Fork from QuoteForge → PriceForge
Renamed module path git.mchus.pro/mchus/quoteforge → git.mchus.pro/mchus/priceforge, renamed package quoteforge → priceforge, moved binary from cmd/qfs to cmd/pfs.
This commit is contained in:
25
migrations/007_detach_configurations_from_qt_users.sql
Normal file
25
migrations/007_detach_configurations_from_qt_users.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
-- Detach qt_configurations from qt_users (ownership is owner_username text)
|
||||
-- Safe for MySQL 8+/MariaDB 10.2+ via INFORMATION_SCHEMA checks.
|
||||
|
||||
SET @fk_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.TABLE_CONSTRAINTS
|
||||
WHERE CONSTRAINT_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'qt_configurations'
|
||||
AND CONSTRAINT_NAME = 'fk_qt_configurations_user'
|
||||
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
|
||||
);
|
||||
|
||||
SET @drop_fk_sql := IF(
|
||||
@fk_exists > 0,
|
||||
'ALTER TABLE qt_configurations DROP FOREIGN KEY fk_qt_configurations_user',
|
||||
'SELECT ''fk_qt_configurations_user not found, skip'' '
|
||||
);
|
||||
PREPARE stmt_drop_fk FROM @drop_fk_sql;
|
||||
EXECUTE stmt_drop_fk;
|
||||
DEALLOCATE PREPARE stmt_drop_fk;
|
||||
|
||||
-- user_id becomes optional legacy column (can stay NULL)
|
||||
ALTER TABLE qt_configurations
|
||||
MODIFY COLUMN user_id BIGINT UNSIGNED NULL;
|
||||
|
||||
Reference in New Issue
Block a user