<<<<<<< HEAD
-- 1.0.341 P-022 WP-2：去掉 IPQC 归口源表 tenant_id 的 DEFAULT 1300000000001（幂等）。
SET NAMES utf8mb4;

SET @has_def := (
  SELECT COUNT(*) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'qms_gcjyd' AND COLUMN_NAME = 'tenant_id'
    AND COLUMN_DEFAULT IS NOT NULL);
SET @sql := IF(@has_def > 0,
  'ALTER TABLE `qms_gcjyd` ALTER COLUMN `tenant_id` DROP DEFAULT',
  'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;

SET @has_def := (
  SELECT COUNT(*) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'qms_gcjydzb' AND COLUMN_NAME = 'tenant_id'
    AND COLUMN_DEFAULT IS NOT NULL);
SET @sql := IF(@has_def > 0,
  'ALTER TABLE `qms_gcjydzb` ALTER COLUMN `tenant_id` DROP DEFAULT',
  'SELECT 1');
=======
-- 1.0.341 ItemMaster 新增 MRPRequired（是否参与资源检查）
-- 行尾必须 LF（CRLF 会导致 SHA256 与 sys_db_migration_log 不一致并阻止启动）。

SET @col_exists := (SELECT COUNT(*) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ItemMaster' AND COLUMN_NAME='MRPRequired');
SET @sql := IF(@col_exists = 0,
  'ALTER TABLE `ItemMaster` ADD COLUMN `MRPRequired` tinyint(1) NOT NULL DEFAULT 0 COMMENT ''是否参与资源检查''',
  'DO 0');
>>>>>>> 6776bdd99 (feat: 物料维护新增 MRPRequired(参与资源检查) 字段; 修复 1.0.338.sql CRLF→LF 行尾)
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
