1
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)
magerine
  • 43
  • 4
  • Which of the two is failing? Please add some more debugging details. Add `echo=True` to the connection and add the exact SQL. Also please be aware that if either `name` or `surname` is `null` the `person` column will also be `null`! You can use `coalesce(name, '')` to solve that part. – rfkortekaas Feb 23 '22 at 08:24

0 Answers0