public static void CreateMigrationsTable(IDbConnection connection, IDbTransaction transaction) { var migrationTableMigration = new MigrationScript { Name = "Migration-Table", Script = connection.IsPostgre() ? CreateTableScriptPostgre : CreateTableScript }; ExecuteMigration(connection, transaction, migrationTableMigration); }
public static void ExecuteMigration(IDbConnection connection, IDbTransaction transaction, MigrationScript migrationScript) { var statements = SplitIntoStatements(migrationScript.Script).ToList(); Log.Information("Executing {StatementsCount} statements in migration script {MigrationScriptName}...", statements.Count, migrationScript.Name); statements.ForEach(s => connection.Execute(s, transaction: transaction)); connection.Execute("INSERT INTO Migrations (Id, Filename, AppliedOn) VALUES (@id, @filename, @appliedOn)", new { Id = Guid.NewGuid(), AppliedOn = DateTimeOffset.Now, Filename = migrationScript.Name }, transaction); }