settings: Prompt for a database login when using South migrations.
[matthijs/projects/dorestad-bookings.git] / southsettings.py
diff --git a/southsettings.py b/southsettings.py
new file mode 100644 (file)
index 0000000..63ff314
--- /dev/null
@@ -0,0 +1,17 @@
+# Database settings for when doing a database migration using south,
+# which requires more privileges.
+
+import sys
+if 'manage.py' in sys.argv[0] and sys.argv[1] == 'migrate':
+    import south
+
+    try:
+        # We cache the prompted values in the south module, since the
+        # settings module gets loaded multiple times...
+        DATABASE_USER = south.cached_db_user
+        DATABASE_PASSWORD = south.cached_db_pw
+    except AttributeError:
+        DATABASE_USER = raw_input("Privileged database user: ")
+        DATABASE_PASSWORD = raw_input("Database password for %s: " % DATABASE_USER)
+        south.cached_db_user = DATABASE_USER
+        south.cached_db_pw = DATABASE_PASSWORD