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

Conversion from sqlite to postgres is broken #734

Open
mikfire opened this issue Mar 14, 2023 · 1 comment
Open

Conversion from sqlite to postgres is broken #734

mikfire opened this issue Mar 14, 2023 · 1 comment

Comments

@mikfire
Copy link
Contributor

mikfire commented Mar 14, 2023

This is trying to copy a default database from sqlite to postgres.

This is a note so that I remember to investigate; nobody else needs to worry about this.

[12:21:07.823] (1dljhogqtc) ERROR : int ObjectStore::impl::insertObjectInDb(QSqlDatabase&, const QObject&, bool) 
Error executing database query  "INSERT INTO fermentable (id, name, deleted, display, folder, inventory_id, add_after_boil, amount, coarse_fine_diff, color, diastatic_power, ftype, is_mashed, ibu_gal_per_lb, max_in_batch, moisture, notes, origin, supplier, protein, recommend_mash, yield) VALUES (:id, :name, :deleted, :display, :folder, :inventory_id, :add_after_boil, :amount, :coarse_fine_diff, :color, :diastatic_power, :ftype, :is_mashed, :ibu_gal_per_lb, :max_in_batch, :moisture, :notes, :origin, :supplier, :protein, :recommend_mash, :yield);" :  
"ERROR:  insert or update on table \"fermentable\" violates foreign key constraint \"fermentable_inventory_id_fkey\"\n
DETAIL:  Key (inventory_id)=(173) is not present in table \"fermentable_in_inventory\".\n(23503) QPSQL: Unable to create query"  [database/ObjectStore.cpp:756]
@matty0ung
Copy link
Contributor

One day maybe we'll have other PostgreSQL users! 😄 (I did use it a fair bit at work, but I never yet got around to getting it installed on my personal machine.)

AIUI, the simplest way to deal with this is to turn off constraints before the copy and turn them back on again afterwards. Eg, according to https://stackoverflow.com/questions/38112379/disable-postgresql-foreign-key-checks-for-migrations, it's SET session_replication_role = 'replica'; for the former and SET session_replication_role = 'origin'; for the latter.

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

2 participants