feat(database): add TypeORM migration support#469
Merged
Conversation
b2b75ec to
0e9f8b5
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #469 +/- ##
==========================================
- Coverage 55.79% 55.77% -0.02%
==========================================
Files 164 165 +1
Lines 6010 6028 +18
Branches 1359 1358 -1
==========================================
+ Hits 3353 3362 +9
- Misses 2281 2289 +8
- Partials 376 377 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
5036ead to
0aeba40
Compare
BREAKING CHANGE: Schema synchronization is now disabled by default. - Add migration infrastructure with baseline migration for v2.0.0 - Disable synchronize by default (DB_SYNCHRONIZE=false) - Enable auto-run migrations on startup (DB_MIGRATIONS_RUN=true) - Add migration CLI scripts (generate, run, revert, show) - Create data-source.ts for TypeORM CLI operations - Update validation schema with new config options - Document migration workflow in database.md Existing databases are automatically detected - the baseline migration skips table creation if tables already exist from synchronize mode. Signed-off-by: Mirko Mollik <mirko.mollik@eudi.sprind.org>
- Remove complex schema creation from baseline migration - Tests use synchronize=true, production uses migrations - Baseline migration now just records itself without creating tables - Avoids schema mismatch issues between migration SQL and entities Signed-off-by: Mirko Mollik <mirko.mollik@eudi.sprind.org>
Signed-off-by: Mirko Mollik <mirko.mollik@eudi.sprind.org>
Signed-off-by: Mirko Mollik <mirko.mollik@eudi.sprind.org>
Fresh installations need synchronize=true to create the initial schema. Production users can disable it after setup and rely on migrations. Signed-off-by: Mirko Mollik <mirko.mollik@eudi.sprind.org>
c20e47e to
0b9dedf
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.



Summary
Add TypeORM migration support to enable safe database schema upgrades for existing installations.
Breaking Change
Schema synchronization (
synchronize: true) is now disabled by default. Use migrations instead for production safety.Changes
New Files
apps/backend/src/database/data-source.ts- TypeORM CLI datasource configurationapps/backend/src/database/migrations/1740000000000-BaselineMigration.ts- Baseline migration capturing current schemaapps/backend/src/database/migrations/README.md- Migration workflow documentationModified Files
apps/backend/src/database/database.module.ts- Added migration configuration and startup warning for pending migrationsapps/backend/src/database/database-validation.schema.ts- AddedDB_SYNCHRONIZEandDB_MIGRATIONS_RUNoptionsapps/backend/package.json- Added migration CLI scripts.env.exampleand deployment env files - Documented new configuration optionsdocs/architecture/database.md- Added migrations documentation sectionNew Configuration Options
DB_MIGRATIONS_RUNtrueDB_SYNCHRONIZEfalseMigration Commands
Upgrade Path
Existing installations will work automatically:
synchronize: truemode), creation is skippedNo manual intervention required — just upgrade and restart.