Closed 4Kaylum closed 1 year ago
Here's some proposed (but not explicitly finished) SQL for the occasion
CREATE TYPE point_origin AS ENUM('text', 'vc', 'minecraft'); CREATE TABLE IF NOT EXISTS user_points( timestamp TIMESTAMP NOT NULL, user_id BIGINT NOT NULL, guild_id BIGINT NOT NULL, channel_id BIGINT, origin point_origin NOT NULL ); INSERT INTO user_points (timestamp, user_id, guild_id, channel_id, origin) SELECT timestamp, user_id, guild_id, channel_id, 'text' FROM user_messages; INSERT INTO user_points (timestamp, user_id, guild_id, channel_id, origin) SELECT timestamp, user_id, guild_id, channel_id, 'vc' FROM user_vc_activity; INSERT INTO user_points (timestamp, user_id, guild_id, channel_id, origin) SELECT timestamp, user_id, guild_id, NULL, 'minecraft' FROM minecraft_server_activity; CREATE INDEX IF NOT EXISTS user_points_user_id_guild_id_timestamp_idx ON user_points (user_id, guild_id, timestamp); CREATE INDEX IF NOT EXISTS user_points_user_id_guild_id_timestamp_origin_idx ON user_points (user_id, guild_id, timestamp, origin); SELECT pg_size_pretty(pg_total_relation_size('user_messages') + pg_total_relation_size('user_vc_activity') + pg_total_relation_size('minecraft_server_activity')), pg_size_pretty(pg_total_relation_size('user_points')); SELECT pg_size_pretty(pg_table_size('user_messages') + pg_table_size('user_vc_activity') + pg_table_size('minecraft_server_activity')), pg_size_pretty(pg_table_size('user_points'));
Here's some proposed (but not explicitly finished) SQL for the occasion