Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 3
0
 def get_all_schema_migrations(self):
     migrations = []
     db = self.__mysql_connect()
     cursor = db.cursor()
     cursor.execute("select id, version, 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 = str(migration_db[1]),
                               file_name = str(migration_db[2]),
                               sql_up = Migration.check_sql_unicode(migration_db[3], self.__mysql_script_encoding),
                               sql_down = Migration.check_sql_unicode(migration_db[4], self.__mysql_script_encoding))
         migrations.append(migration)
     db.close()
     return migrations
Ejemplo n.º 4
0
 def _create_migration(self):
     migrations_dir = self.config.get("database_migrations_dir")
     new_file = Migration.create(
         self.config.get("new_migration", None), migrations_dir[0],
         self.config.get("database_script_encoding", "utf-8"),
         self.config.get("utc_timestamp", False))
     self._execution_log("- Created file '%s'" % (new_file),
                         log_level_limit=1)
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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
Ejemplo n.º 8
0
 def _create_migration(self):
     migrations_dir = self.config.get("migrations_dir")
     new_file = Migration.create(self.config.get("new_migration", None), migrations_dir[0], self.config.get("db_script_encoding", "utf-8"), self.config.get("utc_timestamp", False))
     self._execution_log("- Created file '%s'" % (new_file), log_level_limit=1)
Ejemplo n.º 9
0
 def create_migration(self):
     # TODO: create file in the migrations directory, not in current
     new_file = Migration.create(self.config.get("new_migration"))
     self.cli.msg("- Created file '%s'" % (new_file))
Ejemplo n.º 10
0
 def create_migration(self):
     migrations_dir = self.config.get("migrations_dir")
     new_file = Migration.create(self.config.get("new_migration"), migrations_dir[0], self.config.get("db_script_encoding", "utf-8"))
     self.execution_log("- Created file '%s'" % (new_file), log_level_limit=1)