How to switch to native versioning with existing version tables?
See original GitHub issueHi there, I have a big project which has been using sqlalchemy-continuum for a long time. I’m trying to switch to use native versioning so we can do bulk imports and still get versions.
I set the native_versioning option:
make_versioned(
options={'native_versioning': True}
)
And then ran an alembic migration calling sync_trigger
for all the version tables:
conn = op.get_bind()
sync_trigger(conn, 'user_version')
sync_trigger(conn, 'inventory_item_version')
...
I can see in the database that _audit
triggers are created for all the tables. However, my tests now always return a length of 0 for list(model.versions) after updating a model. Am I missing a step?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to add versioning to a existing sql server 2016 table with ...
Below is the table DDL which I use to create the table -Product_Rates_test first. USE TestDB. SET ANSI_NULLS ON GO. SET QUOTED_IDENTIFIER ON...
Read more >Versioning vocabulary—ArcMap | Documentation
The adds table stores all records inserted to or updated in a versioned dataset ... versioned (the default option) or with the option...
Read more >Implementing version control using Amazon DynamoDB
Table ('VersionControl') # Add the new state data item ... To model historical versions of data and easily retrieve the most recent version...
Read more >System-Versioned Tables - MariaDB Knowledge Base
System-versioned tables record the history of all changes to table data. ... An existing table can be altered to enable system versioning for...
Read more >Database versioning without history tables - Stack Overflow
An update generally does nothing to the master table (unless a static value is actually changed) and a new version of the new...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ended up getting it to work by recreating the transaction table with native_versioning enabled and then copying all the old transactions across. I also needed to enable the hstore extension, and fork sqlalchemy-continuum to change a boolean so it no longer assumed the presence of PropertyModTrackerPlugin.
I should make a PR adding some documentation about it and fixing the mod tracker thing. In the meantime this is the migration I used, if someone else encounters this issue:
Postgres database server version 14 also requires quotes around the
version_table_name_format
if your table name has capital letters.