Parameters:
     - login
     - tableName
     - versioningIter
     - type
770780
def createTable(self, login, tableName, versioningIter, type):
    
    self.send_createTable(login, tableName, versioningIter, type)
    self.recv_createTable()
1065253
def getIteratorSetting(self, login, tableName, iteratorName, scope):
    
    self.send_getIteratorSetting(login, tableName, iteratorName, scope)
    return self.recv_getIteratorSetting()
588593
def checkIteratorConflicts(self, login, tableName, setting, scopes):
    
    self.send_checkIteratorConflicts(login, tableName, setting, scopes)
    self.recv_checkIteratorConflicts()
250476
def set_version(db, name, major_version, minor_version):
    
    version = pack_version(major_version, minor_version)
    db.execute(SET_VERSION_SQL, dict(name=name, version=version))
896292
@Override
    public int getDatabaseMajorVersion() throws SQLException
    {
        checkClosed();
        System.out.println("\n\n\nVERSION: " + versionString);
        return Integer.valueOf(versionString.split("\\.")[0]);
    }
1055448
private boolean checkDatabaseVersion(String databaseName) {
        final Version softwareVersion = this.requiredProductVersions.get(databaseName);
        if (softwareVersion == null) {
            throw new IllegalStateException("No version number is configured for: " + databaseName);
        }

        final Version databaseVersion = this.versionDao.getVersion(databaseName);
        if (databaseVersion == null) {
            throw new IllegalStateException(
                    "No version number is exists in the database for: " + databaseName);
        }

        return softwareVersion.equals(databaseVersion);
    }
1211871
def type_in_db(self, tp, params):
        
        tw = TypeWrapper(tp, params)
        return self.version_db.is_versioned(tw)
715656
def versions(self):
        
        if self._versions is None:
            with self.database.cursor_autocommit() as cursor:
                query = """
                SELECT number,
                       date_start,
                       date_done,
                       log,
                       addons
                FROM {}
                """.format(self.table_name)
                cursor.execute(query)
                rows = cursor.fetchall()
                versions = []
                for row in rows:
                    row = list(row)
                    # convert 'addons' to json
                    row[4] = json.loads(row[4]) if row[4] else []
                    versions.append(
                        self.VersionRecord(*row)
                    )
                self._versions = versions
        return self._versions
741393
def current_db_version(self):
        

        query = """
        SELECT version from {} WHERE success = TRUE ORDER BY version DESC
        """.format(self.upgrades_table)

        self.cursor.execute(query)

        return self.cursor.fetchone()[0]
607152
def getLocalityGroups(self, login, tableName):
    
    self.send_getLocalityGroups(login, tableName)
    return self.recv_getLocalityGroups()
84957
def upgrade():
    """"""
    op.create_table(
        'records_metadata',
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('updated', sa.DateTime(), nullable=False),
        sa.Column(
            'id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
        sa.Column('json', sqlalchemy_utils.JSONType().with_variant(
            sa.dialects.postgresql.JSON(
                none_as_null=True), 'postgresql',
        ), nullable=True),
        sa.Column('version_id', sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_table(
        'records_metadata_version',
        sa.Column('created', sa.DateTime(),
                  autoincrement=False, nullable=True),
        sa.Column('updated', sa.DateTime(),
                  autoincrement=False, nullable=True),
        sa.Column('id', sqlalchemy_utils.types.uuid.UUIDType(),
                  autoincrement=False, nullable=False),
        sa.Column('json', sqlalchemy_utils.JSONType().with_variant(
            sa.dialects.postgresql.JSON(
                none_as_null=True), 'postgresql',
        ), autoincrement=False, nullable=True),
        sa.Column('version_id', sa.Integer(),
                  autoincrement=False, nullable=True),
        sa.Column('transaction_id', sa.BigInteger(),
                  autoincrement=False, nullable=False),
        sa.Column('end_transaction_id',
                  sa.BigInteger(), nullable=True),
        sa.Column('operation_type',
                  sa.SmallInteger(), nullable=False),
        sa.PrimaryKeyConstraint('id', 'transaction_id')
    )
    op.create_index(
        op.f('ix_records_metadata_version_end_transaction_id'),
        'records_metadata_version', ['end_transaction_id'], unique=False
    )
    op.create_index(
        op.f('ix_records_metadata_version_operation_type'),
        'records_metadata_version', ['operation_type'], unique=False
    )
    op.create_index(
        op.f('ix_records_metadata_version_transaction_id'),
        'records_metadata_version', ['transaction_id'], unique=False
    )
484048
protected static function table_version_check()
	{
		// set connection
		static::$connection === null or \DBUtil::set_connection(static::$connection);

		// if table does not exist
		if ( ! \DBUtil::table_exists(static::$table))
		{
			// create table
			\DBUtil::create_table(static::$table, static::$table_definition);
		}

		// check if a table upgrade is needed
		elseif ( ! \DBUtil::field_exists(static::$table, array('migration')))
		{
			// get the current migration status
			$current = \DB::select()->from(static::$table)->order_by('type', 'ASC')->order_by('name', 'ASC')->execute(static::$connection)->as_array();

			// drop the existing table, and recreate it in the new layout
			\DBUtil::drop_table(static::$table);
			\DBUtil::create_table(static::$table, static::$table_definition);

			// check if we had a current migration status
			if ( ! empty($current))
			{
				// do we need to migrate from a v1.0 migration environment?
				if (isset($current[0]['current']))
				{
					// convert the current result into a v1.1. migration environment structure
					$current = array(0 => array('name' => 'default', 'type' => 'app', 'version' => $current[0]['current']));
				}

				// build a new config structure
				$configs = array();

				// convert the v1.1 structure to the v1.2 structure
				foreach ($current as $migration)
				{
					// find the migrations for this entry
					$migrations = static::find_migrations($migration['name'], $migration['type'], null, $migration['version']);

					// array to keep track of the migrations already run
					$config = array();

					// add the individual migrations found
					foreach ($migrations as $file)
					{
						$file = pathinfo($file['path']);

						// add this migration to the table
						\DB::insert(static::$table)->set(array(
							'name' => $migration['name'],
							'type' => $migration['type'],
							'migration' => $file['filename'],
						))->execute(static::$connection);

						// and to the config
						$config[] = $file['filename'];
					}

					// create a config entry for this name and type if needed
					isset($configs[$migration['type']]) or $configs[$migration['type']] = array();
					$configs[$migration['type']][$migration['name']] = $config;
				}

				// write the updated migrations config back
				\Config::set('migrations.version', $configs);
				\Config::save(\Fuel::$env.DS.'migrations', 'migrations');
			}

			// delete any old migration config file that may exist
			is_file(APPPATH.'config'.DS.'migrations.php') and unlink(APPPATH.'config'.DS.'migrations.php');
		}

		// set connection to default
		static::$connection === null or \DBUtil::set_connection(null);
	}
943179
private void ensureSchemaVersion(Connection conn) throws DatabaseException {
        ResultSet rs = null;
        PreparedStatement ps = null;
        try {
            //TODO convert this to use DatabaseProperties
            ps = conn.prepareStatement("SELECT value FROM properties WHERE id = 'version'");
            rs = ps.executeQuery();
            if (rs.next()) {
                final String dbSchemaVersion = settings.getString(Settings.KEYS.DB_VERSION);
                final DependencyVersion appDbVersion = DependencyVersionUtil.parseVersion(dbSchemaVersion);
                if (appDbVersion == null) {
                    throw new DatabaseException("Invalid application database schema");
                }
                final DependencyVersion db = DependencyVersionUtil.parseVersion(rs.getString(1));
                if (db == null) {
                    throw new DatabaseException("Invalid database schema");
                }
                LOGGER.debug("DC Schema: {}", appDbVersion.toString());
                LOGGER.debug("DB Schema: {}", db.toString());
                if (appDbVersion.compareTo(db) > 0) {
                    updateSchema(conn, appDbVersion, db);
                    if (++callDepth < 10) {
                        ensureSchemaVersion(conn);
                    }
                }
            } else {
                throw new DatabaseException("Database schema is missing");
            }
        } catch (SQLException ex) {
            LOGGER.debug("", ex);
            throw new DatabaseException("Unable to check the database schema version", ex);
        } finally {
            DBUtils.closeResultSet(rs);
            DBUtils.closeStatement(ps);
        }
    }
1088341
function (tableName, opts) {
            var m = this.outputIdentifierFunc, im = this.inputIdentifierFunc, self = this;
            return this.metadataDataset.withSql("DESCRIBE ?", sql.identifier(im(tableName))).map(function (row) {
                var ret = {};
                var e = row[m("Extra")];
                var allowNull = row[m("Null")];
                var key = row[m("Key")];
                ret.autoIncrement = e.match(/auto_increment/i) !== null;
                ret.allowNull = allowNull.match(/Yes/i) !== null;
                ret.primaryKey = key.match(/PRI/i) !== null;
                var defaultValue = row[m("Default")];
                ret["default"] = Buffer.isBuffer(defaultValue) ? defaultValue.toString() : defaultValue;
                if (isEmpty(row["default"])) {
                    row["default"] = null;
                }
                ret.dbType = row[m("Type")];
                if (Buffer.isBuffer(ret.dbType)) {
                    //handle case for field type being returned at 252  (i.e. BLOB)
                    ret.dbType = ret.dbType.toString();
                }
                ret.type = self.schemaColumnType(ret.dbType.toString("utf8"));
                var fieldName = m(row[m("Field")]);
                return [fieldName, ret];
            });
        }
1118774
def DBObject(table_name, versioning=VersioningTypes.NONE):
    """"""
    def wrapped(cls):
        field_names = set()
        all_fields = []

        for name in dir(cls):
            fld = getattr(cls, name)
            if fld and isinstance(fld, Field):
                fld.name = name
                all_fields.append(fld)
                field_names.add(name)

        def add_missing_field(name, default='', insert_pos=None):
            if name not in field_names:
                fld = Field(default=default)
                fld.name = name
                all_fields.insert(
                    len(all_fields) if insert_pos is None else insert_pos,
                    fld
                )

        add_missing_field('id', insert_pos=0)
        add_missing_field('_create_date')
        add_missing_field('_last_update')
        if versioning == VersioningTypes.DELTA_HISTORY:
            add_missing_field('_version_hist', default=list)

        # Things we count on as part of our processing
        cls.__table_name__ = table_name
        cls.__versioning__ = versioning
        cls.__fields__ = all_fields

        # Give them a ctor for free - but make sure we aren't clobbering one
        if not ctor_overridable(cls):
            raise TypeError(
                'Classes with user-supplied __init__ should not be decorated '
                'with DBObject. Use the setup method'
            )
        cls.__init__ = _auto_init

        # Duck-type the class for our data methods
        cls.get_table_name = classmethod(_get_table_name)
        cls.get_id = _get_id
        cls.set_id = _set_id
        cls.to_data = _to_data
        cls.from_data = classmethod(_from_data)
        cls.index_names = classmethod(_index_names)
        cls.indexes = _indexes
        # Bonus methods they get for using gludb.simple
        cls.get_version_hist = _get_version_hist

        # Register with our abc since we actually implement all necessary
        # functionality
        Storable.register(cls)

        # And now that we're registered, we can also get the database
        # read/write functionality for free
        cls = DatabaseEnabled(cls)

        if versioning == VersioningTypes.DELTA_HISTORY:
            cls.save = _delta_save(cls.save)

        return cls

    return wrapped
38582
def version(self):
        """"""
        query = "SELECT version FROM %s" % METADATA_TABLE_NAME
        cursor = self.connection.execute(query)
        version = cursor.fetchone()
        if not version:
            return 0
        else:
            return int(version[0])
1110896
def _cachedSqlType(cls):
        
        if not hasattr(cls, "_cached_sql_type"):
            cls._cached_sql_type = cls.sqlType()
        return cls._cached_sql_type