public DesignSchemaMigrations GetCurrentMigrations() { StoreSchemaMigrations package = _migrationAggregator.GenerateMigrations(Schema, SchemaMigrations, _designRecords); var result = DesignSchemaMigrations.FromStoreMigrations(package); return(result); }
public StoreSchemaMigrations GenerateMigrations(DesignSchema schema, DesignSchemaMigrations src, List <DesignLogRecord> log) { if (schema.Version == INITIAL_VERSION) { var package = new StoreSchemaMigrations { SchemaName = schema.Name, Migrations = new StoreMigration[] { GenerateInitialMigration(schema, log) } }; return(package); } else { var package = new StoreSchemaMigrations { SchemaName = schema.Name, Migrations = src.GetStoreMigrations() }; var lastMigration = package.Migrations[package.Migrations.Length - 1]; // we clone it to make sure we don't modify SchemaMigrations data lastMigration = lastMigration.GetCopy() as StoreMigration; package.Migrations[package.Migrations.Length - 1] = lastMigration; var lastCommands = new List <MigrationCommand>(lastMigration.Commands ?? new MigrationCommand[0]); var newMigration = GenerateIncrementalMigration(schema, log); lastCommands.AddRange(newMigration.Commands); lastMigration.Commands = lastCommands.ToArray(); return(package); } }
public void LoadMigrations(string path) { var fileName = Path.Combine(path, GenerateMigrationFileName(path)); var package = _schemaStorage.LoadMigrations(new StorageParameters { FileName = fileName }); SchemaMigrations = DesignSchemaMigrations.FromStoreMigrations(package); }
public void SaveMigrations(string path) { StoreSchemaMigrations package = _migrationAggregator.GenerateMigrations(Schema, SchemaMigrations, _designRecords); var fileName = Path.Combine(path, GenerateMigrationFileName(path)); var parameters = new StorageParameters { FileName = fileName }; var schema = DesignSchemaConvert.ToStoreSchema(Schema); _schemaStorage.SaveMigration(package, parameters); SchemaMigrations = DesignSchemaMigrations.FromStoreMigrations(package); ClearLog(); }
//public void LoadSchema() //{ //} public void NewSchema() { Schema = new DesignSchema { Name = "New Schema", Version = "1.0", DataContextName = Parameters.DataService, Namespace = Parameters.Namespace, Changed = true, IsNew = true }; SchemaMigrations = new DesignSchemaMigrations(); var nm = new StoreMigration { Version = DesignSchemaMigrations.InitialVersion, Created = DateTime.UtcNow, VersionKey = Guid.NewGuid() }; //SchemaMigrations.Migrations.Add(new DesignMigration { StatusText = "Empty", VersionText = "Initial 1.0" }); SchemaMigrations.Migrations.Add(new DesignMigration(nm)); SelectedTable = null; ClearLog(); UpdateLog(DesignOperation.CreateSchema); UpdateDiagramTables(); }