Runs `./manage.py syncdb --migrate` on the given server.

    Usage::

        fab <server> run_syncdb
508305
def run_syncdb():
    
    with cd(settings.FAB_SETTING('SERVER_PROJECT_ROOT')):
        if StrictVersion(django.get_version()) < StrictVersion('1.7'):
            run_workon('python{} manage.py syncdb --migrate --noinput'.format(
                PYTHON_VERSION))
        else:
            run_workon('python{} manage.py migrate'.format(PYTHON_VERSION))
1026772
def exec_migrations(is_up=true)
      Log.info("Executing migrations...")
      migrations = yield @db.current_version

      if migrations.count == 0
        Log.warn("Migrations not found")
        return
      end

      migrations.each do |migration|
        self.exec_migration(migration, is_up)
      end
      Log.success("Migrations executed. Current version: #{@db.current_version}")
    end
838462
def sync_db():
    
    with cd('/'.join([deployment_root(),'env',env.project_fullname,'project',env.project_package_name,'sitesettings'])):
        venv = '/'.join([deployment_root(),'env',env.project_fullname,'bin','activate'])
        sites = _get_django_sites()
        site_ids = sites.keys()
        site_ids.sort()
        for site in site_ids:
            for settings_file in _sitesettings_files():
                site_settings = '.'.join([env.project_package_name,'sitesettings',settings_file.replace('.py','')])
                if env.verbosity:
                    print " * django-admin.py syncdb --noinput --settings=%s"% site_settings
                output = sudo(' '.join(['source',venv,'&&',"django-admin.py syncdb --noinput --settings=%s"% site_settings]),
                              user='site_%s'% site)
                if env.verbosity:
                    print output
227957
def execute(self, conn, migration_url="", migration_input="", create_by="", migration_request_id="", oldest= False, transaction=False):
        
        sql = self.sql
        binds = {}
	if migration_request_id:
	    sql += " WHERE MR.MIGRATION_REQUEST_ID=:migration_request_id"
	    binds['migration_request_id']=migration_request_id
        elif oldest:
            #FIXME: Need to write the sql.YG
            #current_date = dbsUtils().getTime()
            #we require waiting time for 
            #retry_count=0 is 1 minutes
            #retry_count=1 is 2 minutes
            #retyr_count=2 is 4 minutes

            sql += """
                       WHERE MR.MIGRATION_STATUS=0 
                       or (MR.migration_status=3 and MR.retry_count=0 and MR.last_modification_date <= :current_date-60)    
                       or (MR.migration_status=3 and MR.retry_count=1 and MR.last_modification_date <= :current_date-120)  
                       or (MR.migration_status=3 and MR.retry_count=2 and MR.last_modification_date <= :current_date-240)
                       ORDER BY MR.creation_date
                   """ 
            binds['current_date'] = dbsUtils().getTime()
            #print "time= " + str(binds['current_date'])
        else:    
	    if  migration_url or migration_input or create_by:
		sql += " WHERE "
	    if migration_url:
		sql += " MR.MIGRATION_URL=:migration_url"
		binds['migration_url']=migration_url
	    if  migration_input:
		if migration_url:
		    sql += " AND "
		op = ("=", "like")["%" in migration_input]
		sql += " MR.MIGRATION_INPUT %s :migration_input" % op
		binds['migration_input']=migration_input
	    if create_by:
		if  migration_url or migration_input:
		    sql += " AND "
		sql += " MR.CREATE_BY=:create_by" %create_by
		binds['create_by']=create_by
	cursors = self.dbi.processData(sql, binds, conn, transaction, returnCursor=True)
        result = []
        for c in cursors:
            result.extend(self.formatCursor(c, size=100))
        return result
858429
def run(*migration_classes)
      opts = migration_classes.extract_options!
      dir = opts[:direction] || :up
      dir = (dir == :down ? :up : :down) if opts[:revert]
      if reverting?
        # If in revert and going :up, say, we want to execute :down without reverting, so
        revert { run(*migration_classes, direction: dir, revert: true) }
      else
        migration_classes.each do |migration_class|
          migration_class.new.exec_migration(connection, dir)
        end
      end
    end
1263
def run_migration(data, version_start, version_end):
    """"""
    items = []
    if version_start == 1 and version_end == 2:
        for item in data['accounts']:
            items.append(v2.upgrade(item))

    if version_start == 2 and version_end == 1:
        for item in data:
            items.append(v2.downgrade(item))
        items = {'accounts': items}
    return items
985684
def migrate(directory, message, sql, head, splice, branch_label, version_path,
            rev_id, x_arg):
    """"""
    _migrate(directory, message, sql, head, splice, branch_label, version_path,
             rev_id, x_arg)
679184
def run_migrations_online():
    
    alembic_config = config.get_section(config.config_ini_section)
    alembic_config['sqlalchemy.url'] = os.environ['DATABASE_URI']

    connectable = engine_from_config(
        alembic_config,
        prefix='sqlalchemy.',
        poolclass=pool.NullPool)

    with connectable.connect() as connection:
        context.configure(
            connection=connection,
            target_metadata=target_metadata
        )

        with context.begin_transaction():
            context.run_migrations()
1039618
def run_online_migration(self):
    
    connectable = self.graph.postgres

    with connectable.connect() as connection:
        context.configure(
            connection=connection,
            # assumes that all models extend our base
            target_metadata=Model.metadata,
            **get_alembic_environment_options(self.graph),
        )

        with context.begin_transaction():
            context.run_migrations()
1269854
def _upgrade_db(self):
        """"""
        migration_path = "_data/migrations"
        sqlite3.connect(self._db_path).close()    # ensure that it exists
        db_url = "sqlite:///" + self._db_path
        backend = yoyo.get_backend(db_url)
        migration_dir = pkg_resources.resource_filename(__package__, migration_path)
        migrations = yoyo.read_migrations(migration_dir)
        assert len(migrations) > 0, "no migration scripts found -- wrong migraion path for " + __package__
        migrations_to_apply = backend.to_apply(migrations)
        backend.apply_migrations(migrations_to_apply)
725063
def run_migrations_online():
    

    # this callback is used to prevent an auto-migration from being generated
    # when there are no changes to the schema
    # reference: https://alembic.sqlalchemy.org/en/latest/cookbook.html
    def process_revision_directives(context, revision, directives):
        if getattr(config.cmd_opts, 'autogenerate', False):
            script = directives[0]
            if script.upgrade_ops.is_empty():
                directives[:] = []
                logger.info('No changes in schema detected.')

    engine = engine_from_config(config.get_section(config.config_ini_section),
                                prefix='sqlalchemy.',
                                poolclass=pool.NullPool)

    connection = engine.connect()
    kwargs = {}
    if engine.name in ('sqlite', 'mysql'):
        kwargs = {
            'transaction_per_migration': True,
            'transactional_ddl': True,
        }
    configure_args = current_app.extensions['migrate'].configure_args
    if configure_args:
        kwargs.update(configure_args)

    context.configure(connection=connection,
                      target_metadata=target_metadata,
                      # compare_type=True,
                      process_revision_directives=process_revision_directives,
                      **kwargs)

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
1356141
def migrate(engine, database, module, **kwargs):
    '''
    
    '''
    validate_args(engine, database, module)

    options = {
        'direction': kwargs.get('direction', 'up'),
        'fake': kwargs.get('fake', False),
        'force': kwargs.get('force', False),
        'migration': kwargs.get('migration', None),
        'transaction': kwargs.get('transaction', True),
    }

    Migration._meta.database = database
    migrator = DATABASE_MAP[engine](database, module, **options)
    migrator.run()
154371
function runMigrations(db, currentVersion) {
  return new Promise((resolve, reject) => {
    const nextVersion = currentVersion + 1;

    if (!migrations[nextVersion]) {
      return resolve();
    }

    if (debug) {
      console.log('Migrating schema to v%d', nextVersion);
    }
    migrations[nextVersion](db)
      .then(() => {
        // write new schemaVersion file
        const json = JSON.stringify({ schemaVersion: nextVersion });
        fs.writeFile(schemaVersionFilePath, json, err => {
          if (err) {
            return reject(err);
          }
          resolve(runMigrations(db, nextVersion));
        });
      })
      .catch(reject);
  });
}
586297
def run(self, app):
        """"""
        GlimLog.info('Glim server started on %s environment' % self.args.env)
        try:
            kwargs = Config.get('app.server.options')
            run(app.wsgi,
                host=Config.get('app.server.host'),
                port=Config.get('app.server.port'),
                debug=Config.get('app.server.debugger'),
                reloader=Config.get('app.server.reloader'),
                server=Config.get('app.server.wsgi'),
                **kwargs)
        except Exception as e:
            print(traceback.format_exc())
            exit()
1238716
def migrations_to_run(self):
        
        assert self.database_current_migration is not None

        db_current_migration = self.database_current_migration

        return [
            (migration_number, migration_func)
            for migration_number, migration_func in self.sorted_migrations
            if migration_number > db_current_migration]
290375
def migrate(self) -> None:
        

        assert self.ormSessionCreator, "ormSessionCreator is not defined"

        connection = self._dbEngine.connect()
        isDbInitialised = self._dbEngine.dialect.has_table(
            connection, 'alembic_version',
            schema=self._metadata.schema)
        connection.close()

        if isDbInitialised or not self._enableCreateAll:
            self._doMigration(self._dbEngine)

        else:
            self._doCreateAll(self._dbEngine)

        if self._enableForeignKeys:
            self.checkForeignKeys(self._dbEngine)
362039
def initdb():
    

    print("Syncing up database...")
    cwd_to_sys_path()
    if db and hasattr(db, "Model"):
        db.create_all()
        for m in db.Model.__subclasses__():
            if hasattr(m, "initialize__"):
                print("Sync up model: %s ..." % m.__name__)
                getattr(m, "initialize__")()

    print("Done")