

CREATE TABLE active_account_list (
    game_identity TEXT NOT NULL,
    platform_id INTEGER NOT NULL,
    channel_id INTEGER NOT NULL,
    user_id TEXT NOT NULL,
    ds DATE NOT NULL,
    create_time TIMESTAMPTZ NOT NULL,
    receive_time TIMESTAMPTZ,
    PRIMARY KEY (game_identity, platform_id, channel_id, user_id, ds)
) PARTITION BY RANGE (ds);

CREATE EXTENSION pg_partman;

SELECT extname, extversion FROM pg_extension WHERE extname = 'pg_partman';

SELECT e.extname, n.nspname
FROM pg_extension e
JOIN pg_namespace n ON e.extnamespace = n.oid
WHERE e.extname = 'pg_partman';


SELECT public.create_parent(
    p_parent_table => 'public.active_account_list',
    p_control => 'ds',       -- 分区键字段
    p_interval => '1 day',    -- 按天分区
    p_premake => 30          -- 预创建未来30天分区
);

