將sqlalchemy.orm.relationship添加到模型是否更改了內部數據庫模式?如果ORM映射中唯一發生變化的是添加了orm.relationship,那麼是否需要添加數據庫遷移腳本?將sqlalchemy.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")
通過上面的變化,我需要添加數據庫遷移腳本?