Add project files.
This commit is contained in:
44
LoadStockDbFromTrans/DbInitializers/SqliteDbInitializer.cs
Normal file
44
LoadStockDbFromTrans/DbInitializers/SqliteDbInitializer.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Dapper;
|
||||
using LoadStockDbFromTrans.DbConnections;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Data;
|
||||
|
||||
namespace LoadStockDbFromTrans.DbInitializers
|
||||
{
|
||||
|
||||
public class SqliteDbInitializer : ISqliteDbInitializer
|
||||
{
|
||||
private const string INIT_TABLE = @"
|
||||
CREATE TABLE [NewBackupRegings] (
|
||||
[Id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
|
||||
, [BackedUp] text NOT NULL
|
||||
, [DbName]
|
||||
text NULL
|
||||
, [BackupDbName] text NULL
|
||||
, [BackupPath] text NULL
|
||||
)";
|
||||
|
||||
private readonly SqliteDbConnectionFactory _sqliteDbConnectionFactory;
|
||||
private readonly ILogger<SqliteDbInitializer> _log;
|
||||
|
||||
public SqliteDbInitializer(SqliteDbConnectionFactory sqliteDbConnectionFactory, ILogger<SqliteDbInitializer> log)
|
||||
{
|
||||
_sqliteDbConnectionFactory = sqliteDbConnectionFactory;
|
||||
_log = log;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_log.LogInformation(INIT_TABLE);
|
||||
using (IDbConnection database = _sqliteDbConnectionFactory.Connect())
|
||||
{
|
||||
database.Execute(INIT_TABLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user