Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions migrations/0006_puzzling_bloodstrike.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE `app_views` ADD `viewer_hash` text;--> statement-breakpoint
-- Backfill existing rows with their unique id so historical view counts are
-- preserved under COUNT(DISTINCT viewer_hash) and the unique index below is
-- satisfied. Going-forward dedup uses a per-viewer/per-bucket hash on insert.
UPDATE `app_views` SET `viewer_hash` = `id` WHERE `viewer_hash` IS NULL;--> statement-breakpoint
CREATE UNIQUE INDEX `app_views_app_viewer_idx` ON `app_views` (`app_id`,`viewer_hash`);
Loading
Loading