示例#1
0
    def get_all_schema_migrations(self):
        migrations = []
        conn = self.__connect()
        cursor = conn.cursor()
        cursor.execute(
            "select id, version, label, name, sql_up, sql_down from %s order by id"
            % self.__version_table)
        while True:
            migration_db = cursor.fetchone()
            if migration_db is None:
                break

            migration = Migration(
                id=int(migration_db[0]),
                version=migration_db[1] and str(migration_db[1]) or None,
                label=migration_db[2] and str(migration_db[2]) or None,
                file_name=migration_db[3] and str(migration_db[3]) or None,
                sql_up=Migration.ensure_sql_unicode(
                    migration_db[4] and migration_db[4].read() or None,
                    self.__script_encoding),
                sql_down=Migration.ensure_sql_unicode(
                    migration_db[5] and migration_db[5].read() or None,
                    self.__script_encoding))
            migrations.append(migration)
        cursor.close()
        conn.close()
        return migrations
示例#2
0
 def get_all_schema_migrations(self):
     migrations = []
     db = self.__mssql_connect()
     db.execute_query("select id, version, label, name, cast(sql_up as text) as sql_up, cast(sql_down as text) as sql_down from %s order by id;" % self.__version_table)
     all_migrations = db
     for migration_db in all_migrations:
         migration = Migration(id = int(migration_db['id']),
                               version = migration_db['version'] and str(migration_db['version']) or None,
                               label = migration_db['label'] and str(migration_db['label']) or None,
                               file_name = migration_db['name'] and str(migration_db['name']) or None,
                               sql_up = Migration.ensure_sql_unicode(migration_db['sql_up'], self.__mssql_script_encoding),
                               sql_down = Migration.ensure_sql_unicode(migration_db['sql_down'], self.__mssql_script_encoding))
         migrations.append(migration)
     db.close()
     return migrations
示例#3
0
 def get_all_schema_migrations(self):
     migrations = []
     conn = self.__connect()
     cursor = conn.cursor()
     cursor.execute("select id, version, label, name, sql_up, sql_down from %s order by id" % self.__version_table)
     all_migrations = cursor.fetchall()
     for migration_db in all_migrations:
         migration = Migration(id = int(migration_db[0]),
                               version = migration_db[1] and str(migration_db[1]) or None,
                               label = migration_db[2] and str(migration_db[2]) or None,
                               file_name = migration_db[3] and str(migration_db[3]) or None,
                               sql_up = Migration.ensure_sql_unicode(migration_db[4] and migration_db[4].read() or None, self.__script_encoding),
                               sql_down = Migration.ensure_sql_unicode(migration_db[5] and migration_db[5].read() or None, self.__script_encoding))
         migrations.append(migration)
     cursor.close()
     conn.close()
     return migrations
示例#4
0
 def get_all_schema_migrations(self):
     migrations = []
     db = self.__mysql_connect()
     cursor = db.cursor()
     cursor.execute("select id, version, label, name, sql_up, sql_down from %s order by id;" % self.__version_table)
     all_migrations = cursor.fetchall()
     for migration_db in all_migrations:
         migration = Migration(id = int(migration_db[0]),
                               version = migration_db[1] and str(migration_db[1]) or None,
                               label = migration_db[2] and str(migration_db[2]) or None,
                               file_name = migration_db[3] and str(migration_db[3]) or None,
                               sql_up = Migration.ensure_sql_unicode(migration_db[4], self.__mysql_script_encoding),
                               sql_down = Migration.ensure_sql_unicode(migration_db[5], self.__mysql_script_encoding))
         migrations.append(migration)
     cursor.close()
     db.close()
     return migrations
示例#5
0
 def get_all_schema_migrations(self):
     migrations = []
     db = self.__mssql_connect()
     db.execute_query(
         "select id, version, label, name, cast(sql_up as text) as sql_up, cast(sql_down as text) as sql_down from %s order by id;"
         % self.__version_table)
     all_migrations = db
     for migration_db in all_migrations:
         migration = Migration(
             id=int(migration_db['id']),
             version=migration_db['version']
             and str(migration_db['version']) or None,
             label=migration_db['label'] and str(migration_db['label'])
             or None,
             file_name=migration_db['name'] and str(migration_db['name'])
             or None,
             sql_up=Migration.ensure_sql_unicode(
                 migration_db['sql_up'], self.__mssql_script_encoding),
             sql_down=Migration.ensure_sql_unicode(
                 migration_db['sql_down'], self.__mssql_script_encoding))
         migrations.append(migration)
     db.close()
     return migrations