Upgrading from 0.47.4 to 0.50.23 my upgrade crashed with an error relating to a violation of the fk_data_permissions_ref_db_id constraint on the data_permissions table. I use Mariadb as the database for Metabase.
I corrected the error like this:
- I went into the mariadb console with my metabase database:
sudo mariadb metabase
- I removed the constraint
alter table data_permissions drop constraint fk_data_permissions_ref_db_id;
- I returned to the console and restarted metabase - which now ran without error.
- Back to mariadb, I removed records from the data_permissions table that were violating the constraint:
delete from data_permissions where id in ( select p.id from data_permissions p where (select count(*) from metabase_database db where db.id=p.db_id)=0 );
- And recreated the constraint on the table:
alter table data_permissions add constraint fk_data_permissions_ref_db_id foreign key (db_id) references metabase_database(id) on delete cascade;
Most likely, I only needed step 4.
Just posting this here because 1) I deleted some table rows to make the upgrade work, and perhaps someone would have some opinion on that and 2) someone else might find this error/report and solution useful.
Kind regards, C