示例#1
0
 public virtual IReadOnlyList <MigrationOperation> Process(
     [NotNull] MigrationOperationCollection operations,
     [NotNull] IModel sourceModel,
     [NotNull] IModel targetModel)
 {
     return(operations.GetAll());
 }
示例#2
0
        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 Model()));
        }
示例#3
0
        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));
        }
示例#4
0
        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 Model(), model));
        }