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

Database integrity (missing constraints) #189

Open
153957 opened this issue Sep 6, 2017 · 2 comments
Open

Database integrity (missing constraints) #189

153957 opened this issue Sep 6, 2017 · 2 comments
Labels

Comments

@153957
Copy link
Member

153957 commented Sep 6, 2017

Since the transition from MySQL to Postgres the database constraints have not been properly set.
This seems to be caused by the mysql to postgres tool which does not properly set the required constraints. See the two screenshots of the table structure (in Postico) of the inforecords.Cluster table.

The unique and foreign key constraints are not properly set in the live database. Although Django should take care of most of these automatically it would be wiser to have the database constraints properly set.

This will require some careful work, probably restoring from a dump. However, I had some trouble loading a dumped database into my local database with proper constraints... If I loaded the dumped data into a bare database (without tables) it went without issues.

Live database
live_database

Local newly migrated database
new_migrations

( @davidfokkema @tomkooij @kaspervd )

@153957 153957 added the bug label Sep 6, 2017
@153957
Copy link
Member Author

153957 commented Sep 6, 2017

To restore the database locally (vagrant) without errors/warnings I had to remove it and let postgres create the tables.

dropdb --host=localhost --username=postgres publicdb
createdb --host=localhost --username=postgres publicdb
pg_restore --host=localhost --username=postgres  --create --dbname=publicdb /vagrant/publicdb_dump.sql

@153957 153957 changed the title Database integrity Database integrity (missing constraints) Feb 10, 2018
tomkooij added a commit that referenced this issue Feb 19, 2018
Instructions to restore (a copy of) the live database in a dev VM.

See also #189
@153957
Copy link
Member Author

153957 commented Sep 6, 2018

Ran into an issues because of this with the migration to remove pulseheight fits:
https://github.com/HiSPARC/publicdb/blob/master/publicdb/histograms/migrations/0019_remove_pulseheightfit.py
I had to disable the 'AlterUniqueTogether' step of the migration to make it work.

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

No branches or pull requests

1 participant