(data): Add v1-v2 schema migration

This commit is contained in:
2026-07-22 12:59:56 +03:00
parent dd6fc013ee
commit 0c0040d3d2
2 changed files with 172 additions and 5 deletions
+6 -5
View File
@@ -27,7 +27,7 @@ CREATE TABLE events(
user_id TEXT,
occurred_at TIMESTAMPTZ,
event_payload JSONB,
parent_event_id INTEGER REFERENCES events (event_id),
parent_event_id INTEGER REFERENCES events (event_id) ON DELETE SET NULL ON UPDATE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE (event_id, event_type)
);
@@ -225,8 +225,6 @@ SELECT
events.channel_id AS event_channel_id,
events.profileid AS user_profileid,
events.user_id AS user_id,
events.event_payload AS event_payload,
events.parent_event_id AS parent_event_id,
user_profiles.nickname AS user_nickname,
user_profiles.timezone AS user_timezone,
@@ -295,7 +293,7 @@ SELECT
raid_in_events.source_id AS raidin_sourceid,
raid_in_events.source_name AS raidin_sourcename,
raid_in_events.viewer_count AS raidin_viewers
raid_in_events.viewer_count AS raidin_viewers,
notice_events.message_id AS notice_message_id,
notice_events.system_message AS notice_system_message,
@@ -304,6 +302,9 @@ SELECT
notice_sub_events.is_prime AS notice_sub_is_prime,
notice_sub_events.duration_months AS notice_sub_duration_months,
events.event_payload AS event_payload,
events.parent_event_id AS parent_event_id,
notice_resub_events.tier AS notice_resub_tier,
notice_resub_events.is_prime AS notice_resub_is_prime,
notice_resub_events.is_gift AS notice_resub_is_gift,
@@ -311,7 +312,7 @@ SELECT
notice_resub_events.duration_months AS notice_resub_duration_months,
notice_resub_events.streak_months AS notice_resub_streak_months,
notice_resub_events.gifter_is_anonymous AS notice_resub_gifter_is_anonymous,
notice_resub_events.gifter_user_id AS notice_resub_gifter_user_id,
notice_resub_events.gifter_user_id AS notice_resub_gifter_user_id
FROM events
LEFT JOIN user_profiles USING (profileid)