-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SPSH-595: Datenbankschema Migrationen (#495)
* add command for migration, add migrations pckg to project, add tests * adjust docs * adjust README * add migrate up command * split db-migration commands in different console-files * adjust migration docu * add initial migration * trigger pipeline run * make migration available in cluster * add migration docu for DEV and TEST * change migration config * fix typo README
- Loading branch information
Showing
19 changed files
with
2,157 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
33 changes: 33 additions & 0 deletions
33
charts/dbildungs-iam-server/migrations/Migration20240515131039.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
9 changes: 9 additions & 0 deletions
9
charts/dbildungs-iam-server/templates/backend-migration-configmap.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "common.names.name" . }}-backend-migration | ||
namespace: {{ template "common.names.namespace" . }} | ||
labels: | ||
{{- include "common.labels" . | nindent 4 }} | ||
data: | ||
{{ (.Files.Glob "migrations/*").AsConfig | indent 2 }} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Migration via Mikro-Orm Extension | ||
|
||
## Commands | ||
|
||
Run `npm run db:migration-create` to create a new migration | ||
|
||
Run `npm run db:migration-apply` apply the latest version of migration to the database, latest migration files MUST BE available in `./dist/migrations`. | ||
You can ensure this by starting the app via `npm run start`. | ||
|
||
Run `npm run db:migration-init` to create a new initial migration (not necessary anymore, initial migration has been done) | ||
The execution of migration-init can cause following error with current configuration: | ||
```bash | ||
... | ||
[Error: ENOENT: no such file or directory, open '.../dbildungs-iam-server/migrations/.snapshot-dbildungs-iam-server.json'] { | ||
errno: -2, | ||
code: 'ENOENT', | ||
syscall: 'open', | ||
path: '...dbildungs-iam-server/migrations/.snapshot-dbildungs-iam-server.json' | ||
} | ||
``` | ||
|
||
To be able to execute migration-init, temporally adjust `path` in migrations-configuration of console.module.ts | ||
```typescript | ||
extensions: [Migrator], | ||
migrations: { | ||
tableName: 'mikro_orm_migrations' | ||
path: './dist/migrations', | ||
pathTs: './migrations', | ||
``` | ||
## Execution | ||
### Noteworthy | ||
- The parameter `disableForeignKeys` has to be false for execution in cluster, permissions are not sufficient. | ||
- Local the usage of `disableForeignKeys: true` is possible. | ||
### On branched enviroments | ||
`npm run db:migration-apply` is run via pipeline for the individual environments. | ||
### On DEV and TEST | ||
Like with some other tasks regarding database, migration on DEV and TEST is easier to apply, if tables or whole schema can be dropped beforehand. | ||
## Files | ||
Migration files are stored in ./migrations | ||
## Tests | ||
For testing purposes of the migration-console another directory `./test-migrations` is created during test execution. | ||
This directory is deleted before test-execution to avoid errors regarding existing migration-files, it is also included in the [.gitignore](./../.gitignore) |
Oops, something went wrong.