diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-05-18 12:21:36 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2025-05-18 12:21:36 -0500 |
| commit | 85ba3a74f27c753c08af970d4217ed9fc4a85b54 (patch) | |
| tree | 58d3ec4a4a2fbbf7b3ca712c7feebb5a6c66b20d /src/slskd/Core/Data/Migrations | |
| parent | 5d5a79e06c187cedde3682805d259d50ea0e72c7 (diff) | |
| download | slskd-85ba3a74f27c753c08af970d4217ed9fc4a85b54.tar.gz | |
remove migration history file
Diffstat (limited to 'src/slskd/Core/Data/Migrations')
| -rw-r--r-- | src/slskd/Core/Data/Migrations/README.md | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/slskd/Core/Data/Migrations/README.md b/src/slskd/Core/Data/Migrations/README.md index cae058b2..e8630265 100644 --- a/src/slskd/Core/Data/Migrations/README.md +++ b/src/slskd/Core/Data/Migrations/README.md @@ -1,11 +1,9 @@ # Database Migrations -In the hopefully unlikely event that a non-backwards-compatible schema change to a database migration is necessary, a migration must be written. +In the hopefully unlikely event that a schema change more complex than the simple addition of a column to a database migration is necessary, a migration must be written. Migrations are applied by the `Migrator` at startup. -The `history` file in the data directory is used to attempt to track whether migrations have already been applied. If a migration appears in the history file it won't be run again. Users can delete or modify the `history` file or use the `force` flag to apply them, meaning migrations **MUST** be idempotent. - The `Migrator` creates a backup of each database prior to running any migrations, and if an exception is thrown at any time during the process the `Migrator` will revert to these backups automatically. The backup files are left in place when the migration is complete so that users can manually revert if the migration left their application in a bad state or destroyed or lost data. ## Creating a Migration @@ -18,11 +16,12 @@ Z<MMDDYYYY>_<ShortDescription>Migration Migrations MUST: -* Figure out where on disk the associated database(s) are located. This is accomplished by combining the static `Program.DataDirectory` variable -and the name(s) of the table(s) that need to be migrated. +* Be idempotent. The migration must be able to be run any number of times without corrupting the database or losing data. * Inspect the target database(s) schema to determine whether the migration needs to be applied (if possible) * Use transactions when performing database operations and using/try catch where appropriate to avoid partially applied migrations. -* Log progress, so users can see that the application is performing work while records are updated. +* Figure out where on disk the associated database(s) are located. This is accomplished by combining the static `Program.DataDirectory` variable +and the name(s) of the table(s) that need to be migrated. +* Log progress (with logs prefixed by >), so users can see that the application is performing work while records are updated. Review the `IMigration` interface to determine implementation details. |
