public virtual IReadOnlyList <MigrationOperation> Diff([NotNull] IModel sourceModel, [NotNull] IModel targetModel) { Check.NotNull(sourceModel, "sourceModel"); Check.NotNull(targetModel, "targetModel"); _sourceMapping = _databaseBuilder.GetMapping(sourceModel); _targetMapping = _databaseBuilder.GetMapping(targetModel); _operations = new MigrationOperationCollection(); DiffSequences(); DiffTables(); // TODO: Add more unit tests for the operation order. HandleTransitiveRenames(); return (((IEnumerable <MigrationOperation>)_operations.Get <DropIndexOperation>()) .Concat(_operations.Get <DropForeignKeyOperation>()) .Concat(_operations.Get <DropPrimaryKeyOperation>()) .Concat(_operations.Get <DropColumnOperation>()) .Concat(_operations.Get <DropTableOperation>()) .Concat(_operations.Get <MoveTableOperation>()) .Concat(_operations.Get <RenameTableOperation>()) .Concat(_operations.Get <RenameColumnOperation>()) .Concat(_operations.Get <RenameIndexOperation>()) .Concat(_operations.Get <AlterColumnOperation>()) .Concat(_operations.Get <CreateTableOperation>()) .Concat(_operations.Get <AddColumnOperation>()) .Concat(_operations.Get <AddPrimaryKeyOperation>()) .Concat(_operations.Get <AddForeignKeyOperation>()) .Concat(_operations.Get <CreateIndexOperation>()) .ToArray()); }
public virtual IReadOnlyList <MigrationOperation> Process( [NotNull] MigrationOperationCollection operations, [NotNull] IModel sourceModel, [NotNull] IModel targetModel) { return(operations.GetAll()); }
public virtual IReadOnlyList <MigrationOperation> DropSchema([NotNull] IModel model) { Check.NotNull(model, "model"); _operations = new MigrationOperationCollection(); _operations.AddRange(GetSequences(model).Select( s => OperationFactory.DropSequenceOperation(s))); _operations.AddRange(model.EntityTypes.Select( t => OperationFactory.DropTableOperation(t))); return(OperationProcessor.Process(_operations, model, new Metadata.Model())); }
public virtual IReadOnlyList <MigrationOperation> Diff([NotNull] IModel sourceModel, [NotNull] IModel targetModel) { Check.NotNull(sourceModel, "sourceModel"); Check.NotNull(targetModel, "targetModel"); _operations = new MigrationOperationCollection(); var modelPair = Tuple.Create(sourceModel, targetModel); Dictionary <IProperty, IProperty> columnMap; DiffTables(modelPair, out columnMap); DiffSequences(modelPair, columnMap); // TODO: Add more unit tests for the operation order. HandleTransitiveRenames(); return(OperationProcessor.Process(_operations, sourceModel, targetModel)); }
public virtual IReadOnlyList <MigrationOperation> CreateSchema([NotNull] IModel model) { Check.NotNull(model, "model"); _operations = new MigrationOperationCollection(); _operations.AddRange(GetSequences(model) .Select(s => OperationFactory.CreateSequenceOperation(s))); _operations.AddRange(model.EntityTypes .Select(t => OperationFactory.CreateTableOperation(t))); // TODO: GitHub#1107 _operations.AddRange(_operations.Get <CreateTableOperation>() .SelectMany(o => o.ForeignKeys)); _operations.AddRange(_operations.Get <CreateTableOperation>() .SelectMany(o => o.Indexes)); return(OperationProcessor.Process(_operations, new Metadata.Model(), model)); }
public virtual IReadOnlyList <MigrationOperation> Diff([NotNull] IModel sourceModel, [NotNull] IModel targetModel) { Check.NotNull(sourceModel, "sourceModel"); Check.NotNull(targetModel, "targetModel"); _sourceMapping = _databaseBuilder.GetMapping(sourceModel); _targetMapping = _databaseBuilder.GetMapping(targetModel); _operations = new MigrationOperationCollection(); DiffSequences(); DiffTables(); // TODO: Needs to handle name reuse between renames and circular renames. // TODO: Add unit tests for rename column conflict and operation order. HandleRenameConflicts(); return (((IEnumerable <MigrationOperation>)_operations.Get <DropIndexOperation>()) .Concat(_operations.Get <DropForeignKeyOperation>()) .Concat(_operations.Get <DropPrimaryKeyOperation>()) .Concat(_operations.Get <DropDefaultConstraintOperation>()) .Concat(_operations.Get <MoveTableOperation>()) .Concat(_operations.Get <RenameTableOperation>()) .Concat(_operations.Get <RenameColumnOperation>()) .Concat(_operations.Get <RenameIndexOperation>()) .Concat(_operations.Get <CreateTableOperation>()) .Concat(_operations.Get <AddColumnOperation>()) .Concat(_operations.Get <AlterColumnOperation>()) .Concat(_operations.Get <AddDefaultConstraintOperation>()) .Concat(_operations.Get <AddPrimaryKeyOperation>()) .Concat(_operations.Get <AddForeignKeyOperation>()) .Concat(_operations.Get <CreateIndexOperation>()) .Concat(_operations.Get <DropColumnOperation>()) .Concat(_operations.Get <DropTableOperation>()) .ToArray()); }