P.S. I tried this:
def upgrade(): ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table("incomes") as batch_op: batch_op.add_column(sa.Column('income_classtype', sa.Integer(), nullable=True)) batch_op.create_foreign_key(None, 'incomes', 'classtype', ['income_classtype'], ['id']) ### end Alembic commands ### but it gives an error for create_foreign keys, saying there are too many arguments passed. But I can't find in the doc what parameters I should pass to it. On Tuesday, 26 May 2015 09:47:03 UTC-4, Sylvain Martel wrote: > > Hi, > > Not knowing much about SQL stuff, I used Flask-Migrate, which use > alembic, to deal with migrations. But now I have to deal with a migration > where I can't simply destroy the SQLite database and remake it.(which is > how I dealt so far when an ALTER constraint message popped up) > > So I read the doc on batch mode for SQLite, but I admit it makes no sense > to me. How can I take this line in the migration script > op.create_foreign_key(None, 'incomes', 'classtype', ['income_classtype'], > ['id']) > > and transform it to use batch mode so it works with SQLite? > > Basically, I'm adding a column to 2 tables with a one-to-one > relationship. Here are the models in case it helps. The new columns are > the last line in both models. > > class Income(db.Model): > __tablename__='incomes' > id = db.Column(db.Integer, primary_key=True) > date = db.Column(db.DateTime) > amount = db.Column(Numeric) > user_ = db.Column(db.Integer, db.ForeignKey('users.id')) > income_classtype = db.Column(db.Integer,db.ForeignKey('classtype.id')) > > class ClassType(db.Model): > __tablename__ = 'classtype' > id = db.Column(db.Integer, primary_key=True) > name = db.Column(db.String(64), unique=True) > default = db.Column(db.Boolean, default=False, index=True) > class_ = db.relationship('Classes', backref='classtype', lazy='dynamic') > punchcard_type = db.relationship('Punchcard', backref='classtype', > lazy='dynamic') > seasonpass_type = db.relationship('SeasonPass', backref='classtype', > lazy='dynamic') > income_type = db.relationship('Income',backref='classtype', lazy > ='dynamic') > > > > Thanks > -- You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.