mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-08-30 23:28:29 +00:00
Fix migration for MariaDB 12.2.2 (#7265)
Co-authored-by: Timshel <timshel@users.noreply.github.com>
This commit is contained in:
@@ -1,15 +1,31 @@
|
|||||||
-- Dynamically create DROP FOREIGN KEY
|
SELECT if (
|
||||||
-- Some versions of MySQL or MariaDB might fail if the key doesn't exists
|
EXISTS(
|
||||||
-- This checks if the key exists, and if so, will drop it.
|
SELECT CONSTRAINT_NAME FROM information_schema.table_constraints
|
||||||
SET @drop_sso_fk = IF((SELECT true FROM information_schema.TABLE_CONSTRAINTS WHERE
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
CONSTRAINT_SCHEMA = DATABASE() AND
|
AND TABLE_NAME = 'sso_users'
|
||||||
TABLE_NAME = 'sso_users' AND
|
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
|
||||||
CONSTRAINT_NAME = 'sso_users_ibfk_1' AND
|
AND CONSTRAINT_NAME = 'sso_users_ibfk_1'
|
||||||
CONSTRAINT_TYPE = 'FOREIGN KEY') = true,
|
)
|
||||||
'ALTER TABLE sso_users DROP FOREIGN KEY sso_users_ibfk_1',
|
,'ALTER TABLE sso_users DROP FOREIGN KEY `sso_users_ibfk_1`'
|
||||||
'SELECT 1');
|
,'SELECT "info: FK sso_users_ibfk_1 does not exist."'
|
||||||
PREPARE stmt FROM @drop_sso_fk;
|
) INTO @drop_stmt;
|
||||||
EXECUTE stmt;
|
PREPARE drop_stmt FROM @drop_stmt;
|
||||||
DEALLOCATE PREPARE stmt;
|
EXECUTE drop_stmt;
|
||||||
|
|
||||||
|
SELECT if (
|
||||||
|
EXISTS(
|
||||||
|
SELECT CONSTRAINT_NAME FROM information_schema.table_constraints
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'sso_users'
|
||||||
|
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
|
||||||
|
AND CONSTRAINT_NAME = '1'
|
||||||
|
)
|
||||||
|
,'ALTER TABLE sso_users DROP FOREIGN KEY `1`'
|
||||||
|
,'SELECT "info: FK sso_users 1 does not exist."'
|
||||||
|
) INTO @drop_stmt;
|
||||||
|
PREPARE drop_stmt FROM @drop_stmt;
|
||||||
|
EXECUTE drop_stmt;
|
||||||
|
|
||||||
|
DEALLOCATE PREPARE drop_stmt;
|
||||||
|
|
||||||
ALTER TABLE sso_users ADD FOREIGN KEY(user_uuid) REFERENCES users(uuid) ON UPDATE CASCADE ON DELETE CASCADE;
|
ALTER TABLE sso_users ADD FOREIGN KEY(user_uuid) REFERENCES users(uuid) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ services:
|
|||||||
Mariadb:
|
Mariadb:
|
||||||
profiles: ["playwright"]
|
profiles: ["playwright"]
|
||||||
container_name: playwright_mariadb
|
container_name: playwright_mariadb
|
||||||
image: mariadb:11.2.4
|
image: mariadb:12.2.2
|
||||||
env_file: test.env
|
env_file: test.env
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
|
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
|
||||||
|
|||||||
Reference in New Issue
Block a user