Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

feat(db): remove Reddit accounts and their stored cookies and passwords

spacesdrive9f21f4ec2a35
diff --git a/supabase/migrations/20261104222458_alter_accounts_without_reddit.sql b/supabase/migrations/20261104222458_alter_accounts_without_reddit.sql
new file mode 100644
index 0000000..ac66025
--- /dev/null
+++ b/supabase/migrations/20261104222458_alter_accounts_without_reddit.sql
@@ -0,0 +1,5 @@
+-- removes Reddit accounts, with their stored cookies and passwords, and allows only YouTube and Instagram accounts
+delete from public.accounts where platform = 'reddit';
+alter table public.accounts
+ drop constraint accounts_platform_check,
+ add constraint accounts_platform_check check (platform in ('youtube', 'instagram'));
diff --git a/supabase/migrations/20261104222501_replace_accounts_identity_index.sql b/supabase/migrations/20261104222501_replace_accounts_identity_index.sql
new file mode 100644
index 0000000..0ff157b
--- /dev/null
+++ b/supabase/migrations/20261104222501_replace_accounts_identity_index.sql
@@ -0,0 +1,7 @@
+-- rebuilds the one-account-per-user index without the Reddit username branch
+drop index if exists public.accounts_identity_key;
+create unique index accounts_identity_key on public.accounts (
+ user_id,
+ platform,
+ (case platform when 'youtube' then data ->> 'channelId' when 'instagram' then data ->> 'igUserId' end)
+);
diff --git a/supabase/rollbacks/20261104222458_alter_accounts_without_reddit.sql b/supabase/rollbacks/20261104222458_alter_accounts_without_reddit.sql
new file mode 100644
index 0000000..710dbc2
--- /dev/null
+++ b/supabase/rollbacks/20261104222458_alter_accounts_without_reddit.sql
@@ -0,0 +1,4 @@
+-- allows Reddit accounts again; the deleted rows come back only from the backup taken before the change
+alter table public.accounts
+ drop constraint accounts_platform_check,
+ add constraint accounts_platform_check check (platform in ('youtube', 'instagram', 'reddit'));
diff --git a/supabase/rollbacks/20261104222501_replace_accounts_identity_index.sql b/supabase/rollbacks/20261104222501_replace_accounts_identity_index.sql
new file mode 100644
index 0000000..9359b35
--- /dev/null
+++ b/supabase/rollbacks/20261104222501_replace_accounts_identity_index.sql
@@ -0,0 +1,7 @@
+-- rebuilds the one-account-per-user index with the Reddit username branch it had before
+drop index if exists public.accounts_identity_key;
+create unique index accounts_identity_key on public.accounts (
+ user_id,
+ platform,
+ (case platform when 'youtube' then data ->> 'channelId' when 'reddit' then data ->> 'username' when 'instagram' then data ->> 'igUserId' end)
+);
diff --git a/supabase/schemas/public/tables/accounts.sql b/supabase/schemas/public/tables/accounts.sql
index b032943..d5cf950 100644
--- a/supabase/schemas/public/tables/accounts.sql
+++ b/supabase/schemas/public/tables/accounts.sql
@@ -8,7 +8,7 @@ CREATE TABLE "public"."accounts" (
CONSTRAINT "accounts_data_check" CHECK ((jsonb_typeof(data) = 'object'::text)),
CONSTRAINT "accounts_id_user_id_key" UNIQUE (id, user_id),
CONSTRAINT "accounts_pkey" PRIMARY KEY (id),
- CONSTRAINT "accounts_platform_check" CHECK ((platform = ANY (ARRAY['youtube'::text, 'instagram'::text, 'reddit'::text]))),
+ CONSTRAINT "accounts_platform_check" CHECK ((platform = ANY (ARRAY['youtube'::text, 'instagram'::text]))),
CONSTRAINT "accounts_user_id_fkey" FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE
);
@@ -18,7 +18,6 @@ ALTER TABLE "public"."accounts"
CREATE UNIQUE INDEX accounts_identity_key ON public.accounts USING btree (user_id, platform, (
CASE platform
WHEN 'youtube'::text THEN (DATA ->> 'channelId'::text)
- WHEN 'reddit'::text THEN (DATA ->> 'username'::text)
WHEN 'instagram'::text THEN (DATA ->> 'igUserId'::text)
ELSE NULL::text
END));