将 sqlalchemy.orm.relationship 添加到模型是否会更改内部数据库架构?如果 ORM 映射中唯一更改的是添加了 orm.relationship,我是否需要添加数据库迁移脚本?
例如原始映射:
class Service(Base):
__tablename__ = 'service'
id = sql.Column(sql.String(64), primary_key=True)
type = sql.Column(sql.String(255))
extra = sql.Column(sql.Text())
class Endpoint(Base):
__tablename__ = 'endpoint'
id = sql.Column(sql.String(64), primary_key=True)
legacy_endpoint_id = sql.Column(sql.String(64))
interface = sql.Column(sql.String(8), primary_key=True)
region = sql.Column('region', sql.String(255))
service_id = sql.Column(sql.String(64),
sql.ForeignKey('service.id'),
nullable=False)
url = sql.Column(sql.Text())
extra = sql.Column(sql.Text())
修改映射:
@@ -3,6 +3,7 @@
id = sql.Column(sql.String(64), primary_key=True)
type = sql.Column(sql.String(255))
extra = sql.Column(sql.Text())
+ endpoints = sql.orm.relationship("Endpoint")
class Endpoint(Base):
@@ -16,4 +17,5 @@
nullable=False)
url = sql.Column(sql.Text())
extra = sql.Column(sql.Text())
+ service = sql.orm.relationship("Service")
通过上述更改,我是否需要添加数据库迁移脚本?