Exemplo n.º 1
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()));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
 private void FindMovedTables(
     IEnumerable <Tuple <IEntityType, IEntityType> > tablePairs)
 {
     _operations.AddRange(
         tablePairs
         .Where(pair => !MatchTableSchemas(pair.Item1, pair.Item2))
         .Select(pair => OperationFactory.MoveTableOperation(pair.Item1, pair.Item2)));
 }