Calculate changes for migrations from models2 to models1.
762391
def diff_many(models1, models2, migrator=None, reverse=False):
    """"""
    models1 = pw.sort_models(models1)
    models2 = pw.sort_models(models2)

    if reverse:
        models1 = reversed(models1)
        models2 = reversed(models2)

    models1 = OrderedDict([(m._meta.name, m) for m in models1])
    models2 = OrderedDict([(m._meta.name, m) for m in models2])

    changes = []

    for name, model1 in models1.items():
        if name not in models2:
            continue
        changes += diff_one(model1, models2[name], migrator=migrator)

    # Add models
    for name in [m for m in models1 if m not in models2]:
        changes.append(create_model(models1[name], migrator=migrator))

    # Remove models
    for name in [m for m in models2 if m not in models1]:
        changes.append(remove_model(models2[name]))

    return changes
112988
public function migrateUp()
    {
        $this->builder->table(
            $this->table,
            function ($table) {
                $table->string('medium')->nullable()->index();
                $table->string('source')->nullable()->index();
                $table->string('search_terms_hash')->nullable()->index();
            }
        );

        $this->builder->table($this->foreign, function ($table) {
            $table->foreign('referer_id', 'tracker_referers_referer_id_fk')
                ->references('id')
                ->on('tracker_referers')
                ->onUpdate('cascade')
                ->onDelete('cascade');
        });
    }
136546
def update_models(ctx, f=False):
    
    if f:
        manage(ctx, 'create_models_from_sql --force True', env={})
    else:
        manage(ctx, 'create_models_from_sql', env={})
585882
def update_models(self, model, name, info):
        

        if info.method_name in ["add_input_data_port", "remove_input_data_port", "input_data_ports"]:
            (model_list, data_list, model_name, model_class, model_key) = self.get_model_info("input_data_port")
        elif info.method_name in ["add_output_data_port", "remove_output_data_port", "output_data_ports"]:
            (model_list, data_list, model_name, model_class, model_key) = self.get_model_info("output_data_port")
        elif info.method_name in ["add_income", "remove_income", "income"]:
            (model_list, data_list, model_name, model_class, model_key) = self.get_model_info("income")
        elif info.method_name in ["add_outcome", "remove_outcome", "outcomes"]:
            (model_list, data_list, model_name, model_class, model_key) = self.get_model_info("outcome")
        else:
            return

        if "add" in info.method_name:
            self.add_missing_model(model_list, data_list, model_name, model_class, model_key)
        elif "remove" in info.method_name:
            destroy = info.kwargs.get('destroy', True)
            self.remove_specific_model(model_list, info.result, model_key, destroy)
        elif info.method_name in ["input_data_ports", "output_data_ports", "income", "outcomes"]:
            self.re_initiate_model_list(model_list, data_list, model_name, model_class, model_key)
993854
public function up()
    {
        // Check if the 2 tables exist
        if (Schema::hasTable('tags') && Schema::hasTable('taggables')) {
            if (Schema::hasColumn('tags', 'tagable_id') && Schema::hasColumn('tags', 'tagable_type')) {
                $tags = DB::select('select * from tags');
                foreach ($tags as $tag) {
                    // Points to new namespace Redooor\\Redminportal\\App\\Models\\
                    $new_type_array = explode('\\', $tag->tagable_type);
                    $last_model = array_pop($new_type_array);
                    $new_type = 'Redooor\\Redminportal\\App\\Models\\' . $last_model;
                    DB::table('taggables')->insert([
                        'tag_id' => $tag->id,
                        'taggable_id' => $tag->tagable_id,
                        'taggable_type' => $new_type
                    ]);
                }
                Schema::table('tags', function ($table) {
                    $table->dropColumn(['tagable_id', 'tagable_type']);
                });
            }
        }
    }
891518
def migrate(schema_file, config_file):
    ''''''

    schema = load_schema_file(open(schema_file, 'r'))
    config = load_config_file(config_file, open(config_file, 'r').read())

    config = append_existing_values(schema, config)

    migrated_config = generate_config_parser(config)
    migrated_config.write(sys.stdout)
244699
def migrate_constituencies(apps, schema_editor):
    
    Constituency = apps.get_model("representatives", "Constituency")
    for c in Constituency.objects.all():
        c.save()
1187239
public function runMigrations()
	{
		$migrations = Model::where('status', 'pending');

		if ($migrations->get()->size() > 0) {
			foreach($migrations->get()->all() as $migration) {
				$this->runSingleMigration($migration);
			}
		}
	}
1043635
def model_changed(self, model):
        
        callbacks = [cb for cbs in self.traverse(lambda x: x.callbacks)
                     for cb in cbs]
        stream_metadata = [stream._metadata for cb in callbacks
                           for stream in cb.streams if stream._metadata]
        return any(md['id'] == model.ref['id'] for models in stream_metadata
                   for md in models.values())
421005
def migrateUp(self):
        
        te = self.store.findFirst(TimedEvent, sort=TimedEvent.time.descending)
        if te is not None:
            self._transientSchedule(te.time, None)
1045266
def _migrate(data: Mapping[str, Any]) -> SettingsData:
    
    next = dict(data)
    version = next.pop('_version', 0)
    target_version = len(_MIGRATIONS)
    migrations = _MIGRATIONS[version:]

    if len(migrations) > 0:
        log.info(
            "Migrating advanced settings from version {} to {}"
            .format(version, target_version))

    for m in migrations:
        next = m(next)

    return next, target_version
1171806
function previous(version, migrations) {
  function cmp(a, b) { return parseInt(a, 10) > parseInt(b, 10); }
  var regex = RegExp('^(' + version + '):?.*$');
  var keys = _.keys(migrations).sort(cmp);
  for (var i = 0, found; i < keys.length; i++) {
    if (keys[i].match(regex)) {
      found = keys[i - 1];
      break;
    }
  }
  return found || '0000';
}
562382
def handle_relations(changeset):
    """"""
    for relation in changeset.bundle.get('relations', []):
        relations = [models.Relation(*i.split(':')) if ':' in i
                     else models.Relation(i, '') for i in relation]
        changeset.send({
            'id': 'addRelation-{}'.format(changeset.next_action()),
            'method': 'addRelation',
            'args': [
                '${}'.format(
                    changeset.services_added[rel.name]) +
                (':{}'.format(rel.interface) if rel.interface else '')
                for rel in relations
            ],
            'requires': [changeset.services_added[rel.name] for
                         rel in relations],
        })
    return handle_units
1132979
def migration_data(self):
        
        return self.session.query(
            self.migration_model).filter_by(name=self.name).first()
247697
function () {
                /*  determine parameters  */
                var params = $cs.params("migrate", arguments, {
                    comps:     { pos: "...", req: true    },
                    sync:      {             def: false   },
                    completed: {             def: $cs.nop }
                });

                /*  iterate over all components to migrate  */
                var n = 0;
                var parent = this;
                _cs.foreach(params.comps, function (comp) {
                    if (params.sync) {
                        /*  migrate synchronously  */
                        var state_old = comp.state();
                        comp.state({ state: "created", sync: true });
                        comp.detach();
                        comp.attach(parent);
                        comp.state(state_old);
                    }
                    else {
                        /*  migrate asynchronously  */
                        (function (comp, state_old) {
                            comp.state({ state: "created", sync: false, callback: function (/* state_new */) {
                                this.detach();
                                this.attach(parent);
                                this.state({ state: state_old, sync: false, callback: function (/* state_old */) {
                                    n--;
                                    if (n === 0)
                                        params.completed.call(null);
                                }});
                            }});
                        })(comp, comp.state());
                        n++;
                    }
                });
            }
699326
public ModelDiff diff() {
        if (diff != null) return diff;

        setOffline();

        setDefaults();

        try {
            migrationModel = new MigrationModel(server);
            ModelContainer migrated = migrationModel.read();

            currentModel = new CurrentModel(server, constraintNaming);
            ModelContainer current = currentModel.read();
            diff = new ModelDiff(migrated);
            diff.compareTo(current);
        } finally {
            if (!online) {
                DbOffline.reset();
            }
        }
        return diff;
    }
881138
def change_prior(self, **kwargs):
        
        for kw in kwargs:
            if kw in self.priorfactors:
                self.priorfactors[kw] = kwargs[kw]
                logging.info('{0} changed to {1} for {2} model'.format(kw,kwargs[kw],
                                                                       self.model))