It's the easiest procedure: it just merge the old schema into the new
one by doing a few temporary steps: very fast, very easy.
543328
private function migrateKeepingRegions(bool $useRegionAsStyle = false)
    {
        /** @var \DatabaseConnection $database */
        $database = $this->getContainer()->get('database');

        $database->query("
            delete from {layout}
        ");

        $database->query("
            create temporary table {temp_layout_migrate} as
            select
                l.id as layout_id, l.nid, l.site_id, region, 0 as new_id
            from {ucms_layout} l
            join {ucms_layout_data} d
                on d.layout_id = l.id
            group by
                l.id, d.region, l.site_id, l.nid
        ");

        $database->query("
            insert into {layout} (site_id, node_id, region)
            select
                site_id, nid, region
            from {temp_layout_migrate}
        ");

        $database->query("
            update {temp_layout_migrate}
            set
                new_id = (
                    select id
                    from {layout} l
                    where
                        l.region = {temp_layout_migrate}.region
                        and l.site_id = {temp_layout_migrate}.site_id
                        and l.node_id = {temp_layout_migrate}.nid
                )
        ");

        if ($useRegionAsStyle) {
            $database->query("
                insert into {layout_data} (layout_id, item_type, item_id, style, position)
                select
                    t.new_id, 'node', d.nid, d.region, d.weight
                from {ucms_layout_data} d
                join {temp_layout_migrate} t
                    on t.layout_id = d.layout_id
                    and t.region = d.region
            ");
        } else {
            $database->query("
                insert into {layout_data} (layout_id, item_type, item_id, style, position)
                select
                    t.new_id, 'node', d.nid, d.view_mode, d.weight
                from {ucms_layout_data} d
                join {temp_layout_migrate} t
                    on t.layout_id = d.layout_id
                    and t.region = d.region
            ");
        }
    }
1262377
public function upgradeSchema(Schema $schema)
    {
        $table = $schema->getTable('FileImageThumbnailPaths');
        if ($table->hasIndex('thumbnailPathID')) {
            $table->dropIndex('thumbnailPathID');
        }
        if (!$table->hasColumn('thumbnailFormat')) {
            $table->addColumn(
                'thumbnailFormat',
                'string',
                [
                    'notnull' => true,
                    'default' => '',
                    'length' => 5,
                ]
            );
            $table->setPrimaryKey([
                'fileID',
                'fileVersionID',
                'thumbnailTypeHandle',
                'storageLocationID',
                'thumbnailFormat',
            ]);
        }
    }
962283
def merge(new, old):
    '''  '''

    for k, vals in new.items():

        if k == 'synonyms':
            new_synonyms = vals
            if old['synonyms']:
                old_literals = [syn['literal'].lower().strip() for syn in old['synonyms']]
                for new_synonym in new_synonyms:
                    if new_synonym['literal'].lower().strip() not in old_literals:
                        old['synonyms'].append(new_synonym) # default is a list in SciCrunch, that's why this works without initing old['synonyms']
            else:
                old['synonyms'].extend(new['synonyms'])

        elif k == 'existing_ids':
            iris = [e['iri'] for e in old['existing_ids']]
            for new_existing_id in vals:

                new_existing_id['preferred'] = 0

                if 'change' not in list(new_existing_id):  # notion that you want to add it
                    new_existing_id['change'] = False

                if new_existing_id.get('delete') == True:
                    if new_existing_id['iri'] in iris:
                        new_existing_ids = []
                        for e in old['existing_ids']:
                            if e['iri'] != new_existing_id['iri']:
                                new_existing_ids.append(e)
                        old['existing_ids'] = new_existing_ids
                    else:
                        print(new_existing_id)
                        sys.exit("You want to delete an iri that doesn't exist")

                elif new_existing_id.get('replace') == True:
                    if not new_existing_id.get('old_iri'):
                        sys.exit(
                            'Need to have old_iri as a key to have a ref for replace'
                        )
                    old_iri = new_existing_id.pop('old_iri')
                    if old_iri in iris:
                        new_existing_ids = []
                        for e in old['existing_ids']:
                            if e['iri'] == old_iri:
                                if new_existing_id.get('curie'):
                                    e['curie'] = new_existing_id['curie']
                                if new_existing_id.get('iri'):
                                    e['iri'] = new_existing_id['iri']
                            new_existing_ids.append(e)
                        old['existing_ids'] = new_existing_ids
                    else:
                        print(new_existing_id)
                        sys.exit("You want to replace an iri that doesn't exist", '\n', new)

                else:
                    if new_existing_id['iri'] not in iris and new_existing_id['change'] == True:
                        sys.exit('You want to change iri that doesnt exist ' + str(new))
                    elif new_existing_id['iri'] not in iris and new_existing_id['change'] == False:
                        old['existing_ids'].append(new_existing_id)
                    elif new_existing_id['iri'] in iris and new_existing_id['change'] == True:
                        new_existing_ids = []
                        for e in old['existing_ids']:
                            if e['iri'] == new_existing_id['iri']:
                                if not new_existing_id.get('curie'):
                                    new_existing_id['curie'] = e['curie']
                                new_existing_ids.append(new_existing_id)
                            else:
                                new_existing_ids.append(e)
                        old['existing_ids'] = new_existing_ids
                    elif new_existing_id['iri'] in iris and new_existing_id['change'] == False:
                        pass  # for sanity readability
                    else:
                        sys.exit('Something broke while merging in existing_ids')

        elif k in ['definition', 'superclasses', 'id', 'type', 'comment', 'label', 'uid', 'ontologies']:
            old[k] = vals

        # TODO: still need to mark them... but when batch elastic for update works
        # old['uid'] = 34142  # DEBUG: need to mark as mine manually until all Old terms are fixed

    ''' REMOVE REPEATS; needs to exist due to server overloads '''
    if old.get('synonyms'):
        visited = {}
        new_synonyms = []
        for synonym in old['synonyms']:
            if not visited.get(synonym.get('literal')):
                new_synonyms.append(synonym)
                visited[synonym['literal']] = True
        old['synonyms'] = new_synonyms

    visited = {}
    new_existing_ids = []
    for e in old['existing_ids']:
        if not visited.get(e['iri']):
            new_existing_ids.append(e)
            visited[e['iri']] = True
    old['existing_ids'] = new_existing_ids
    old = preferred_change(old)

    return old
753007
def modify_schema(self, field_schema):
        """"""
        if self.minimum_value:
            field_schema['minLength'] = self.minimum_value

        if self.maximum_value:
            field_schema['maxLength'] = self.maximum_value
298010
def merge(self, other, replacements=None):
        

        # TODO: is the current solution not optimal enough?
        for _, item in other._storage.items():  # type: RegionObject
            for so in item.stored_objects:  # type: StoredObject
                if replacements and so.obj in replacements:
                    so = StoredObject(so.start, replacements[so.obj], so.size)
                self._object_mapping[so.obj_id] = so
                self.__store(so, overwrite=False)

        return self
226429
def merge_schema(first, second):
    
    if not (type(first) == type(second) == dict):
        raise ValueError("Argument is not a schema")

    if not (first.get('type') == second.get('type') == 'object'):
        raise NotImplementedError("Unsupported root type")

    return merge_objects(first, second)
188004
public function upgradeSchema(Schema $schema)
    {
        $this->version->getConfiguration()->getOutputWriter()->write(t('Adding fields to workflow and select tables...'));
        if (!$schema->getTable('Workflows')->hasColumn('pkgID')) {
            $schema->getTable('Workflows')->addColumn('pkgID', 'integer', [
                'unsigned' => true, 'notnull' => true, 'default' => 0,
            ]);
        }
        if (!$schema->getTable('atSelectOptions')->hasColumn('isDeleted')) {
            $schema->getTable('atSelectOptions')->addColumn('isDeleted', 'boolean', [
                'default' => 0,
            ]);
        }
    }
676207
public function migrateUp()
    {
        Schema::create('tddd_projects', function (Blueprint $table) {
            $table->increments('id');

            $table->string('name');

            $table->string('path');

            $table->string('tests_path');

            $table->timestamps();
        });
    }
1079601
def merge(config, revisions, **kwargs):
    
    with alembic_lock(
        config.registry["sqlalchemy.engine"], config.alembic_config()
    ) as alembic_config:
        alembic.command.merge(alembic_config, revisions, **kwargs)
1106995
def _merge_cluster(old, new):
    """"""
    logger.debug("_merge_cluster: %s to %s" % (old.id, new.id))
    logger.debug("_merge_cluster: add idls %s" % old.loci2seq.keys())
    for idl in old.loci2seq:
        # if idl in new.loci2seq:
        #    new.loci2seq[idl] = list(set(new.loci2seq[idl] + old.loci2seq[idl]))
        # new.loci2seq[idl] = old.loci2seq[idl]
        new.add_id_member(old.loci2seq[idl], idl)
    return new
487091
def migrate_data(self, data, from_state):
        
        for instance in data:
            if instance.status == 'ER':
                continue

            container = getattr(instance, self.schema_type, {})
            schema = container.pop(self.field[-1])
            container[self.new_field] = schema

            setattr(instance, self.schema_type, container)
            instance.save()
518240
public function up(Schema $schema)
    {
        /*
         * Migration is not critical
         * Old format for storing image files to the new format
         *
         * Old format(date added image):
         *    media/{Y}/{m}/
         *
         * New Format(date added item):
         *    media/{Y}/{m}/{d}/{His}/
         */

        // move covers
        $items = $this->connection->fetchAll('
            SELECT
                `id`,
                `cover`,
                `date_add`
            FROM
                `item`
            WHERE
                `cover` IS NOT NULL AND
                `cover` != "" AND
                `cover`  NOT LIKE "example/%"'
        );
        foreach ($items as $item) {
            $path = date('Y/m/d/His/', strtotime($item['date_add']));
            $file = new File($this->media_dir.$item['cover']);
            $file->move($this->media_dir.$path);
            $this->addSql('
                UPDATE
                    `item`
                SET
                    `cover` = ?
                WHERE
                    `id` = ?',
                [
                    $path.$file->getBasename(),
                    $item['id'],
                ]
            );
        }

        // move images
        $images = $this->connection->fetchAll('
            SELECT
                im.`id`,
                im.`source`,
                i.`date_add`
            FROM
                `item` AS `i`
            INNER JOIN
                `image` AS `im`
                ON
                    im.`item` = i.`id`'
        );
        foreach ($images as $image) {
            $path = date('Y/m/d/His/', strtotime($image['date_add']));
            $file = new File($this->media_dir.$image['source']);
            $file->move($this->media_dir.$path);
            $this->addSql('
                UPDATE
                    `image`
                SET
                    `source` = ?
                WHERE
                    `id` = ?',
                [
                    $path.$file->getBasename(),
                    $image['id'],
                ]
            );
        }

        // skip if no data
        $this->skipIf(!($items && $images), 'No data to migrate');
    }
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)
396101
public function upgradeSchema(Schema $schema)
    {
        $config = $schema->getTable('Config');
        $config->dropPrimaryKey();
        $config->setPrimaryKey(['configNamespace', 'configGroup', 'configItem']);
    }
178084
public function up(Schema $schema)
    {
        // copy images for example items
        $this->fs->mirror($this->source, $this->target);

        // create storage
        $storage = (new Storage())
            ->setDescription('Storage on local computer')
            ->setName('Local')
            ->setPath(Filesystem::getUserHomeDir())
            ->setType(Storage::TYPE_FOLDER);
        $this->em->persist($storage);

        // create items
        $this->persist($this->getItemOnePiece($storage));
        $this->persist($this->getItemFullmetalAlchemist($storage));
        $this->persist($this->getItemSpiritedAway($storage));
        $this->em->flush();
    }
127847
public static <T> void mergeFrom(byte[] data, int offset, int len, T message,
            Schema<T> schema)
    {
        mergeFrom(data, offset, len, message, schema, DEFAULT_INPUT_FACTORY);
    }
500294
NodeSchema join(NodeSchema schema) {
        NodeSchema copy = this.clone();
        for (SchemaColumn column: schema.getColumns()) {
            copy.addColumn(column.clone());
        }
        return copy;
    }