folder_a / models.py
class Category(db.Model):
__tablename__ = "category_a"
id = db.Column(db.Integer, primary_key=True)
parent_id = db.Column(db.Integer(), db.ForeignKey('category_a.id'))
parent = db.relationship('Category',
primaryjoin='Category.parent_id == Category.id',
remote_side=id, backref=db.backref('children'))
folder_b / models.py
class Category(db.Model):
__tablename__ = "category_b"
id = db.Column(db.Integer, primary_key=True)
parent_id = db.Column(db.Integer(), db.ForeignKey('category_b.id'))
parent = db.relationship('Category',
primaryjoin='Category.parent_id == Category.id',
remote_side=id, backref=db.backref('children'))
但是我不能使用SQLAlchemy create_all()来初始化数据库。 如果我不想更改班级名称,我该怎么办呢? 谢谢!