diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-05-25 17:53:31 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2025-05-25 17:53:31 -0500 |
| commit | 930df71e94dedd5de5267418c3e7666a86eea416 (patch) | |
| tree | 083ea0dd1f3147c7f8e38a82e2df788562897c97 /src/slskd/Core | |
| parent | 7a44729293863b494fd929b91f349f47b8603e7c (diff) | |
| download | slskd-930df71e94dedd5de5267418c3e7666a86eea416.tar.gz | |
final tweaks
Diffstat (limited to 'src/slskd/Core')
| -rw-r--r-- | src/slskd/Core/Data/IMigration.cs | 38 | ||||
| -rw-r--r-- | src/slskd/Core/Data/Migrations/README.md | 4 | ||||
| -rw-r--r-- | src/slskd/Core/Data/Migrator.cs | 20 |
3 files changed, 39 insertions, 23 deletions
diff --git a/src/slskd/Core/Data/IMigration.cs b/src/slskd/Core/Data/IMigration.cs new file mode 100644 index 00000000..18b198b2 --- /dev/null +++ b/src/slskd/Core/Data/IMigration.cs @@ -0,0 +1,38 @@ +// <copyright file="IMigration.cs" company="slskd Team"> +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// </copyright> + +namespace slskd; + +/// <summary> +/// Applies database migrations. +/// </summary> +public interface IMigration +{ + /// <summary> + /// Determines whether the migration needs to be applied. + /// </summary> + /// <remarks> + /// This method MUST be read-only and should contain no side effects. + /// </remarks> + /// <returns>A value indicating whether the migration needs to be applied.</returns> + bool NeedsToBeApplied(); + + /// <summary> + /// Applies the migration. + /// </summary> + void Apply(); +}
\ No newline at end of file diff --git a/src/slskd/Core/Data/Migrations/README.md b/src/slskd/Core/Data/Migrations/README.md index e8630265..2b5fd6f4 100644 --- a/src/slskd/Core/Data/Migrations/README.md +++ b/src/slskd/Core/Data/Migrations/README.md @@ -27,6 +27,4 @@ Review the `IMigration` interface to determine implementation details. The new `IMigration` implementation must be added to the dictionary in the `Migrations` property of the `Migrator` in the desired order so that it can be run. -### Above all else, each and every migration **MUST** be idempotent. - -Users can delete the history file or use the `force` flag to cause migrations to be run again. We can inspect schemas to determine whether re-running is necessary, but there may be cases where that's not enough.
\ No newline at end of file +### Above all else, each and every migration **MUST** be idempotent; they'll be evaluated and run each time the app starts.
\ No newline at end of file diff --git a/src/slskd/Core/Data/Migrator.cs b/src/slskd/Core/Data/Migrator.cs index 4cc56147..e359d334 100644 --- a/src/slskd/Core/Data/Migrator.cs +++ b/src/slskd/Core/Data/Migrator.cs @@ -28,26 +28,6 @@ using slskd.Migrations; /// <summary> /// Applies database migrations. /// </summary> -public interface IMigration -{ - /// <summary> - /// Determines whether the migration needs to be applied. - /// </summary> - /// <remarks> - /// This method MUST be read-only and should contain no side effects. - /// </remarks> - /// <returns>A value indicating whether the migration needs to be applied.</returns> - bool NeedsToBeApplied(); - - /// <summary> - /// Applies the migration. - /// </summary> - void Apply(); -} - -/// <summary> -/// Applies database migrations. -/// </summary> public class Migrator { /// <summary> |
