I'm trying to use flask, sqlalchemy, and flask_migrate...
But every time run manage.py migrate, alembic always detect my model as a new table.
I think that I put __table_args__ in my model to store table in a different postgres schema:
class Entry(db.Model):
__table_args__ = {'schema': app.config['BASE_SCH']}
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100))
slug = db.Column(db.String(100), unique=True)
body = db.Column(db.Text)
status = db.Column(db.SmallInteger, default=STATUS_PUBLIC)
created_timestamp = db.Column(db.DateTime, default=datetime.datetime.now)
modified_timestamp = db.Column(db.DateTime, default=datetime.datetime.now,
onupdate=datetime.datetime.now)
If I delete the __table_args__ line of my model, the flask migrate works properly. Storing my table in public postgres schema.
So, how can I use different postgres table schemas with flask?
schema, maybe if you add it manually things will work for you.flask db migratecreates a new migration that's an exact duplicate of the first one, like Alembic is not seeing that the table already exists in the DB.