I have checked out Alembic Migrations on Multiple Models but the I way I build my SQLAlchemy models is different.
In src/models/__init__.py
:
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
from .Model1 import Model1
MyMetadata = [Model1.metadata]
In src/models/Model1.py
:
from . import db
class Model1(db.Model):
In migrations/env.py
:
from src.models import MyMetadata
target_metadata = MyMetadata
When I run alembic revision --autogenerate -m "Initial"
, I bump into the following error:
ValueError: Duplicate table keys across multiple MetaData objects: "model1", "model2", "model3"
Any advice and insight is appreciated.