mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 21:30:39 +00:00
Improve the sqlite-to-mysql scripts
This commit is contained in:
@@ -12,7 +12,12 @@ try:
|
||||
dbuser = os.environ['DBUSER']
|
||||
dbpasswd = os.environ['DBPASSWD']
|
||||
except:
|
||||
print 'Environment not set! Exit'
|
||||
sys.stderr.write('Environment not set! Exit\n')
|
||||
sys.exit(1)
|
||||
|
||||
def check_settings():
|
||||
if settings.DATABASE_ENGINE == 'mysql':
|
||||
sys.stderr.write('[ERROR] Current settings is mysql, need sqlite settings\n')
|
||||
sys.exit(1)
|
||||
|
||||
def do_create():
|
||||
@@ -41,6 +46,9 @@ def do_delete(prefix):
|
||||
pass
|
||||
|
||||
if __name__=="__main__":
|
||||
# check current settings.py
|
||||
check_settings()
|
||||
|
||||
# create database if not exists
|
||||
do_create()
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Before run the script, you should have created seafile-meta
|
||||
# database.
|
||||
# Before run the script, edit PYTHONPATH and database configuration
|
||||
# Choose NO when promote to create superuser.
|
||||
|
||||
# The python path. Change to your path
|
||||
@@ -12,21 +11,19 @@ export DBNAME='seahub-meta'
|
||||
export DBUSER='seafile-user'
|
||||
export DBPASSWD='seafile'
|
||||
|
||||
# Save sqlite settings
|
||||
cp settings.py setting.py.sqlite
|
||||
|
||||
# Delete the exist seahub tables in database
|
||||
python batch-delete.py
|
||||
if [ $? -eq 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#DUMP_FILE='dump_seahub.json'
|
||||
# Save sqlite settings
|
||||
cp settings.py settings.py.sqlite
|
||||
|
||||
DUMP_FILE='dump_seahub.xml'
|
||||
SETTINGS_COPY='mysqlsettings.py'
|
||||
SETTINGS_MODULE='mysqlsettings'
|
||||
|
||||
|
||||
cp settings.py $SETTINGS_COPY
|
||||
sed -i "/DATABASE_ENGINE/c\DATABASE_ENGINE = 'mysql'" $SETTINGS_COPY
|
||||
sed -i "/DATABASE_NAME/c\DATABASE_NAME = '$DBNAME'" $SETTINGS_COPY
|
||||
|
Reference in New Issue
Block a user