Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to call sync_trigger in Alembic env.py to keep the Native versioning up-to-date #236

Open
scil opened this issue Feb 19, 2020 · 3 comments

Comments

@scil
Copy link

scil commented Feb 19, 2020

I'd like an example to implement these code in alembic env.py

from sqlalchemy_continuum.dialects.postgresql import sync_trigger

sync_trigger(conn, 'article_version')

It's from Native versioning

@austospumanto
Copy link

Bump. Same issue. New triggers are not added when I migrate my schemas via Alembic.

@sp-schoen
Copy link

sp-schoen commented Sep 7, 2022

I found a working solution. After the autogenerated alembic commands in the migration script I added the following lines in the upgrade function:

conn = op.get_bind()
sync_trigger(conn, 'article_version')

First line just gets you to connection used by alembic. The trigger will be created, but I didn't test the whole thing. On downgrade I tried the same, but the trigger will not be removed.

@schanjr
Copy link

schanjr commented Nov 14, 2024

DIdn't work for me. I used synchronous engine and async engine, both returned

  File "/Users/schan/Library/Caches/pypoetry/virtualenvs/leads-v2-iIKbbH54-py3.12/lib/python3.12/site-packages/sqlalchemy_continuum/dialects/postgresql.py", line 480, in sync_trigger
    autoload_with=session.connection()
                  ^^^^^^^^^^^^^^^^^^^^
TypeError: '_ConnectionFairy' object is not callable


Using below versions
psycopg2 = "^2.9.10"
asyncpg = "^0.29.0"
alembic = "^1.13.2"
sqlalchemy-continuum = "^1.4.2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants