Roundcube - Migration from older mailcow roundcube setup issue
FingerlessGlov3s opened this issue · comments
FingerlessGloves commented
I did the upgrade Migration from older mailcow roundcube setup
ages ago and come across a bug, when the tables are moved the foreign keys aren't updated. I got the below SQL script which dynamically gets all the foreign keys, then removes the old prefix, to create what the foreign keys should be for each table, then outputs the SQL queries required to amend the new tables in the roundcubemail
database.
By not updating the foreign keys creates problems creating identities and other parts of roundcube.
SELECT
CONCAT(
'ALTER TABLE `', TABLE_NAME, '` ',
'DROP FOREIGN KEY `', CONSTRAINT_NAME, '`;',
'ALTER TABLE `', TABLE_NAME, '` ',
'ADD FOREIGN KEY `', CONSTRAINT_NAME, '` (', COLUMN_NAME, ') ',
'REFERENCES `', REPLACE(REFERENCED_TABLE_NAME, 'mailcow_rc1', ''), '` (', REFERENCED_COLUMN_NAME, ');'
)
FROM
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE
TABLE_SCHEMA = 'roundcubemail' AND
REFERENCED_TABLE_NAME IS NOT NULL;
I'll have a look at updating the docs when I get a moment unless someone can get too it before I can.