From 930df71e94dedd5de5267418c3e7666a86eea416 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 May 2025 17:53:31 -0500 Subject: final tweaks --- src/slskd/Core/Data/IMigration.cs | 38 ++++++++++++++++++++++++++++++++ src/slskd/Core/Data/Migrations/README.md | 4 +--- src/slskd/Core/Data/Migrator.cs | 20 ----------------- 3 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 src/slskd/Core/Data/IMigration.cs (limited to 'src') 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 (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/. +// + +namespace slskd; + +/// +/// Applies database migrations. +/// +public interface IMigration +{ + /// + /// Determines whether the migration needs to be applied. + /// + /// + /// This method MUST be read-only and should contain no side effects. + /// + /// A value indicating whether the migration needs to be applied. + bool NeedsToBeApplied(); + + /// + /// Applies the migration. + /// + 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 @@ -25,26 +25,6 @@ using System.Linq; using Serilog; using slskd.Migrations; -/// -/// Applies database migrations. -/// -public interface IMigration -{ - /// - /// Determines whether the migration needs to be applied. - /// - /// - /// This method MUST be read-only and should contain no side effects. - /// - /// A value indicating whether the migration needs to be applied. - bool NeedsToBeApplied(); - - /// - /// Applies the migration. - /// - void Apply(); -} - /// /// Applies database migrations. /// -- cgit v1.2.3