Migrate legacy "_tenant" row, if it exists to the Tenants table.
764800
private void migrateTenantDefinition(String keyspace) {
        TenantDefinition tempTenantDef = new TenantDefinition();
        tempTenantDef.setName(keyspace);
        Tenant migratingTenant = new Tenant(tempTenantDef);
        DColumn col = DBService.instance(migratingTenant).getColumn("Applications", "_tenant", "Definition");
        if (col == null) {
            return;
        }
        m_logger.info("Migrating tenant definition from keyspace {}", keyspace);
        TenantDefinition migratingTenantDef = new TenantDefinition();
        try {
            migratingTenantDef.parse(UNode.parseJSON(col.getValue()));
        } catch (Exception e) {
            m_logger.warn("Couldn't parse tenant definition; skipping migration of keyspace: " + keyspace, e);
            return;
        }
        storeTenantDefinition(migratingTenantDef);
        DBTransaction dbTran = new DBTransaction(migratingTenant);
        dbTran.deleteRow("Applications", "_tenant");
        DBService.instance(migratingTenant).commit(dbTran);
    }
125842
protected function migrate()
    {
        if (! $this->container['migrator']->repositoryExists()) {
            throw new Exception('Migration table not found.');
        }

        $this->container['migrator']->run($this->getAttribute('path').'/database/migrations');
    }
1243145
def _rebuild_table(self, new_name, old_name, new_columns, old_columns): 
        
        '''  '''
    
    # verbosity
        print('Rebuilding %s table in %s database' % (self.table_name, self.database_name), end='', flush=True)
        
        from sqlalchemy import Table, MetaData
        metadata_object = MetaData()
    
    # construct old table
        old_table_args = [ old_name, metadata_object ]
        old_column_args = self._construct_columns(old_columns)
        old_table_args.extend(old_column_args)
        old_table = Table(*old_table_args)
    
    # construct new table
        new_table_args = [ new_name, metadata_object ]
        new_column_args = self._construct_columns(new_columns)
        new_table_args.extend(new_column_args)
        new_table = Table(*new_table_args)
    
    # determine differences between tables
        add_columns, remove_columns, rename_columns, retype_columns, resize_columns = self._compare_columns(new_columns, old_columns)
        
    # rename table and recreate table if it doesn't already exist
        table_list = self.engine.table_names()
        if not old_name in table_list:
            self.engine.execute('ALTER TABLE %s RENAME TO %s' % (new_name, old_name))
            new_table.create(self.engine)
     
    # wait for renamed table to be responsive
                
    # migrate records from old to new
        list_statement = old_table.select()
        count = 0
        for record in self.session.execute(list_statement).fetchall():
            create_kwargs = self._construct_inserts(record, new_columns, rename_columns, retype_columns, resize_columns)
            insert_statement = new_table.insert().values(**create_kwargs)
            self.session.execute(insert_statement)
            delete_statement = old_table.delete(old_table.c.id==record.id)
            self.session.execute(delete_statement)
            if not count % 10:
                print('.', end='', flush=True)
            count += 1
        
    # drop old table
        record_list = self.session.execute(list_statement).first()
        if not record_list:
            self.session.close()
            old_table.drop(self.engine)
            self.session = self.engine.connect()
    
    # handle verbosity   
        print(' done.')
        
        return True
1030018
def migrate_keys(self, host, port, keys, dest_db, timeout, *,
                     copy=False, replace=False):
        
        if not isinstance(host, str):
            raise TypeError("host argument must be str")
        if not isinstance(timeout, int):
            raise TypeError("timeout argument must be int")
        if not isinstance(dest_db, int):
            raise TypeError("dest_db argument must be int")
        if not isinstance(keys, (list, tuple)):
            raise TypeError("keys argument must be list or tuple")
        if not host:
            raise ValueError("Got empty host")
        if dest_db < 0:
            raise ValueError("dest_db must be greater equal 0")
        if timeout < 0:
            raise ValueError("timeout must be greater equal 0")
        if not keys:
            raise ValueError("keys must not be empty")

        flags = []
        if copy:
            flags.append(b'COPY')
        if replace:
            flags.append(b'REPLACE')
        flags.append(b'KEYS')
        flags.extend(keys)
        fut = self.execute(b'MIGRATE', host, port,
                           "", dest_db, timeout, *flags)
        return wait_ok(fut)
1078562
public function migrateDown()
    {
        Schema::table('tddd_runs', function (Blueprint $table) {
            $table->dropColumn('screenshots');
            $table->text('png')->nullable();
        });
    }
674793
def _migrate_db_pre010(self, dbname, newslab):
        '''
        
        '''
        donekey = f'migrdone:{dbname}'

        if self.metadict.get(donekey, False):
            return

        if not self.layrslab.dbexists(dbname):
            self.metadict.set(donekey, True)
            return False

        oldslab = self.layrslab
        olddb = oldslab.initdb(dbname)

        entries = oldslab.stat(olddb)['entries']
        if not entries:
            self.metadict.set(donekey, True)
            return False

        if newslab.dbexists(dbname):
            logger.warning('Incomplete migration detected.  Dropping new splices to restart.')
            newslab.dropdb(dbname)
            logger.info('New splice dropping complete.')

        logger.info('Pre-010 %s migration starting.  Total rows: %d...', dbname, entries)

        def progfunc(count):
            logger.info('Progress %d/%d (%2.2f%%)', count, entries, count / entries * 100)

        oldslab.copydb(olddb, newslab, destdbname=dbname, progresscb=progfunc)
        logger.info('Pre-010 %s migration copying done.  Deleting from old location...', dbname)
        oldslab.dropdb(dbname)
        logger.info('Pre-010 %s migration completed.', dbname)

        self.metadict.set(donekey, True)

        return True
342660
def migrate(record, dry_run=False):
    ''''''
    handler = record_migration if record else execute_migration
    success = True
    for plugin, package, filename in available_migrations():
        migration = get_migration(plugin, filename)
        if migration or not success:
            log_status(plugin, filename, cyan('Skipped'))
        else:
            status = magenta('Recorded') if record else yellow('Apply')
            log_status(plugin, filename, status)
            script = resource_string(package, join('migrations', filename))
            success &= handler(plugin, filename, script, dryrun=dry_run)
130952
public String migrate(String host, int port, Object key, int destinationDb, int timeout) {
		Jedis jedis = getJedis();
		try {
			return jedis.migrate(valueToBytes(host), port, keyToBytes(key), destinationDb, timeout);
		}
		finally {close(jedis);}
	}
154268
def _migrate_single(self, conn, migration):
        """"""
        with contextlib.ExitStack() as stack:
            for wrapper in self._wrappers:
                stack.enter_context(wrapper(conn))
            migration.func(conn)
432128
public function migrateDown()
    {
        Schema::table('tddd_runs', function (Blueprint $table) {
            $table->dropColumn('started_at');

            $table->dropColumn('ended_at');

            $table->dropColumn('notified_at');
        });
    }
801588
def migration(resource, version, previous_version=''):
    """"""
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            migrated = func(*args, **kwargs)

            return migrated

        m = Migration(wrapper, resource, version, previous_version)
        m.register()

        return m

    return decorator
495114
def _migration_required(connection):
    
    stored_version = get_stored_version(connection)
    actual_version = SCHEMA_VERSION
    assert isinstance(stored_version, int)
    assert isinstance(actual_version, int)
    assert stored_version <= actual_version, \
        'Db version can not be greater than models version. Update your source code.'
    return stored_version < actual_version
1091274
public function up()
    {
        // CAUTION: only works and tested on MySQL
        // Legacy support, default type MyISAM doesn't support foreign key
        // Convert table to InnoDB
        if (Schema::hasTable('products')) {
            DB::statement('ALTER TABLE products ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('categories')) {
            DB::statement('ALTER TABLE categories ENGINE = InnoDB');
        }

        if (Schema::hasTable('pricelists')) {
            DB::statement('ALTER TABLE pricelists ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('medias')) {
            DB::statement('ALTER TABLE medias ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('modules')) {
            DB::statement('ALTER TABLE modules ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('memberships')) {
            DB::statement('ALTER TABLE memberships ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('coupons')) {
            DB::statement('ALTER TABLE coupons ENGINE = InnoDB');
        }
    }
1335057
public function migrateUp()
    {
        $this->builder->create(
            $this->table,
            function ($table) {
                $table->bigIncrements('id');

                $table->string('sha1', 40)->index();
                $table->text('statement');
                $table->double('time')->index();
                $table->integer('connection_id')->unsigned();

                $table->timestamps();
                $table->index('created_at');
                $table->index('updated_at');
            }
        );
    }
530522
def migrate(self, conn):
        
        while self.should_migrate(conn):
            current_version = get_user_version(conn)
            migration = self._get_migration(current_version)
            assert migration.from_ver == current_version
            logger.info(f'Migrating database from {migration.from_ver}'
                        f' to {migration.to_ver}')
            self._migrate_single(conn, migration)
            set_user_version(conn, migration.to_ver)
            logger.info(f'Migrated database to {migration.to_ver}')
1031140
public function migrateUp()
    {
        Schema::create('tddd_runs', function (Blueprint $table) {
            $table->increments('id');

            $table->integer('test_id')->unsigned();

            $table->boolean('was_ok');

            $table->mediumText('log');

            $table->text('html')->nullable();

            $table->text('png')->nullable();

            $table->timestamps();
        });

        Schema::table('tddd_runs', function (Blueprint $table) {
            $table->foreign('test_id')
                ->references('id')
                ->on('tddd_tests')
                ->onDelete('cascade')
                ->onUpdate('cascade');
        });
    }
863082
public function migrate()
	{
		$this->msg( 'Adding indexes from "fos_user"', 0 ); $this->status( '' );

		$schema = $this->getSchema( 'db-customer' );

		foreach( $this->list as $idx => $stmt )
		{
			$this->msg( sprintf( 'Checking index "%1$s"', $idx ), 0 );

			if( $schema->tableExists( 'fos_user' ) === true
				&& $schema->indexExists( 'fos_user', $idx ) === false )
			{
				$this->execute( $stmt );
				$this->status( 'done' );
			}
			else
			{
				$this->status( 'OK' );
			}
		}
	}