-- Convert status columns to TINYINT(1) and backfill (safe order)
UPDATE sys_user SET status = CASE WHEN status IN ('enabled', '1') THEN '1' ELSE '0' END;
ALTER TABLE sys_user MODIFY COLUMN status TINYINT(1) NOT NULL DEFAULT 1;

UPDATE sys_role SET status = CASE WHEN status IN ('enabled', '1') THEN '1' ELSE '0' END;
ALTER TABLE sys_role MODIFY COLUMN status TINYINT(1) NOT NULL DEFAULT 1;

UPDATE sys_permission SET status = CASE WHEN status IN ('enabled', '1') THEN '1' ELSE '0' END;
ALTER TABLE sys_permission MODIFY COLUMN status TINYINT(1) NOT NULL DEFAULT 1;

UPDATE sys_dict_type SET status = CASE WHEN status IN ('enabled', '1') THEN '1' ELSE '0' END;
ALTER TABLE sys_dict_type MODIFY COLUMN status TINYINT(1) NOT NULL DEFAULT 1;

UPDATE sys_dict_item SET status = CASE WHEN status IN ('enabled', '1') THEN '1' ELSE '0' END;
ALTER TABLE sys_dict_item MODIFY COLUMN status TINYINT(1) NOT NULL DEFAULT 1;

UPDATE sys_param SET status = CASE WHEN status IN ('enabled', '1') THEN '1' ELSE '0' END;
ALTER TABLE sys_param MODIFY COLUMN status TINYINT(1) NOT NULL DEFAULT 1;

-- Optional: drop legacy is_active if exists
-- ALTER TABLE sys_user DROP COLUMN is_active;
