mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-15 20:08:18 +08:00
fix(db): keep Integer-mapped wiki flag columns as SMALLINT in the PostgreSQL-family tree
The blanket SMALLINT->BOOLEAN flag-column conversion over-reached: six wiki columns map to Integer (1/0) entity fields, not Boolean. On vanilla PostgreSQL, reading a BOOLEAN into a JDBC int throws 'Bad value for type int : f', breaking every wiki KB list / SSE chat. Revert only those six back to SMALLINT (V133/V134/ V135/V136/V146 in the PostgreSQL-family tree) with guard comments; genuine Boolean-entity columns stay BOOLEAN.
This commit is contained in:
parent
839cb2c1ba
commit
a0eba17688
@ -10,10 +10,14 @@ CREATE TABLE IF NOT EXISTS mate_wiki_agent_page_type_permission (
|
|||||||
agent_id BIGINT NOT NULL,
|
agent_id BIGINT NOT NULL,
|
||||||
kb_id BIGINT NOT NULL,
|
kb_id BIGINT NOT NULL,
|
||||||
page_type VARCHAR(64) NOT NULL,
|
page_type VARCHAR(64) NOT NULL,
|
||||||
can_read BOOLEAN NOT NULL DEFAULT TRUE,
|
-- SMALLINT (not BOOLEAN): the entity fields WikiAgentPageTypePermissionEntity
|
||||||
can_create BOOLEAN NOT NULL DEFAULT FALSE,
|
-- .can{Read,Create,Update,Delete} are Integer (1/0). Vanilla PostgreSQL cannot
|
||||||
can_update BOOLEAN NOT NULL DEFAULT FALSE,
|
-- map a BOOLEAN into a JDBC int, so these must stay integer-typed. Do not
|
||||||
can_delete BOOLEAN NOT NULL DEFAULT FALSE,
|
-- "normalize" to BOOLEAN to match the other flag columns.
|
||||||
|
can_read SMALLINT NOT NULL DEFAULT 1,
|
||||||
|
can_create SMALLINT NOT NULL DEFAULT 0,
|
||||||
|
can_update SMALLINT NOT NULL DEFAULT 0,
|
||||||
|
can_delete SMALLINT NOT NULL DEFAULT 0,
|
||||||
write_policy VARCHAR(32) NOT NULL DEFAULT 'approval_required',
|
write_policy VARCHAR(32) NOT NULL DEFAULT 'approval_required',
|
||||||
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|||||||
@ -10,7 +10,10 @@ CREATE TABLE IF NOT EXISTS mate_wiki_page_type_profile (
|
|||||||
name VARCHAR(128) NOT NULL,
|
name VARCHAR(128) NOT NULL,
|
||||||
version INT NOT NULL DEFAULT 1,
|
version INT NOT NULL DEFAULT 1,
|
||||||
config_json TEXT NOT NULL,
|
config_json TEXT NOT NULL,
|
||||||
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
-- SMALLINT (not BOOLEAN): WikiPageTypeProfileEntity.enabled is Integer (1/0).
|
||||||
|
-- Vanilla PostgreSQL cannot map a BOOLEAN into a JDBC int. The generated
|
||||||
|
-- column below compares enabled = 1 accordingly. Do not switch to BOOLEAN.
|
||||||
|
enabled SMALLINT NOT NULL DEFAULT 1,
|
||||||
create_time TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
create_time TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
update_time TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
update_time TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
deleted INT NOT NULL DEFAULT 0,
|
deleted INT NOT NULL DEFAULT 0,
|
||||||
@ -18,7 +21,7 @@ CREATE TABLE IF NOT EXISTS mate_wiki_page_type_profile (
|
|||||||
-- ignores NULL keys for uniqueness, giving "at most one enabled per KB".
|
-- ignores NULL keys for uniqueness, giving "at most one enabled per KB".
|
||||||
enabled_kb BIGINT
|
enabled_kb BIGINT
|
||||||
GENERATED ALWAYS AS (
|
GENERATED ALWAYS AS (
|
||||||
CASE WHEN enabled = TRUE AND deleted = 0 THEN kb_id ELSE NULL END
|
CASE WHEN enabled = 1 AND deleted = 0 THEN kb_id ELSE NULL END
|
||||||
) STORED,
|
) STORED,
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -28,7 +28,9 @@ BEGIN
|
|||||||
SELECT 1 FROM information_schema.columns
|
SELECT 1 FROM information_schema.columns
|
||||||
WHERE table_name = 'mate_wiki_page' AND column_name = 'stale'
|
WHERE table_name = 'mate_wiki_page' AND column_name = 'stale'
|
||||||
) THEN
|
) THEN
|
||||||
ALTER TABLE mate_wiki_page ADD COLUMN stale BOOLEAN NOT NULL DEFAULT FALSE;
|
-- SMALLINT (not BOOLEAN): WikiPageEntity.stale is Integer (1/0). Vanilla
|
||||||
|
-- PostgreSQL cannot map a BOOLEAN into a JDBC int. Do not switch to BOOLEAN.
|
||||||
|
ALTER TABLE mate_wiki_page ADD COLUMN stale SMALLINT NOT NULL DEFAULT 0;
|
||||||
END IF;
|
END IF;
|
||||||
END $$;
|
END $$;
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,9 @@ CREATE TABLE IF NOT EXISTS mate_wiki_pipeline_definition (
|
|||||||
trigger_config_json TEXT,
|
trigger_config_json TEXT,
|
||||||
steps_json TEXT NOT NULL,
|
steps_json TEXT NOT NULL,
|
||||||
dedup_window_seconds INT NOT NULL DEFAULT 0,
|
dedup_window_seconds INT NOT NULL DEFAULT 0,
|
||||||
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
-- SMALLINT (not BOOLEAN): WikiPipelineDefinitionEntity.enabled is Integer (1/0).
|
||||||
|
-- Vanilla PostgreSQL cannot map a BOOLEAN into a JDBC int. Do not switch to BOOLEAN.
|
||||||
|
enabled SMALLINT NOT NULL DEFAULT 1,
|
||||||
create_time TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
create_time TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
update_time TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
update_time TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
deleted INT NOT NULL DEFAULT 0
|
deleted INT NOT NULL DEFAULT 0
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
-- Per-KB source-watcher toggle. See the h2 sibling for the prose explanation.
|
-- Per-KB source-watcher toggle. See the h2 sibling for the prose explanation.
|
||||||
-- MySQL INFORMATION_SCHEMA guard converted to plpgsql DO block.
|
-- MySQL INFORMATION_SCHEMA guard converted to plpgsql DO block.
|
||||||
-- TINYINT(1) converted to SMALLINT.
|
-- SMALLINT (not BOOLEAN): WikiKnowledgeBaseEntity.watcherEnabled is Integer (1/0).
|
||||||
|
-- Vanilla PostgreSQL cannot map a BOOLEAN into a JDBC int. Do not switch to BOOLEAN.
|
||||||
|
|
||||||
DO $$
|
DO $$
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -8,6 +9,6 @@ BEGIN
|
|||||||
SELECT 1 FROM information_schema.columns
|
SELECT 1 FROM information_schema.columns
|
||||||
WHERE table_name = 'mate_wiki_knowledge_base' AND column_name = 'watcher_enabled'
|
WHERE table_name = 'mate_wiki_knowledge_base' AND column_name = 'watcher_enabled'
|
||||||
) THEN
|
) THEN
|
||||||
ALTER TABLE mate_wiki_knowledge_base ADD COLUMN watcher_enabled BOOLEAN NOT NULL DEFAULT FALSE;
|
ALTER TABLE mate_wiki_knowledge_base ADD COLUMN watcher_enabled SMALLINT NOT NULL DEFAULT 0;
|
||||||
END IF;
|
END IF;
|
||||||
END $$;
|
END $$;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user