Atlas migrations#312
Open
bfabio wants to merge 4 commits into
Open
Conversation
dd34780 to
b08caef
Compare
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
b08caef to
68cb7ca
Compare
Member
Author
|
@GitGuardian false positive |
GORM AutoMigrate applies schema changes implicitly at startup. There is no way to review them before they hit the database and no way to roll back. Atlas versioned migrations are explicit SQL files that get committed and reviewed like any other code change. The binary gains a `migrate` subcommand that shells out to the Atlas CLI. DSNToURL() converts the lib/pq key=value DSN to a postgres:// URL that Atlas expects. AutoMigrate is kept only for SQLite (tests). Fix italia#72.
Without CI checks a developer could change a model and forget to generate the migration, or edit a migration file and break the checksum. atlas-sync runs on PRs that touch models or migrations. It validates the checksum file then checks that `atlas migrate diff` produces no new files (no drift between models and committed migrations). The test workflow now applies migrations with Atlas before running tests, matching how production databases are set up.
Migrations need to run before the new code starts. A Helm pre-upgrade hook Job runs `developers-italia-api migrate` before the Deployment is touched. If it fails the upgrade is aborted and existing pods keep serving. backoffLimit 0 and activeDeadlineSeconds 300 ensure the Job either succeeds or fails definitively within 5 minutes. migrationBaseline lets operators skip the initial migration on databases already set up by GORM AutoMigrate.
68cb7ca to
c917f40
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #72.
cc @tensor5 because this touches the db and the deploy in a potentially risky way + review of the Helm chart
cc @mburri @caebr @ssandino this is a (nice) feature you might want to know about