Files
OSGAccountServer/src/main/resources/db/migration/V24__hint_feed_generation.sql
T
Rocky 454ba8ddc5 Migrate AI Hint feed generation
Bring dynamic hint generation into the account service while preserving the legacy key.osglab.com deployment for existing clients.
2026-08-21 15:17:15 +08:00

57 lines
2.0 KiB
SQL

CREATE TABLE hint_feed_settings (
id TINYINT UNSIGNED NOT NULL,
generation_interval_hours INT NOT NULL,
holiday_countries_zh VARCHAR(255) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
holiday_countries_en VARCHAR(255) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
weather_cities_zh TEXT NOT NULL,
weather_cities_en TEXT NOT NULL,
google_trends_geos VARCHAR(255) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
updated_at DATETIME(6) NOT NULL,
PRIMARY KEY (id),
CONSTRAINT chk_hint_feed_settings_singleton CHECK (id = 1),
CONSTRAINT chk_hint_feed_generation_interval
CHECK (generation_interval_hours BETWEEN 1 AND 168)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
INSERT INTO hint_feed_settings (
id,
generation_interval_hours,
holiday_countries_zh,
holiday_countries_en,
weather_cities_zh,
weather_cities_en,
google_trends_geos,
updated_at
) VALUES (
1,
12,
'CN',
'US,GB',
'北京:39.90,116.40;上海:31.23,121.47;广州:23.13,113.26;深圳:22.54,114.06',
'New York:40.71,-74.01;London:51.51,-0.13;Los Angeles:34.05,-118.24',
'US,GB',
UTC_TIMESTAMP(6)
);
CREATE TABLE hint_feed_generation_state (
id TINYINT UNSIGNED NOT NULL,
status VARCHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
last_started_at DATETIME(6) NULL,
last_completed_at DATETIME(6) NULL,
last_error_code VARCHAR(64) CHARACTER SET ascii COLLATE ascii_bin NULL,
updated_at DATETIME(6) NOT NULL,
PRIMARY KEY (id),
CONSTRAINT chk_hint_feed_state_singleton CHECK (id = 1),
CONSTRAINT chk_hint_feed_state_status
CHECK (status IN ('IDLE', 'RUNNING', 'SUCCEEDED', 'FAILED'))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
INSERT INTO hint_feed_generation_state (
id,
status,
last_started_at,
last_completed_at,
last_error_code,
updated_at
) VALUES (1, 'IDLE', NULL, NULL, NULL, UTC_TIMESTAMP(6));