Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic migrations in case of outdated version found in migration_scheme. #93

Open
darkjian opened this issue Feb 19, 2024 · 1 comment

Comments

@darkjian
Copy link

I have studied issues as far as I could, but I haven't found an answer to my question, sorry in advance if I was inattentive.

How can I implement the following task:

When the application is launched, the version of the last added migration file and the version in the database schema should be checked.
If they do not match, load all migrations from files starting with the version specified in the database.

Is it possible with tern now?

p.s. thank you very much for your efforts

@jackc
Copy link
Owner

jackc commented Feb 24, 2024

It is possible, but you would need to wire the calls together. You could use the *Migrator.GetCurrentVersion method to see what the current version is then call *Migrator.Migrate if it is not the latest. See the Status and Migrate functions in main.go for examples of how the CLI tool uses them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants