mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-13 03:13:41 +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,
|
||||
kb_id BIGINT NOT NULL,
|
||||
page_type VARCHAR(64) NOT NULL,
|
||||
can_read BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
can_create BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_update BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
can_delete BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
-- SMALLINT (not BOOLEAN): the entity fields WikiAgentPageTypePermissionEntity
|
||||
-- .can{Read,Create,Update,Delete} are Integer (1/0). Vanilla PostgreSQL cannot
|
||||
-- map a BOOLEAN into a JDBC int, so these must stay integer-typed. Do not
|
||||
-- "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',
|
||||
create_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,
|
||||
version INT NOT NULL DEFAULT 1,
|
||||
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,
|
||||
update_time TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
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".
|
||||
enabled_kb BIGINT
|
||||
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,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
@ -28,7 +28,9 @@ BEGIN
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'mate_wiki_page' AND column_name = 'stale'
|
||||
) 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 $$;
|
||||
|
||||
|
||||
@ -10,7 +10,9 @@ CREATE TABLE IF NOT EXISTS mate_wiki_pipeline_definition (
|
||||
trigger_config_json TEXT,
|
||||
steps_json TEXT NOT NULL,
|
||||
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,
|
||||
update_time TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted INT NOT NULL DEFAULT 0
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
-- Per-KB source-watcher toggle. See the h2 sibling for the prose explanation.
|
||||
-- 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 $$
|
||||
BEGIN
|
||||
@ -8,6 +9,6 @@ BEGIN
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'mate_wiki_knowledge_base' AND column_name = 'watcher_enabled'
|
||||
) 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 $$;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user