I'm making second revision of changing the table structure adding new tables and columns, but flask sqlalchemy on migrate is creating all the tables again.
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.autogenerate.compare] Detected added table 'old_table'
INFO [alembic.autogenerate.compare] Detected added table 'new_table'
expected behavior was old table should not be added again.. init.py
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
db = SQLAlchemy()
migrate = Migrate()
def creat_app():
...
db.init_app(app)
migrate.init_app(app, db)
models.py
from package_name import db
class MetaFields(db.Model):
__abstract__ = True
created = db.Column(db.DateTime)
class Model1(MetaFields):
__tablename__ = "new_table"
__table_args__ = {"schema": "schema_name"}
Got the migration working on flask db migrate to generate proper alembic patch on model changes.
Added below code in alembic env.py script:
And updated
include_schemas
andinclude_object
in the configuration script: