Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Backfill missing usage rows

Neeraj Guptac2011b314561
diff --git a/server/migrations/141_backfill_missing_usage.down.sql b/server/migrations/141_backfill_missing_usage.down.sql
new file mode 100644
index 0000000000..9f7060a47f
--- /dev/null
+++ b/server/migrations/141_backfill_missing_usage.down.sql
@@ -0,0 +1 @@
+-- no-op
diff --git a/server/migrations/141_backfill_missing_usage.up.sql b/server/migrations/141_backfill_missing_usage.up.sql
new file mode 100644
index 0000000000..2b1e4be15c
--- /dev/null
+++ b/server/migrations/141_backfill_missing_usage.up.sql
@@ -0,0 +1,9 @@
+INSERT INTO usage(user_id, storage_consumed)
+SELECT u.user_id, 0
+FROM users u
+WHERE NOT EXISTS (
+ SELECT 1
+ FROM usage us
+ WHERE us.user_id = u.user_id
+)
+ON CONFLICT (user_id) DO NOTHING;