Apply all migrations from scratch on the test database #1401
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I find that Alembic has added by itself a op.drop_table('alembic_version') in the upgrade function of the 2nd version file. Is this supposed to be there ? If not why did it added this by itself ? |
Beta Was this translation helpful? Give feedback.
-
hi - this is incredibly scant detail but based on the message "relation "public.alembic_version"" it seems like you have something weird going on with your configured search_path and/or how you have configured your tables and/or migration context, or perhaps you have set version_table_schema to "public" which would probably cause problems. I would advise you set your PostgreSQL search_path to 'public' and remove any references to the name "public" in the "schema" for tables or in your metadata config including version_table_schema. |
Beta Was this translation helpful? Give feedback.
-
that's the default for PostgreSQL, if you omit the schema entirely (which is what I recommend), "public" is where they will go.
Alembic supports this but let's start small.
OK remove that. public is the default schema. re-stating it confuses SQLAlchemy and Alembic. See https://docs.sqlalchemy.org/en/20/dialects/postgresql.html#remote-schema-table-introspection-and-postgresql-search-path . Overall, if your PG search path is left at its default of "public", and you omit the word "public" from any of your Python code regarding table schemas, everything should just work. |
Beta Was this translation helpful? Give feedback.
that's the default for PostgreSQL, if you omit the schema entirely (which is what I recommend), "public" is where they will go.
Alembic supports this but let's start small.
OK remove that. public is the default schema. re-stating it confuses SQLAlchemy and Alembic. See https://docs.sqlalchemy.org/en/20/dialects/postgresql.html#remote-schema-table-introspection-and-postgresql-search-path .
Overall, if your PG search path is left at its default of "public", and you omit the wor…