mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-15 20:08:18 +08:00
fix(db): correct V154 wiki_disabled migration for MySQL and KingbaseES
The cherry-picked V154 used 'ALTER TABLE ... ADD COLUMN IF NOT EXISTS' for MySQL — invalid on MySQL 8.0.x (a MariaDB-only extension) which aborts Flyway at startup. Switch to the INFORMATION_SCHEMA + PREPARE guard the other MySQL migrations use. Also change the KingbaseES column from SMALLINT to BOOLEAN to match the Java 'Boolean wikiDisabled' field and the existing skills_disabled / tools_disabled flags (vanilla PostgreSQL is strict about boolean vs smallint). H2 (already BOOLEAN) is unchanged.
This commit is contained in:
parent
22a212a2e6
commit
d6001e3e6f
@ -1,3 +1,3 @@
|
|||||||
-- V154: Wiki/knowledge-base opt-out flag on mate_agent (issue #304).
|
-- V154: Wiki/knowledge-base opt-out flag on mate_agent (issue #304).
|
||||||
-- Mirrors skills_disabled / tools_disabled. Defaults to FALSE.
|
-- 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;
|
||||||
|
|||||||
@ -1,3 +1,17 @@
|
|||||||
-- V154: Wiki/knowledge-base opt-out flag on mate_agent (issue #304).
|
-- V154: Wiki/knowledge-base opt-out flag on mate_agent (issue #304).
|
||||||
-- Mirrors skills_disabled / tools_disabled. Defaults to FALSE.
|
-- 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;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user