示例#1
0
 public static CreateTableMigration FromMemento(MigrationMemento memento, IImmutableDictionary <BigInteger, Migration> migrationsByHashCode)
 {
     return(new CreateTableMigration(
                (UseSchemaMigration)migrationsByHashCode[memento.Prerequisites["Parent"].Single()],
                memento.Attributes["TableName"],
                memento.Prerequisites["Prerequisites"].Select(p => migrationsByHashCode[p]).ToImmutableList()));
 }
示例#2
0
 public static CreateIndexMigration FromMemento(MigrationMemento memento, IImmutableDictionary <BigInteger, Migration> migrationsByHashCode)
 {
     return(new CreateIndexMigration(
                (CreateTableMigration)migrationsByHashCode[memento.Prerequisites["Parent"].Single()],
                memento.Prerequisites["Columns"].Select(p => migrationsByHashCode[p]).OfType <CreateColumnMigration>(),
                memento.Prerequisites["Prerequisites"].Select(p => migrationsByHashCode[p]).ToImmutableList()));
 }
        private string GenerateMigrationValue(MigrationMemento migration)
        {
            string attributes = JsonConvert.SerializeObject(migration.Attributes);
            string hex        = $"0x{migration.HashCode.ToString("X")}";

            return($@"
    ('{migration.Type}', {hex}, '{attributes.Replace("'", "''")}')");
        }
 public static CustomSqlMigration FromMemento(MigrationMemento memento, IImmutableDictionary <BigInteger, Migration> migrationsByHashCode)
 {
     return(new CustomSqlMigration(
                memento.Attributes["DatabaseName"],
                memento.Attributes["Up"],
                memento.Attributes["Down"],
                memento.Prerequisites["Prerequisites"].Select(p => migrationsByHashCode[p]).ToImmutableList()));
 }
 public static CreateColumnMigration FromMemento(MigrationMemento memento, IImmutableDictionary <BigInteger, Migration> migrationsByHashCode)
 {
     return(new CreateColumnMigration(
                (CreateTableMigration)migrationsByHashCode[memento.Prerequisites["Parent"].Single()],
                memento.Attributes["ColumnName"],
                memento.Attributes["TypeDescriptor"],
                memento.Attributes["Nullable"] == "true",
                memento.Prerequisites["Prerequisites"].Select(x => migrationsByHashCode[x]).ToImmutableList()));
 }
示例#6
0
 public static CreateForeignKeyMigration FromMemento(MigrationMemento memento, IImmutableDictionary <BigInteger, Migration> migrationsByHashCode)
 {
     return(new CreateForeignKeyMigration(
                (CreateIndexMigration)migrationsByHashCode[memento.Prerequisites["Parent"].Single()],
                (CreatePrimaryKeyMigration)migrationsByHashCode[memento.Prerequisites["Referencing"].Single()],
                memento.Attributes["CascadeDelete"] == "true",
                memento.Attributes["CascaseUpdate"] == "true",
                memento.Prerequisites["Prerequisites"].Select(x => migrationsByHashCode[x]).ToImmutableList()));
 }
        private static MigrationMemento LoadMemento(LookaheadEnumerator <MigrationHistoryRow> enumerator)
        {
            var type       = enumerator.Current.Type;
            var hashCode   = enumerator.Current.HashCode;
            var attributes = enumerator.Current.Attributes;
            var roles      = LoadRoles(hashCode, enumerator);

            var migrationAttributes = JsonConvert.DeserializeObject <Dictionary <string, string> >(attributes);
            var memento             = new MigrationMemento(
                type,
                migrationAttributes,
                hashCode,
                roles);

            return(memento);
        }