Alembic 迁移:如何更改表以添加 gin 索引
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('person', sa.Column('__ts_vector__', postgresql.TSVECTOR(), sa.Computed("to_tsvector('english', name || ' ' || surname)", persisted=True), nullable=True))
op.create_index('ix_person___ts_vector__', 'person', ['__ts_vector__'], unique=False, postgresql_using='gin')
# ### end Alembic commands ###
上面的代码是我的迁移脚本,用于为 gin
索引创建迁移脚本。
但运行 alembic Upgrade
给出了以下错误:
File "/sqlalchemy/engine/default.py", line 719, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.InvalidObjectDefinition) generation expression is not immutable.
(Background on this error at: https://sqlalche.me/e/14/f405)
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('person', sa.Column('__ts_vector__', postgresql.TSVECTOR(), sa.Computed("to_tsvector('english', name || ' ' || surname)", persisted=True), nullable=True))
op.create_index('ix_person___ts_vector__', 'person', ['__ts_vector__'], unique=False, postgresql_using='gin')
# ### end Alembic commands ###
The above code is my migration script for creating a migration script for gin
index.
but running alembic upgrade
gives me the error bellow:
File "/sqlalchemy/engine/default.py", line 719, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.InvalidObjectDefinition) generation expression is not immutable.
(Background on this error at: https://sqlalche.me/e/14/f405)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论