|
@ -14,6 +14,10 @@ |
|
|
* GNU General Public License for more details. |
|
|
* GNU General Public License for more details. |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
from shutil import copy, move |
|
|
|
|
|
from os.path import exists, join |
|
|
|
|
|
|
|
|
|
|
|
from django.conf import settings |
|
|
from django.db import connection |
|
|
from django.db import connection |
|
|
from django.db.models import signals |
|
|
from django.db.models import signals |
|
|
|
|
|
|
|
@ -22,6 +26,14 @@ from mumble import models |
|
|
from update_schema import update_schema |
|
|
from update_schema import update_schema |
|
|
from server_detect import find_existing_instances |
|
|
from server_detect import find_existing_instances |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if settings.DATABASE_ENGINE == "sqlite3": |
|
|
|
|
|
# Move the DB to the db subdirectory if necessary. |
|
|
|
|
|
oldpath = join( settings.MUMBLE_DJANGO_ROOT, "mumble-django.db3" ) |
|
|
|
|
|
if not exists( settings.DATABASE_NAME ) and exists( oldpath ): |
|
|
|
|
|
move( oldpath, settings.DATABASE_NAME ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cursor = connection.cursor() |
|
|
cursor = connection.cursor() |
|
|
|
|
|
|
|
|
tablename = models.Mumble._meta.db_table |
|
|
tablename = models.Mumble._meta.db_table |
|
@ -38,6 +50,9 @@ else: |
|
|
uptodate = True |
|
|
uptodate = True |
|
|
|
|
|
|
|
|
if not uptodate: |
|
|
if not uptodate: |
|
|
|
|
|
if settings.DATABASE_ENGINE == "sqlite3": |
|
|
|
|
|
# backup the db before the conversion. |
|
|
|
|
|
copy( settings.DATABASE_NAME, settings.DATABASE_NAME+".bak" ) |
|
|
signals.post_syncdb.connect( update_schema, sender=models ); |
|
|
signals.post_syncdb.connect( update_schema, sender=models ); |
|
|
else: |
|
|
else: |
|
|
signals.post_syncdb.connect( find_existing_instances, sender=models ); |
|
|
signals.post_syncdb.connect( find_existing_instances, sender=models ); |
|
|