Transaction table not being created.
See original GitHub issuePyramid/SQLAlchemy project, using alembic the version tables are being created fine but the Transaction table is not so when changes are made, I get the error:
ProgrammingError: (psycopg2.ProgrammingError) relation "transaction" does not exist LINE 1: INSERT INTO transaction (fxt, issued_at, id, remote_addr) VA... ^ [SQL: "INSERT INTO transaction (fxt, issued_at, id, remote_addr) VALUES (%(fxt)s, %(issued_at)s, nextval('transaction_id_seq'), %(remote_addr)s) RETURNING transaction.id"] [parameters: {'fxt': None, 'issued_at': datetime.datetime(2020, 1, 28, 23, 1, 46, 849596), 'remote_addr': None}] (Background on this error at: http://sqlalche.me/e/f405)
Not doing anything fancy, just using the make_versioned/configure_mappers calls as in the examples.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (4 by maintainers)
Top GitHub Comments
I had a similar issue.
If you are using Alembic but NOT using Flask, then you need to manually import the models that are using versioning in
alembic/env.py
, and then you can run the revision auto-generating feature of Alembic.The below is a solution that doesn’t require you to manually create migration files. It’s not the cleanest, so I’m sure someone could suggest a neater way to do it.
My
models/__init__.py
:My
alembic/env.py
:Then you run:
This should create a migration file that creates the
reports_version
table (<your model>_version
instead) andtransaction
table, along with all necessary indices. If you have more models to version, just add their imports beforeconfigure_mappers()
Oh wow, that was easy.
So, I created a table as I would any other:
And it works 😄
Thank you, just need to get it to play nicely with marshmallow and we’re off to the races.