Fix wrong using of Metadata in 15,16 migrations

In up>down>up mode migrations are failing due to using of common MetaData.
It should be declared separatly for both of migration methods.

Fixes-Bug: #1240898
Change-Id: I8f6555ce44204e79a9c47b7caa1fe05970f4e3f0
This commit is contained in:
Svetlana Shturm 2013-10-18 14:30:45 +04:00
parent e4a1a4fcef
commit 71f1264a8a
2 changed files with 4 additions and 4 deletions

View File

@ -20,10 +20,9 @@ from migrate import ForeignKeyConstraint
from sqlalchemy import MetaData, Table, Column, Index from sqlalchemy import MetaData, Table, Column, Index
from sqlalchemy import String, DateTime from sqlalchemy import String, DateTime
meta = MetaData()
def upgrade(migrate_engine): def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine meta.bind = migrate_engine
project = Table('project', meta, autoload=True) project = Table('project', meta, autoload=True)
@ -68,6 +67,7 @@ def upgrade(migrate_engine):
def downgrade(migrate_engine): def downgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine meta.bind = migrate_engine
alarm_history = Table('alarm_history', meta, autoload=True) alarm_history = Table('alarm_history', meta, autoload=True)
alarm_history.drop() alarm_history.drop()

View File

@ -21,10 +21,9 @@ import json
from sqlalchemy import MetaData, Table, Column, Index from sqlalchemy import MetaData, Table, Column, Index
from sqlalchemy import String, Float, Integer, Text from sqlalchemy import String, Float, Integer, Text
meta = MetaData()
def upgrade(migrate_engine): def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine meta.bind = migrate_engine
table = Table('alarm', meta, autoload=True) table = Table('alarm', meta, autoload=True)
@ -65,6 +64,7 @@ def upgrade(migrate_engine):
def downgrade(migrate_engine): def downgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine meta.bind = migrate_engine
table = Table('alarm', meta, autoload=True) table = Table('alarm', meta, autoload=True)