Exemple #1
0
        private static void ApplyMigration(IDbMigrator migrator, IDbConnection connection)
        {
            var result = migrator.Migrate(connection);

            if (result.MigrationWasApplied)
            {
                connection.Execute(
                    @"INSERT INTO PocketMigrator.AppliedMigrations
             (MigrationScope,
              MigrationVersion,
              Log,
              AppliedDate)
     VALUES
            (@migrationScope, 
             @migrationVersion,
             @log,
             GetDate())",
                    parameters: new Dictionary <string, object>
                {
                    { "@migrationScope", migrator.MigrationScope },
                    { "@migrationVersion", migrator.MigrationVersion.ToString() },
                    {
                        "@log",
                        $"{migrator.GetType().AssemblyQualifiedName}\n\n{result.Log}".Trim()
                    }
                });
            }
        }
Exemple #2
0
        private static MigrationResult ApplyMigration(IDbMigrator migrator, DbContext connection)
        {
            var result = migrator.Migrate(connection);

            if (result.MigrationWasApplied)
            {
                connection.Database.ExecuteSqlCommand(
                    @"INSERT INTO PocketMigrator.AppliedMigrations
             (MigrationScope,
              MigrationVersion,
              Log,
              AppliedDate)
     VALUES
            (@migrationScope, 
             @migrationVersion,
             @log,
             GetDate())",
                    new SqlParameter("@migrationScope", migrator.MigrationScope),
                    new SqlParameter("@migrationVersion", migrator.MigrationVersion.ToString()),
                    new SqlParameter("@log", $"{migrator.GetType().AssemblyQualifiedName}\n\n{result.Log}".Trim()));
            }

            return(result);
        }