From cdb8aa48e16a87e966f61b15fe7aa083b3336071 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sat, 23 Jan 2021 00:23:37 -0500 Subject: [PATCH] added Db version update --- .../DataAccessLayers/DbInitializerPostgresDal.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/DbInitializerPostgresDal.cs b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/DbInitializerPostgresDal.cs index fd4b703..ca883ff 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/DbInitializerPostgresDal.cs +++ b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/DataAccessLayers/DbInitializerPostgresDal.cs @@ -145,12 +145,25 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers var addIndex = $@"CREATE INDEX IF NOT EXISTS lastsync_twitteruser ON {_settings.TwitterUserTableName}(lastSync)"; await _tools.ExecuteRequestAsync(addIndex); - return new Version(2, 0); + await UpdateDbVersionAsync(to); + return to; } throw new NotImplementedException(); } + private async Task UpdateDbVersionAsync(Version newVersion) + { + using (var dbConnection = Connection) + { + dbConnection.Open(); + + await dbConnection.ExecuteAsync( + $"UPDATE {_settings.DbVersionTableName} SET major = @major, minor = @minor WHERE type = @type", + new { type = DbVersionType, major = newVersion.Major, minor = newVersion.Minor }); + } + } + public async Task DeleteAllAsync() { var dropsRequests = new[]