Skip to content

Conditionally creating tables in PostgresQL with "unlogged" prefix in certain environments #1108

Answered by zzzeek
sihil asked this question in Usage Questions
Discussion options

You must be logged in to vote

I would like to invoke create table migration operations with a prefix of "unlogged" when running in local and continuous integration environments but without that prefix when the migrations are run elsewhere. From what I understand about the SQLalchemy architecture I think this needs to happen in alembic.

OK, there are ways to affect that at the SQLAlchemy level as well, a table prefix is a pretty simple thing so a compiles against CreateTable could achieve this, if you had the compiler hook looking at a global variable.

I've considered/investigated various options:

1. write an SQLalchemy metaclass to adjust this, but this happens too early and is baked into the migrations

I would s…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@sihil
Comment options

@sihil
Comment options

@CaselIT
Comment options

@zzzeek
Comment options

@sihil
Comment options

Answer selected by sihil
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants