aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-04-27 18:38:26 +0800
committercrupest <crupest@outlook.com>2021-04-27 18:38:26 +0800
commit6c9778b55dd8367d38280c66e0f308c5332029ed (patch)
treeb59aaf0194103af93c5a0c5e4e8bfd1b414ac201 /BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs
parenta341819711cda358652ad84b1e507d9559ecabfd (diff)
downloadtimeline-6c9778b55dd8367d38280c66e0f308c5332029ed.tar.gz
timeline-6c9778b55dd8367d38280c66e0f308c5332029ed.tar.bz2
timeline-6c9778b55dd8367d38280c66e0f308c5332029ed.zip
refactor: Refactor is still on...
Diffstat (limited to 'BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs')
-rw-r--r--BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs17
1 files changed, 6 insertions, 11 deletions
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs b/BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs
index 2180ad40..20e2c074 100644
--- a/BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs
+++ b/BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs
@@ -7,17 +7,12 @@ using Timeline.Entities;
namespace Timeline.Services.DatabaseManagement
{
- public interface IDatabaseCustomMigrator
- {
- Task MigrateAsync(CancellationToken cancellationToken = default);
- }
-
public class DatabaseCustomMigrator : IDatabaseCustomMigrator
{
- private IEnumerable<IDatabaseCustomMigration> _migrations;
- private DatabaseContext _database;
+ private readonly IEnumerable<IDatabaseCustomMigration> _migrations;
+ private readonly DatabaseContext _database;
- private ILogger<DatabaseCustomMigrator> _logger;
+ private readonly ILogger<DatabaseCustomMigrator> _logger;
public DatabaseCustomMigrator(IEnumerable<IDatabaseCustomMigration> migrations, DatabaseContext database, ILogger<DatabaseCustomMigrator> logger)
{
@@ -33,11 +28,11 @@ namespace Timeline.Services.DatabaseManagement
var name = migration.GetName();
var isApplied = await _database.Migrations.AnyAsync(m => m.Name == name, cancellationToken);
- _logger.LogInformation("Found custom migration '{0}'. Applied: {1}.", name, isApplied);
+ _logger.LogInformation(Resource.DatabaseCustomMigratorFoundMigration, name, isApplied);
if (!isApplied)
{
- _logger.LogWarning("Begin custom migration '{0}'.", name);
+ _logger.LogWarning(Resource.DatabaseCustomMigratorBeginMigration, name);
await using var transaction = await _database.Database.BeginTransactionAsync(cancellationToken);
@@ -48,7 +43,7 @@ namespace Timeline.Services.DatabaseManagement
await transaction.CommitAsync(cancellationToken);
- _logger.LogWarning("End custom migration '{0}'.", name);
+ _logger.LogWarning(Resource.DatabaseCustomMigratorFinishMigration, name);
}
}
}