added index

This commit is contained in:
Nicolas Constant 2021-01-23 00:11:31 -05:00
parent f6ed37b46a
commit 2f933ffc9c
No known key found for this signature in database
GPG key ID: 1E9F677FB01A5688
3 changed files with 13 additions and 12 deletions

View file

@ -141,6 +141,10 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers
{
var addLastSync = $@"ALTER TABLE {_settings.TwitterUserTableName} ADD lastSync TIMESTAMP (2) WITHOUT TIME ZONE";
await _tools.ExecuteRequestAsync(addLastSync);
var addIndex = $@"CREATE INDEX IF NOT EXISTS lastsync_twitteruser ON {_settings.TwitterUserTableName}(lastSync)";
await _tools.ExecuteRequestAsync(addIndex);
return new Version(2, 0);
}

View file

@ -18,18 +18,11 @@ namespace BirdsiteLive.DAL.Postgres.Tools
public async Task ExecuteRequestAsync(string request)
{
try
using (var conn = new NpgsqlConnection(_settings.ConnString))
using (var cmd = new NpgsqlCommand(request, conn))
{
using (var conn = new NpgsqlConnection(_settings.ConnString))
using (var cmd = new NpgsqlCommand(request, conn))
{
await conn.OpenAsync();
await cmd.ExecuteNonQueryAsync();
}
}
catch (Exception e)
{
Console.WriteLine(e);
await conn.OpenAsync();
await cmd.ExecuteNonQueryAsync();
}
}
}

View file

@ -13,7 +13,11 @@ namespace BirdsiteLive.DAL.Postgres.Tests.DataAccessLayers
public async Task CleanUp()
{
var dal = new DbInitializerPostgresDal(_settings, _tools);
await dal.DeleteAllAsync();
try
{
await dal.DeleteAllAsync();
}
catch (Exception ) { }
}
[TestMethod]