我在尝试在新的Flask应用中创建迁移时遇到问题。学习python / flask,所以请耐心等待!
这是班级/移民
class Experiments(db.Model):
experiment_id = db.Column(db.Integer, primary_key=True)
device_id = db.Column(db.Integer, db.ForeignKey('device.id'), nullable=False)
initiated_by = db.Column(db.Integer, db.ForeignKey('tb_user.id'), nullable=False)
temperature = db.Column(db.Numeric(3,2), nullable=False)
o2 = db.Column(db.Numeric(4,3), nullable=False)
co2 = db.Column(db.Numeric(4,3), nullable=False)
image_capture_interval = db.Column(db.Integer, nullable=False)
start_at = db.Column(db.DateTime, nullable=False)
end_at = db.Column(db.DateTime, nullable=False)
create_at = db.Column(db.DateTime, nullable=False)
updated_at = db.Column(db.DateTime, nullable=False)
deleted_at = db.Column(db.DateTime, nullable=False)
我收到错误
sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column
'experiments.initiated_by' could not find table 'tb_user.id' with which to
generate a foreign key to target column 'id'
该表“ tb_user”确实存在,它的“ id”列也存在
这些表已经存在,因此我没有为它们进行任何类/模型/迁移,因为它们是由另一个应用程序(记事板)管理的
如何绑定这些表/列?
谢谢!