Files
yunzerwebsiteallinone/go/docs/sql/add_module_platforms.sql
T
2026-11-16 17:22:50 +08:00

35 lines
1.5 KiB
SQL

SET @db := DATABASE();
SET @tbl := 'yz_system_modules';
SET @col := 'platforms';
SET @exists := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = @tbl AND COLUMN_NAME = @col
);
SET @sql := IF(@exists = 0,
CONCAT('ALTER TABLE `', @tbl, '` ADD COLUMN `', @col,
'` VARCHAR(64) NULL DEFAULT NULL COMMENT ''展示端:web/app JSON数组;空或NULL=全端'' AFTER `is_show`'),
CONCAT('ALTER TABLE `', @tbl, '` MODIFY COLUMN `', @col,
'` VARCHAR(64) NULL DEFAULT NULL COMMENT ''展示端:web/app JSON数组;空或NULL=全端''')
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @tbl := 'yz_system_menu';
SET @exists := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = @tbl AND COLUMN_NAME = @col
);
SET @sql := IF(@exists = 0,
CONCAT('ALTER TABLE `', @tbl, '` ADD COLUMN `', @col,
'` VARCHAR(64) NULL DEFAULT NULL COMMENT ''展示端:web/app JSON数组;空或NULL=继承所属模块'' AFTER `views`'),
CONCAT('ALTER TABLE `', @tbl, '` MODIFY COLUMN `', @col,
'` VARCHAR(64) NULL DEFAULT NULL COMMENT ''展示端:web/app JSON数组;空或NULL=继承所属模块''')
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_COMMENT
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND COLUMN_NAME = 'platforms'
AND TABLE_NAME IN ('yz_system_modules', 'yz_system_menu');