Autogenerated migration script does not include postgreSQL schema name in enum type #1417
-
I have autogenerated a migration script for postgresSQL . It includes schame name in new tables but not in new Enum. def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('accounts',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('status', sa.Enum('active', 'inactive', name='accountstatus'), nullable=True),
sa.PrimaryKeyConstraint('id'),
schema='auth'
) cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.InvalidSchemaName) no schema has been selected to create in
[SQL: CREATE TYPE accountstatus AS ENUM ('active', 'inactive')]
(Background on this error at: https://sqlalche.me/e/20/f405) If i change line |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi, You need to set https://docs.sqlalchemy.org/en/20/core/type_basics.html#sqlalchemy.types.Enum.params.inherit_schema to true fir the enum to inherit the schema. @zzzeek why is that flag not set to true by default? Could it be a change for sqlalchemy 2.1? |
Beta Was this translation helpful? Give feedback.
-
yes let's do this |
Beta Was this translation helpful? Give feedback.
Hi,
You need to set https://docs.sqlalchemy.org/en/20/core/type_basics.html#sqlalchemy.types.Enum.params.inherit_schema to true fir the enum to inherit the schema.
@zzzeek why is that flag not set to true by default? Could it be a change for sqlalchemy 2.1?