|
@ -26,7 +26,15 @@ from mumble.management.server_detect import find_existing_instances |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_schema( **kwargs ): |
|
|
def update_schema( **kwargs ): |
|
|
scriptpath = join( |
|
|
|
|
|
|
|
|
if "verbosity" in kwargs: |
|
|
|
|
|
v = kwargs['verbosity']; |
|
|
|
|
|
else: |
|
|
|
|
|
v = 1; |
|
|
|
|
|
|
|
|
|
|
|
if v: |
|
|
|
|
|
print "Migrating Database schema for Mumble-Django 2.0 now." |
|
|
|
|
|
|
|
|
|
|
|
scriptdir = join( |
|
|
settings.MUMBLE_DJANGO_ROOT, "pyweb", "mumble", "conversionsql", { |
|
|
settings.MUMBLE_DJANGO_ROOT, "pyweb", "mumble", "conversionsql", { |
|
|
'postgresql_psycopg2': 'pgsql', |
|
|
'postgresql_psycopg2': 'pgsql', |
|
|
'postgresql': 'pgsql', |
|
|
'postgresql': 'pgsql', |
|
@ -35,14 +43,20 @@ def update_schema( **kwargs ): |
|
|
}[settings.DATABASE_ENGINE] |
|
|
}[settings.DATABASE_ENGINE] |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
scripts = [ filename for filename in os.listdir( scriptpath ) if filename.endswith( ".sql" ) ] |
|
|
|
|
|
|
|
|
if v > 1: |
|
|
|
|
|
print "Reading migration scripts for %s from '%s'" % ( settings.DATABASE_ENGINE, scriptdir ) |
|
|
|
|
|
|
|
|
|
|
|
scripts = [ filename for filename in os.listdir( scriptdir ) if filename.endswith( ".sql" ) ] |
|
|
scripts.sort() |
|
|
scripts.sort() |
|
|
|
|
|
|
|
|
for filename in scripts: |
|
|
for filename in scripts: |
|
|
cursor = connection.cursor() |
|
|
cursor = connection.cursor() |
|
|
|
|
|
|
|
|
scriptfile = open( os.path.join( scriptpath, filename ), "r" ) |
|
|
|
|
|
|
|
|
scriptpath = os.path.join( scriptdir, filename ) |
|
|
|
|
|
scriptfile = open( scriptpath, "r" ) |
|
|
try: |
|
|
try: |
|
|
|
|
|
if v > 1: |
|
|
|
|
|
print "Running migration script '%s'..." % scriptpath |
|
|
stmt = scriptfile.read() |
|
|
stmt = scriptfile.read() |
|
|
cursor.execute( stmt ) |
|
|
cursor.execute( stmt ) |
|
|
|
|
|
|
|
@ -58,4 +72,7 @@ def update_schema( **kwargs ): |
|
|
scriptfile.close() |
|
|
scriptfile.close() |
|
|
cursor.close() |
|
|
cursor.close() |
|
|
|
|
|
|
|
|
|
|
|
if v: |
|
|
|
|
|
print "Database migration finished successfully." |
|
|
|
|
|
|
|
|
find_existing_instances( **kwargs ) |
|
|
find_existing_instances( **kwargs ) |