diff --git a/mateclaw-server/src/main/resources/db/migration/kingbase/V154__agent_wiki_disabled.sql b/mateclaw-server/src/main/resources/db/migration/kingbase/V154__agent_wiki_disabled.sql index 72db6127..62c9db24 100644 --- a/mateclaw-server/src/main/resources/db/migration/kingbase/V154__agent_wiki_disabled.sql +++ b/mateclaw-server/src/main/resources/db/migration/kingbase/V154__agent_wiki_disabled.sql @@ -1,3 +1,3 @@ -- V154: Wiki/knowledge-base opt-out flag on mate_agent (issue #304). -- Mirrors skills_disabled / tools_disabled. Defaults to FALSE. -ALTER TABLE mate_agent ADD COLUMN IF NOT EXISTS wiki_disabled SMALLINT NOT NULL DEFAULT 0; +ALTER TABLE mate_agent ADD COLUMN IF NOT EXISTS wiki_disabled BOOLEAN NOT NULL DEFAULT FALSE; diff --git a/mateclaw-server/src/main/resources/db/migration/mysql/V154__agent_wiki_disabled.sql b/mateclaw-server/src/main/resources/db/migration/mysql/V154__agent_wiki_disabled.sql index abb8131d..aa92cf27 100644 --- a/mateclaw-server/src/main/resources/db/migration/mysql/V154__agent_wiki_disabled.sql +++ b/mateclaw-server/src/main/resources/db/migration/mysql/V154__agent_wiki_disabled.sql @@ -1,3 +1,17 @@ -- V154: Wiki/knowledge-base opt-out flag on mate_agent (issue #304). -- Mirrors skills_disabled / tools_disabled. Defaults to FALSE. -ALTER TABLE mate_agent ADD COLUMN IF NOT EXISTS wiki_disabled TINYINT(1) NOT NULL DEFAULT 0; +-- See the H2 file for context. MySQL 8.0 doesn't support +-- `ADD COLUMN IF NOT EXISTS`, so the existence check goes through +-- INFORMATION_SCHEMA + a prepared statement. +SET @col_exists := ( + SELECT COUNT(*) FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'mate_agent' + AND COLUMN_NAME = 'wiki_disabled' +); +SET @ddl := IF(@col_exists = 0, + 'ALTER TABLE mate_agent ADD COLUMN wiki_disabled TINYINT(1) NOT NULL DEFAULT 0', + 'SELECT 1'); +PREPARE stmt FROM @ddl; +EXECUTE stmt; +DEALLOCATE PREPARE stmt;