Files
xxx-sphere-web/bin/main/db/migration/V2__available_in.sql
Mario 4f2048bdc8
Some checks failed
Host-Based Deploy (Java 21 Fix) / build-and-run (push) Has been cancelled
Weiter gebaut
2026-04-25 16:56:35 +02:00

35 lines
1.1 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- Migration: vanillaAvailable (boolean) → availableIn (VARCHAR enum)
--
-- BDSM_AND_VANILLA = ehemals vanilla_available = TRUE
-- BDSM_ONLY = ehemals vanilla_available = FALSE (Default)
-- CHASTITY_ONLY = neuer Wert
--
-- Die Prozedur prüft zuerst, ob vanilla_available noch existiert, bevor
-- sie etwas tut dadurch ist die Migration auf leeren Datenbanken ein No-op.
DROP PROCEDURE IF EXISTS proc_migrate_available_in;
CREATE PROCEDURE proc_migrate_available_in()
BEGIN
DECLARE col_exists INT DEFAULT 0;
SELECT COUNT(*) INTO col_exists
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'aufgaben_gruppe'
AND COLUMN_NAME = 'vanilla_available';
IF col_exists > 0 THEN
ALTER TABLE aufgaben_gruppe
ADD COLUMN available_in VARCHAR(50) NOT NULL DEFAULT 'BDSM_ONLY';
UPDATE aufgaben_gruppe
SET available_in = 'BDSM_AND_VANILLA'
WHERE vanilla_available = 1;
ALTER TABLE aufgaben_gruppe
DROP COLUMN vanilla_available;
END IF;
END;
CALL proc_migrate_available_in();
DROP PROCEDURE IF EXISTS proc_migrate_available_in;