Browse files

Merge branch 'release/0.3.9'

  • Loading branch information...
2 parents b4f7a6d + 88b3d0a commit 00c4dd0379dbaab3d9cbe1983f5f45deba4907fa @klen committed Aug 24, 2012
Showing with 70 additions and 6 deletions.
  1. +1 −0 Changelog
  2. +1 −1 base/config/develop.py
  3. +1 −0 base/config/test.py
  4. +17 −5 manage.py
  5. 0 alembic.ini → migrate/develop.ini
  6. +50 −0 migrate/production.ini
View
1 Changelog
@@ -2,6 +2,7 @@
* Add 'before_new', 'before_delete' model methods support
* Add FlaskMail log handler for production
+ * Load migrations by app config
2012-08-19 klen
View
2 base/config/develop.py
@@ -6,5 +6,5 @@
DEBUG = True
SQLALCHEMY_ECHO = True
+
# pymode:lint_ignore=W0614,W404
-# flake8: noqa
View
1 base/config/test.py
@@ -10,4 +10,5 @@
AUTH_USER_MIXINS += ['base.auth.tests.TestUserMixin']
+
# pymode:lint_ignore=W0614,W404
View
22 manage.py
@@ -12,15 +12,27 @@
@manager.shell
def make_shell_context():
" Update shell. "
+
from flask import current_app
return dict(app=current_app, db=db)
@manager.command
def migrate():
- " Migration utils. "
+ " Alembic migration utils. "
+
+ from flask import current_app
from alembic.config import main
- main(filter(lambda a: a != '-c' and not a.startswith('base.config.'), ARGV))
+
+ global ARGV
+
+ config = 'production.ini'
+ if current_app.debug:
+ config = 'develop.ini'
+
+ ARGV = ['-c', 'migrate/%s' % config] + ARGV
+
+ main(ARGV)
@manager.command
@@ -43,9 +55,9 @@ def test():
if __name__ == '__main__':
argv = sys.argv[1:]
if argv and argv[0] == 'migrate':
- ARGV = list(argv[1:])
- sys.argv[0] += ' migrate'
- sys.argv = sys.argv[:2]
+ ARGV = filter(lambda a: not a in ('-c', 'migrate') and not a.startswith('base.config.'), argv)
+ argv = filter(lambda a: not a in ARGV, argv)
+ sys.argv = [sys.argv[0]] + argv
manager.run()
View
0 alembic.ini → migrate/develop.ini
File renamed without changes.
View
50 migrate/production.ini
@@ -0,0 +1,50 @@
+# A generic, single database configuration.
+
+[alembic]
+# path to migration scripts
+script_location = migrate
+
+# template used to generate migration files
+# file_template = %%(rev)s_%%(slug)s
+
+# set to 'true' to run the environment during
+# the 'revision' command, regardless of autogenerate
+# revision_environment = false
+
+sqlalchemy.url = sqlite:///.db
+
+
+# Logging configuration
+[loggers]
+keys = root,sqlalchemy,alembic
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = WARN
+handlers = console
+qualname =
+
+[logger_sqlalchemy]
+level = WARN
+handlers =
+qualname = sqlalchemy.engine
+
+[logger_alembic]
+level = INFO
+handlers =
+qualname = alembic
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(levelname)-5.5s [%(name)s] %(message)s
+datefmt = %H:%M:%S

0 comments on commit 00c4dd0

Please sign in to comment.