Doesn't create ForeignKey for inherited models
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
sqlalchemy-migrate |
New
|
Undecided
|
Unassigned |
Bug Description
I use Flask-SQLAlchemy. If models A, B inherited from model C by ForeignKey. Then migrate creates ForeignKey only for first model (A or B) and not creates ForeignKey for another model. It should create ForeignKeys for both models A and B. These are some snippets of my code:
`class Party(db.Model, UserMixin):
id = db.Column(
...
class PartyNonAdmin(
id = db.Column(
...
class PartyNonAdmin2(
id = db.Column(
...
`
So classes PartyNonAdmin and PartyNonAdmin2 inherited from Party by ForeignKey. But when I launch db_migrate.py the ForeignKey created only for PartyNonAdmin table (the first of two tables PartyNonAdmin and PartyNonAdmin2).
I use the following db_migrate.py script:
`#!flask/bin/python
import imp
from migrate.versioning import api
from app import db
from config import SQLALCHEMY_
from config import SQLALCHEMY_
migration = SQLALCHEMY_
api.db_
tmp_module = imp.new_
old_model = api.create_
exec old_model in tmp_module.dict
script = api.make_
db.metadata)
open(migration, "wt").write(script)
api.upgrade(
print 'New migration saved as ' + migration
print 'Current database version: ' + str(api.