Permalink
Browse files

Added schematic.

  • Loading branch information...
1 parent eafc1be commit 5527311ed36d1f51c610f3ea53ffc1fc3fc1bea2 @fwenzel fwenzel committed Jan 7, 2011
Showing with 38 additions and 2 deletions.
  1. +1 −1 docs/libs.rst
  2. +5 −0 manage.py
  3. +1 −0 migrations/01-noop.sql
  4. 0 migrations/__init__.py
  5. +30 −0 migrations/schematic_settings.py
  6. +1 −1 vendor
View
@@ -16,7 +16,7 @@ Database
* `django-multidb-router <https://github.com/jbalogh/django-multidb-router>`_:
Round-robin master/slave db router for Django 1.2.
-* `schematic <https://github.com/jbalogh/schematic>`_:
+* `schematic <https://github.com/jbalogh/schematic>`_\*:
Simple database migration tool.
Deferred Execution (cron, message queues)
View
@@ -38,6 +38,11 @@
" Please come back and try again later.")
raise
+# If we want to use django settings anywhere, we need to set up the required
+# environment variables.
+setup_environ(settings)
+
+# Configure Celery
import djcelery
djcelery.setup_loader()
View
@@ -0,0 +1 @@
+-- Example database migration for schematic. Remove this, if you like.
View
No changes.
@@ -0,0 +1,30 @@
+import sys
+import os
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+# Set up playdoh.
+import manage
+from django.conf import settings
+
+config = settings.DATABASES['default']
+config['HOST'] = config.get('HOST', 'localhost')
+config['PORT'] = config.get('PORT', '3306')
+
+if not config['HOST'] or config['HOST'].endswith('.sock'):
+ """Oh, you meant 'localhost'!"""
+ config['HOST'] = 'localhost'
+
+s = 'mysql --silent {NAME} -h{HOST} -u{USER}'
+
+if config['PASSWORD']:
+ s += ' -p{PASSWORD}'
+else:
+ del config['PASSWORD']
+if config['PORT']:
+ s += ' -P{PORT}'
+else:
+ del config['PORT']
+
+db = s.format(**config)
+table = 'schema_version'
2 vendor
Submodule vendor updated 3 files
+3 −0 .gitmodules
+1 −0 src/schematic
+1 −0 vendor.pth

0 comments on commit 5527311

Please sign in to comment.