refactor(db): 阶段C - Postgres migration 补全
- migrations/postgres/ 8 个文件改为 Postgres 方言: BIGSERIAL、原生 BOOLEAN、TEXT 主键、ON CONFLICT DO NOTHING/UPDATE、 "key" 双引号处理保留字 - 跳过 SQLite 历史遗留列(与 MySQL 版一致) - 00005 ws_messages 空操作(00001 已建) 至此三套数据库 migration 全部就位,业务 SQL 通过方言适配器统一处理。 SQLite 全测试通过,MySQL/PG 待真实实例验证。 Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
36a7f74154
commit
fb83aacb8b
8 files changed
+106
-199
No files matched your search
@@ -1,22 +1,5 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE IF NOT EXISTS ws_messages (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
cookie_id TEXT NOT NULL,
|
||||
direction TEXT NOT NULL DEFAULT 'in',
|
||||
raw_text TEXT NOT NULL DEFAULT '',
|
||||
parsed_json TEXT NOT NULL DEFAULT '',
|
||||
message_kind TEXT NOT NULL DEFAULT '',
|
||||
parse_status TEXT NOT NULL DEFAULT 'raw',
|
||||
error TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (cookie_id) REFERENCES cookies(id) ON DELETE CASCADE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_ws_messages_cookie_id_created_at ON ws_messages(cookie_id, created_at DESC);
|
||||
-- +goose StatementEnd
|
||||
-- ws_messages 表在 Postgres 版 00001 已创建,此迁移为空操作,保留版本号与 SQLite 对齐。
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP INDEX IF EXISTS idx_ws_messages_cookie_id_created_at;
|
||||
DROP TABLE IF EXISTS ws_messages;
|
||||
-- +goose StatementEnd
|
||||
-- 空操作:ws_messages 在 00001 创建,回滚由 00001 Down 处理。
|
||||
Reference in new issue
Block a user