Fix #5391 - Alembic migrations would only work for SQLite
authorJessica Tallon <tsyesika@tsyesika.se>
Mon, 18 Jan 2016 09:39:34 +0000 (09:39 +0000)
committerJessica Tallon <tsyesika@tsyesika.se>
Mon, 18 Jan 2016 09:39:34 +0000 (09:39 +0000)
The database connection was being set in a alembic.ini config file, if the user
had specified postgres the "sqlite" connection URL in alembic.ini would override
that. We probably should look into this more so i've opened #5395.

alembic.ini
mediagoblin/db/migration_tools.py

index 2fa080996dd1276b4280e9215adc79147735006f..7ae94f9fd01e999b01f2c6571cd68f7d6da3f385 100644 (file)
@@ -20,9 +20,6 @@ script_location = %(here)s/mediagoblin/db/migrations
 # versions/ directory
 # sourceless = false
 
-sqlalchemy.url = sqlite:///mediagoblin.db
-
-
 # Logging configuration
 [loggers]
 keys = root,sqlalchemy,alembic
index 756c109306aa5ee2da638306fd38549a59cbe164..e34685f589642b3f128528f908bb84d21580c265 100644 (file)
@@ -42,6 +42,7 @@ class AlembicMigrationManager(object):
             os.path.dirname(__file__))))
         alembic_cfg_path = os.path.join(root_dir, 'alembic.ini')
         self.alembic_cfg = Config(alembic_cfg_path)
+        self.alembic_cfg.set_main_option("sqlalchemy.url", str(session.get_bind().url))
         self.session = session
 
     def get_current_revision(self):