Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.
docs(database): open every migration and rollback with one plain sentence
spacesdrive1a53a7872e27
diff --git a/backend/tests/database/migrations.test.ts b/backend/tests/database/migrations.test.tsindex 345b103..94db344 100644--- a/backend/tests/database/migrations.test.ts+++ b/backend/tests/database/migrations.test.ts@@ -57,6 +57,17 @@ describe('database migrations', () => {}});+ test('every file opens with one plain sentence that says what it does', () => {+ for (const [folder, names] of [['migrations', migrations], ['rollbacks', rollbacks]] as const) {+ for (const name of names) {+ const [first, second = ''] = read(folder, name).split(/\r?\n/);+ assert.match(first, /^-- [a-z]\S*( \S+)+$/, `${folder}/${name} must open with "-- <what the file does>"`);+ assert.doesNotMatch(first, /\.\s/, `${folder}/${name}: keep the opening comment to one sentence`);+ assert.doesNotMatch(second, /^--/, `${folder}/${name}: keep the opening comment to one line`);+ }+ }+ });+test('no file uses an em or en dash', () => {for (const name of migrations) assert.doesNotMatch(read('migrations', name), /[–—]/, name);for (const name of rollbacks) assert.doesNotMatch(read('rollbacks', name), /[–—]/, name);diff --git a/supabase/migrations/20261016000000_baseline_accounts.sql b/supabase/migrations/20261016000000_baseline_accounts.sqlindex 6d4fb46..23b733e 100644--- a/supabase/migrations/20261016000000_baseline_accounts.sql+++ b/supabase/migrations/20261016000000_baseline_accounts.sql@@ -1,4 +1,4 @@--- the accounts table before versioned migrations; safe to repeat on a database that already has it+-- creates the accounts table as it was before migrations, and is safe to run again on a database that has itcreate table if not exists public.accounts (id text primary key,user_id uuid not null references auth.users (id) on delete cascade,diff --git a/supabase/migrations/20261016000100_baseline_settings.sql b/supabase/migrations/20261016000100_baseline_settings.sqlindex c4fbb58..39a205c 100644--- a/supabase/migrations/20261016000100_baseline_settings.sql+++ b/supabase/migrations/20261016000100_baseline_settings.sql@@ -1,4 +1,4 @@--- the settings table before versioned migrations; safe to repeat on a database that already has it+-- creates the settings table as it was before migrations, and is safe to run again on a database that has itcreate table if not exists public.settings (user_id uuid not null references auth.users (id) on delete cascade,key text not null,diff --git a/supabase/migrations/20261016000200_baseline_scheduled_posts.sql b/supabase/migrations/20261016000200_baseline_scheduled_posts.sqlindex 6b4d776..2cf42ff 100644--- a/supabase/migrations/20261016000200_baseline_scheduled_posts.sql+++ b/supabase/migrations/20261016000200_baseline_scheduled_posts.sql@@ -1,4 +1,4 @@--- the scheduled_posts table before versioned migrations; safe to repeat on a database that already has it+-- creates the scheduled_posts table as it was before migrations, and is safe to run again on a database that has itcreate table if not exists public.scheduled_posts (id text primary key,user_id uuid not null references auth.users (id) on delete cascade,diff --git a/supabase/migrations/20261016000300_baseline_tracked_posts.sql b/supabase/migrations/20261016000300_baseline_tracked_posts.sqlindex 688fd22..ff7acd1 100644--- a/supabase/migrations/20261016000300_baseline_tracked_posts.sql+++ b/supabase/migrations/20261016000300_baseline_tracked_posts.sql@@ -1,4 +1,4 @@--- the tracked_posts table before versioned migrations; safe to repeat on a database that already has it+-- creates the tracked_posts table as it was before migrations, and is safe to run again on a database that has itcreate table if not exists public.tracked_posts (id text primary key,user_id uuid not null references auth.users (id) on delete cascade,diff --git a/supabase/migrations/20261016000400_revoke_browser_access_accounts.sql b/supabase/migrations/20261016000400_revoke_browser_access_accounts.sqlindex e7a7bc9..af7d5c4 100644--- a/supabase/migrations/20261016000400_revoke_browser_access_accounts.sql+++ b/supabase/migrations/20261016000400_revoke_browser_access_accounts.sql@@ -1,3 +1,3 @@--- only the Worker's service role reads accounts; the anon key ships in every browser, so browser roles get nothing+-- removes all browser access to accounts, because only the Worker should read itdrop policy if exists users_own_accounts on public.accounts;revoke all on table public.accounts from anon, authenticated;diff --git a/supabase/migrations/20261016000500_revoke_browser_access_settings.sql b/supabase/migrations/20261016000500_revoke_browser_access_settings.sqlindex eb445cc..c266e5d 100644--- a/supabase/migrations/20261016000500_revoke_browser_access_settings.sql+++ b/supabase/migrations/20261016000500_revoke_browser_access_settings.sql@@ -1,3 +1,3 @@--- only the Worker's service role reads settings; the anon key ships in every browser, so browser roles get nothing+-- removes all browser access to settings, because only the Worker should read itdrop policy if exists users_own_settings on public.settings;revoke all on table public.settings from anon, authenticated;diff --git a/supabase/migrations/20261016000600_revoke_browser_access_scheduled_posts.sql b/supabase/migrations/20261016000600_revoke_browser_access_scheduled_posts.sqlindex bae2fb2..43d0bf6 100644--- a/supabase/migrations/20261016000600_revoke_browser_access_scheduled_posts.sql+++ b/supabase/migrations/20261016000600_revoke_browser_access_scheduled_posts.sql@@ -1,3 +1,3 @@--- only the Worker's service role reads scheduled_posts; the anon key ships in every browser, so browser roles get nothing+-- removes all browser access to scheduled_posts, because only the Worker should read itdrop policy if exists users_own_posts on public.scheduled_posts;revoke all on table public.scheduled_posts from anon, authenticated;diff --git a/supabase/migrations/20261016000700_revoke_browser_access_tracked_posts.sql b/supabase/migrations/20261016000700_revoke_browser_access_tracked_posts.sqlindex 091cd58..ab4b27b 100644--- a/supabase/migrations/20261016000700_revoke_browser_access_tracked_posts.sql+++ b/supabase/migrations/20261016000700_revoke_browser_access_tracked_posts.sql@@ -1,2 +1,2 @@--- only the Worker's service role reads tracked_posts; the anon key ships in every browser, so browser roles get nothing+-- removes all browser access to tracked_posts, because only the Worker should read itrevoke all on table public.tracked_posts from anon, authenticated;diff --git a/supabase/migrations/20261016000800_revoke_browser_default_privileges.sql b/supabase/migrations/20261016000800_revoke_browser_default_privileges.sqlindex a827fb7..816ecee 100644--- a/supabase/migrations/20261016000800_revoke_browser_default_privileges.sql+++ b/supabase/migrations/20261016000800_revoke_browser_default_privileges.sql@@ -1,3 +1,3 @@--- Supabase grants new tables and functions in public to the browser roles; later migrations start without that+-- stops new tables and functions from giving the browser roles access by defaultalter default privileges for role postgres in schema public revoke all on tables from anon, authenticated;alter default privileges for role postgres in schema public revoke all on functions from anon, authenticated;diff --git a/supabase/migrations/20261016000900_check_accounts_values.sql b/supabase/migrations/20261016000900_check_accounts_values.sqlindex fcdf4a7..be73bd5 100644--- a/supabase/migrations/20261016000900_check_accounts_values.sql+++ b/supabase/migrations/20261016000900_check_accounts_values.sql@@ -1,4 +1,4 @@--- an unknown platform or a data value that is not an object fails at the write instead of breaking a later read+-- only allows known platforms and a JSON object as data on accountsalter table public.accountsadd constraint accounts_platform_check check (platform in ('youtube', 'instagram', 'reddit')),add constraint accounts_data_check check (jsonb_typeof(data) = 'object');diff --git a/supabase/migrations/20261016001000_check_settings_values.sql b/supabase/migrations/20261016001000_check_settings_values.sqlindex ae1d525..c7cbace 100644--- a/supabase/migrations/20261016001000_check_settings_values.sql+++ b/supabase/migrations/20261016001000_check_settings_values.sql@@ -1,3 +1,3 @@--- every setting is stored as an object of named values+-- only allows a JSON object as the value of a settingalter table public.settingsadd constraint settings_value_check check (jsonb_typeof(value) = 'object');diff --git a/supabase/migrations/20261016001100_check_scheduled_posts_values.sql b/supabase/migrations/20261016001100_check_scheduled_posts_values.sqlindex 74b3ad3..84e5e81 100644--- a/supabase/migrations/20261016001100_check_scheduled_posts_values.sql+++ b/supabase/migrations/20261016001100_check_scheduled_posts_values.sql@@ -1,4 +1,4 @@--- the four statuses of the publishing lifecycle; anything else is a bug and fails at the write+-- only allows the four publishing statuses, valid attempts and claims, and a JSON object as data on scheduled postsalter table public.scheduled_postsadd constraint scheduled_posts_status_check check (status in ('pending', 'publishing', 'published', 'failed')),add constraint scheduled_posts_attempts_check check (attempts >= 0),diff --git a/supabase/migrations/20261016001200_check_tracked_posts_values.sql b/supabase/migrations/20261016001200_check_tracked_posts_values.sqlindex 2689c2a..3be3be9 100644--- a/supabase/migrations/20261016001200_check_tracked_posts_values.sql+++ b/supabase/migrations/20261016001200_check_tracked_posts_values.sql@@ -1,4 +1,4 @@--- tracked items are Reddit posts or YouTube videos+-- only allows Reddit posts and YouTube videos as tracked items, an account only on Reddit items, and a JSON object or nothing as dataalter table public.tracked_postsadd constraint tracked_posts_content_type_check check (content_type in ('reddit', 'youtube')),-- only Reddit items read through an account, for its cookiediff --git a/supabase/migrations/20261016001300_add_accounts_id_user_id_key.sql b/supabase/migrations/20261016001300_add_accounts_id_user_id_key.sqlindex a631192..b29b9d8 100644--- a/supabase/migrations/20261016001300_add_accounts_id_user_id_key.sql+++ b/supabase/migrations/20261016001300_add_accounts_id_user_id_key.sql@@ -1,2 +1,2 @@--- id alone is unique, so (id, user_id) is too; naming the pair lets a post reference an account with its owner+-- makes the pair of account id and owner unique, so other tables can point at an account together with its owneralter table public.accounts add constraint accounts_id_user_id_key unique (id, user_id);diff --git a/supabase/migrations/20261016001400_add_scheduled_posts_account_fkey.sql b/supabase/migrations/20261016001400_add_scheduled_posts_account_fkey.sqlindex 409aaa1..49170a8 100644--- a/supabase/migrations/20261016001400_add_scheduled_posts_account_fkey.sql+++ b/supabase/migrations/20261016001400_add_scheduled_posts_account_fkey.sql@@ -1,4 +1,4 @@--- a scheduled post can only name an account of the same user, and goes with that account when it is removed+-- makes a scheduled post point at an account of the same user, and removes the post with that accountalter table public.scheduled_posts drop constraint if exists scheduled_posts_account_id_fkey;alter table public.scheduled_postsadd constraint scheduled_posts_account_fkey foreign key (account_id, user_id)diff --git a/supabase/migrations/20261016001500_add_tracked_posts_account_fkey.sql b/supabase/migrations/20261016001500_add_tracked_posts_account_fkey.sqlindex 1e428ec..3c216ee 100644--- a/supabase/migrations/20261016001500_add_tracked_posts_account_fkey.sql+++ b/supabase/migrations/20261016001500_add_tracked_posts_account_fkey.sql@@ -1,4 +1,4 @@--- a tracked item can only read through the same user's account; removing the account keeps the item without one+-- makes a tracked item point at an account of the same user, and clears the account when it is removedalter table public.tracked_posts drop constraint if exists tracked_posts_account_id_fkey;alter table public.tracked_postsadd constraint tracked_posts_account_fkey foreign key (account_id, user_id)diff --git a/supabase/migrations/20261016001600_create_set_updated_at_function.sql b/supabase/migrations/20261016001600_create_set_updated_at_function.sqlindex 0ac5000..80815de 100644--- a/supabase/migrations/20261016001600_create_set_updated_at_function.sql+++ b/supabase/migrations/20261016001600_create_set_updated_at_function.sql@@ -1,4 +1,4 @@--- one trigger function keeps updated_at on every table, so no query has to remember to set it+-- creates the trigger function that sets updated_at on every updatecreate or replace function public.set_updated_at()returns triggerlanguage plpgsqldiff --git a/supabase/migrations/20261016001700_add_accounts_updated_at.sql b/supabase/migrations/20261016001700_add_accounts_updated_at.sqlindex 725c7fa..650495a 100644--- a/supabase/migrations/20261016001700_add_accounts_updated_at.sql+++ b/supabase/migrations/20261016001700_add_accounts_updated_at.sql@@ -1,3 +1,4 @@+-- adds updated_at to accounts with the trigger that keeps updated_at currentalter table public.accounts add column if not exists updated_at timestamptz not null default now();-- existing rows were last changed at an unknown time; their creation time is the closest honest valuediff --git a/supabase/migrations/20261016001800_add_settings_updated_at.sql b/supabase/migrations/20261016001800_add_settings_updated_at.sqlindex 121afa1..456e62f 100644--- a/supabase/migrations/20261016001800_add_settings_updated_at.sql+++ b/supabase/migrations/20261016001800_add_settings_updated_at.sql@@ -1,3 +1,4 @@+-- adds updated_at to settings with the trigger that keeps updated_at currentalter table public.settings add column if not exists updated_at timestamptz not null default now();-- existing rows were last changed at an unknown time; their creation time is the closest honest valuediff --git a/supabase/migrations/20261016001900_add_scheduled_posts_updated_at.sql b/supabase/migrations/20261016001900_add_scheduled_posts_updated_at.sqlindex 7d1ec85..d965245 100644--- a/supabase/migrations/20261016001900_add_scheduled_posts_updated_at.sql+++ b/supabase/migrations/20261016001900_add_scheduled_posts_updated_at.sql@@ -1,3 +1,4 @@+-- adds updated_at to scheduled_posts with the trigger that keeps updated_at currentalter table public.scheduled_posts add column if not exists updated_at timestamptz not null default now();-- existing rows were last changed at an unknown time; their creation time is the closest honest valuediff --git a/supabase/migrations/20261016002000_add_tracked_posts_updated_at_trigger.sql b/supabase/migrations/20261016002000_add_tracked_posts_updated_at_trigger.sqlindex 17b691e..11b5d7a 100644--- a/supabase/migrations/20261016002000_add_tracked_posts_updated_at_trigger.sql+++ b/supabase/migrations/20261016002000_add_tracked_posts_updated_at_trigger.sql@@ -1,3 +1,3 @@--- tracked_posts already had updated_at, set by the repository; the trigger takes that job over+-- adds the trigger that keeps updated_at current on tracked_posts, a job the code did beforecreate trigger tracked_posts_set_updated_at before update on public.tracked_postsfor each row execute function public.set_updated_at();diff --git a/supabase/migrations/20261016002100_create_merge_account_data_function.sql b/supabase/migrations/20261016002100_create_merge_account_data_function.sqlindex 8cf9a0f..3fe2aa7 100644--- a/supabase/migrations/20261016002100_create_merge_account_data_function.sql+++ b/supabase/migrations/20261016002100_create_merge_account_data_function.sql@@ -1,4 +1,4 @@--- merges a patch into data in one UPDATE, so two writers never undo each other; a null p_user_id is the cron form+-- creates merge_account_data, which merges changes into an account in one step so two writers never undo each othercreate or replace function public.merge_account_data(p_id text, p_user_id uuid, p_patch jsonb)returns booleanlanguage sqldiff --git a/supabase/migrations/20261016002200_create_merge_scheduled_post_function.sql b/supabase/migrations/20261016002200_create_merge_scheduled_post_function.sqlindex ca64d06..a3677e0 100644--- a/supabase/migrations/20261016002200_create_merge_scheduled_post_function.sql+++ b/supabase/migrations/20261016002200_create_merge_scheduled_post_function.sql@@ -1,4 +1,4 @@--- one UPDATE for status, time and a data patch; p_only_status keeps an edit off a post a scheduler has just claimed+-- creates merge_scheduled_post, which changes a scheduled post in one step and can refuse a post that is no longer pendingcreate or replace function public.merge_scheduled_post(p_id text,p_user_id uuid,diff --git a/supabase/migrations/20261016002300_create_merge_tracked_post_data_function.sql b/supabase/migrations/20261016002300_create_merge_tracked_post_data_function.sqlindex 1750dfb..870df85 100644--- a/supabase/migrations/20261016002300_create_merge_tracked_post_data_function.sql+++ b/supabase/migrations/20261016002300_create_merge_tracked_post_data_function.sql@@ -1,4 +1,4 @@--- merges a patch into data in one UPDATE, so a manual view count and a refresh at the same moment both survive+-- creates merge_tracked_post_data, which merges changes into a tracked item in one stepcreate or replace function public.merge_tracked_post_data(p_id text, p_user_id uuid, p_patch jsonb)returns booleanlanguage sqldiff --git a/supabase/migrations/20261016002400_index_accounts_list.sql b/supabase/migrations/20261016002400_index_accounts_list.sqlindex e1d7447..9ecc166 100644--- a/supabase/migrations/20261016002400_index_accounts_list.sql+++ b/supabase/migrations/20261016002400_index_accounts_list.sql@@ -1,2 +1,2 @@--- accounts.listForUser: where user_id = $1 order by created_at, id+-- adds an index that lists a user's accounts in the order they were addedcreate index if not exists accounts_user_id_created_at_idx on public.accounts (user_id, created_at, id);diff --git a/supabase/migrations/20261016002500_index_scheduled_posts_list.sql b/supabase/migrations/20261016002500_index_scheduled_posts_list.sqlindex 439b5ed..9ac1f9e 100644--- a/supabase/migrations/20261016002500_index_scheduled_posts_list.sql+++ b/supabase/migrations/20261016002500_index_scheduled_posts_list.sql@@ -1,3 +1,3 @@--- scheduledPosts.listForUser: where user_id = $1 order by scheduled_at; the counts behind delete all use it too+-- replaces the scheduled posts user index with one that also sorts by scheduled timecreate index if not exists scheduled_posts_user_id_scheduled_at_idx on public.scheduled_posts (user_id, scheduled_at);drop index if exists public.scheduled_posts_user_id_idx;diff --git a/supabase/migrations/20261016002600_index_scheduled_posts_schedulers.sql b/supabase/migrations/20261016002600_index_scheduled_posts_schedulers.sqlindex 72dffd2..2d809bc 100644--- a/supabase/migrations/20261016002600_index_scheduled_posts_schedulers.sql+++ b/supabase/migrations/20261016002600_index_scheduled_posts_schedulers.sql@@ -1,4 +1,4 @@--- the schedulers only read pending and publishing posts, so partial indexes leave out the growing published history+-- adds indexes that let the schedulers find due and stuck posts without reading published onesdrop index if exists public.scheduled_posts_due_idx;create index scheduled_posts_due_idx on public.scheduled_posts (scheduled_at) where status = 'pending';create index if not exists scheduled_posts_claimed_idx on public.scheduled_posts (claimed_at) where status = 'publishing';diff --git a/supabase/migrations/20261016002700_index_tracked_posts_list.sql b/supabase/migrations/20261016002700_index_tracked_posts_list.sqlindex feae405..579f9d8 100644--- a/supabase/migrations/20261016002700_index_tracked_posts_list.sql+++ b/supabase/migrations/20261016002700_index_tracked_posts_list.sql@@ -1,3 +1,3 @@--- trackedPosts.listForUser: where user_id = $1 order by created_at desc+-- replaces the tracked items user index with one that also sorts by newest firstcreate index if not exists tracked_posts_user_id_created_at_idx on public.tracked_posts (user_id, created_at desc);drop index if exists public.tracked_posts_user_id_idx;diff --git a/supabase/migrations/20261016100000_create_automation_accounts.sql b/supabase/migrations/20261016100000_create_automation_accounts.sqlindex 94c3897..ea77f99 100644--- a/supabase/migrations/20261016100000_create_automation_accounts.sql+++ b/supabase/migrations/20261016100000_create_automation_accounts.sql@@ -1,4 +1,4 @@--- per Instagram account automation controls: the owner's pause, a cooldown after Instagram limits, and the webhook subscription+-- creates automation_accounts, which holds each Instagram account's pause, cooldowns and webhook subscriptioncreate table public.automation_accounts (account_id text primary key,user_id uuid not null references auth.users (id) on delete cascade,diff --git a/supabase/migrations/20261016100100_revoke_browser_access_automation_accounts.sql b/supabase/migrations/20261016100100_revoke_browser_access_automation_accounts.sqlindex 9543085..259173e 100644--- a/supabase/migrations/20261016100100_revoke_browser_access_automation_accounts.sql+++ b/supabase/migrations/20261016100100_revoke_browser_access_automation_accounts.sql@@ -1,3 +1,3 @@--- only the Worker's service role reads automation_accounts; the anon key ships in every browser+-- turns on row level security and removes browser access to automation_accountsalter table public.automation_accounts enable row level security;revoke all on table public.automation_accounts from anon, authenticated;diff --git a/supabase/migrations/20261016100200_add_automation_accounts_updated_at_trigger.sql b/supabase/migrations/20261016100200_add_automation_accounts_updated_at_trigger.sqlindex 0509f21..577e8ee 100644--- a/supabase/migrations/20261016100200_add_automation_accounts_updated_at_trigger.sql+++ b/supabase/migrations/20261016100200_add_automation_accounts_updated_at_trigger.sql@@ -1,3 +1,3 @@--- set_updated_at() keeps updated_at, so no query has to set it+-- adds the trigger that keeps updated_at current on automation_accountscreate trigger automation_accounts_set_updated_at before update on public.automation_accountsfor each row execute function public.set_updated_at();diff --git a/supabase/migrations/20261016100300_create_automation_rules.sql b/supabase/migrations/20261016100300_create_automation_rules.sqlindex 53d0151..9ac5823 100644--- a/supabase/migrations/20261016100300_create_automation_rules.sql+++ b/supabase/migrations/20261016100300_create_automation_rules.sql@@ -1,4 +1,4 @@--- keyword rules that answer a comment with a private reply+-- creates automation_rules, which holds the rules that answer Instagram commentscreate table public.automation_rules (id text primary key,user_id uuid not null references auth.users (id) on delete cascade,diff --git a/supabase/migrations/20261016100400_revoke_browser_access_automation_rules.sql b/supabase/migrations/20261016100400_revoke_browser_access_automation_rules.sqlindex fec75e5..518778a 100644--- a/supabase/migrations/20261016100400_revoke_browser_access_automation_rules.sql+++ b/supabase/migrations/20261016100400_revoke_browser_access_automation_rules.sql@@ -1,3 +1,3 @@--- only the Worker's service role reads automation_rules; the anon key ships in every browser+-- turns on row level security and removes browser access to automation_rulesalter table public.automation_rules enable row level security;revoke all on table public.automation_rules from anon, authenticated;diff --git a/supabase/migrations/20261016100500_add_automation_rules_updated_at_trigger.sql b/supabase/migrations/20261016100500_add_automation_rules_updated_at_trigger.sqlindex e4e266c..c6c70b5 100644--- a/supabase/migrations/20261016100500_add_automation_rules_updated_at_trigger.sql+++ b/supabase/migrations/20261016100500_add_automation_rules_updated_at_trigger.sql@@ -1,3 +1,3 @@--- set_updated_at() keeps updated_at, so no query has to set it+-- adds the trigger that keeps updated_at current on automation_rulescreate trigger automation_rules_set_updated_at before update on public.automation_rulesfor each row execute function public.set_updated_at();diff --git a/supabase/migrations/20261016100600_index_automation_rules_user_id_created_at.sql b/supabase/migrations/20261016100600_index_automation_rules_user_id_created_at.sqlindex 8f0f6ab..39014d0 100644--- a/supabase/migrations/20261016100600_index_automation_rules_user_id_created_at.sql+++ b/supabase/migrations/20261016100600_index_automation_rules_user_id_created_at.sql@@ -1,2 +1,2 @@--- automationRules.listForUser: where user_id = $1 order by created_at, id+-- adds an index that lists a user's rules in the order they were madecreate index automation_rules_user_id_created_at_idx on public.automation_rules (user_id, created_at, id);diff --git a/supabase/migrations/20261016100700_index_automation_rules_enabled_account.sql b/supabase/migrations/20261016100700_index_automation_rules_enabled_account.sqlindex 66d6427..0878206 100644--- a/supabase/migrations/20261016100700_index_automation_rules_enabled_account.sql+++ b/supabase/migrations/20261016100700_index_automation_rules_enabled_account.sql@@ -1,2 +1,2 @@--- the webhook reads only the enabled rules of an account+-- adds an index that finds an account's enabled rules when a comment arrivescreate index automation_rules_enabled_account_idx on public.automation_rules (account_id) where enabled;diff --git a/supabase/migrations/20261016100800_create_automation_comments.sql b/supabase/migrations/20261016100800_create_automation_comments.sqlindex aa022f5..a17d4e7 100644--- a/supabase/migrations/20261016100800_create_automation_comments.sql+++ b/supabase/migrations/20261016100800_create_automation_comments.sql@@ -1,4 +1,4 @@--- every comment the webhook delivered for an account with an enabled rule; a matched comment is also the job that sends its reply+-- creates automation_comments, which stores each comment the webhook receives and is also the queue of private repliescreate table public.automation_comments (id text primary key,user_id uuid not null references auth.users (id) on delete cascade,diff --git a/supabase/migrations/20261016100900_revoke_browser_access_automation_comments.sql b/supabase/migrations/20261016100900_revoke_browser_access_automation_comments.sqlindex 4ea7344..a3bc2fe 100644--- a/supabase/migrations/20261016100900_revoke_browser_access_automation_comments.sql+++ b/supabase/migrations/20261016100900_revoke_browser_access_automation_comments.sql@@ -1,3 +1,3 @@--- only the Worker's service role reads automation_comments; the anon key ships in every browser+-- turns on row level security and removes browser access to automation_commentsalter table public.automation_comments enable row level security;revoke all on table public.automation_comments from anon, authenticated;diff --git a/supabase/migrations/20261016101000_add_automation_comments_updated_at_trigger.sql b/supabase/migrations/20261016101000_add_automation_comments_updated_at_trigger.sqlindex c872e1b..7fad27a 100644--- a/supabase/migrations/20261016101000_add_automation_comments_updated_at_trigger.sql+++ b/supabase/migrations/20261016101000_add_automation_comments_updated_at_trigger.sql@@ -1,3 +1,3 @@--- set_updated_at() keeps updated_at, so no query has to set it+-- adds the trigger that keeps updated_at current on automation_commentscreate trigger automation_comments_set_updated_at before update on public.automation_commentsfor each row execute function public.set_updated_at();diff --git a/supabase/migrations/20261016101100_index_automation_comments_due.sql b/supabase/migrations/20261016101100_index_automation_comments_due.sqlindex 4958c1c..34cbaa2 100644--- a/supabase/migrations/20261016101100_index_automation_comments_due.sql+++ b/supabase/migrations/20261016101100_index_automation_comments_due.sql@@ -1,2 +1,2 @@--- claim_automation_comments: jobs that are due, oldest first; partial, so the history is left out+-- adds an index that finds replies waiting to be sent, without reading old commentscreate index automation_comments_due_idx on public.automation_comments (next_attempt_at) where status in ('queued', 'retry_wait');diff --git a/supabase/migrations/20261016101200_index_automation_comments_claimed.sql b/supabase/migrations/20261016101200_index_automation_comments_claimed.sqlindex 2819bd2..7812468 100644--- a/supabase/migrations/20261016101200_index_automation_comments_claimed.sql+++ b/supabase/migrations/20261016101200_index_automation_comments_claimed.sql@@ -1,2 +1,2 @@--- claim_automation_comments: jobs whose run stopped holding them+-- adds an index that finds replies held by a run that stoppedcreate index automation_comments_claimed_idx on public.automation_comments (claimed_at) where status in ('processing', 'sending');diff --git a/supabase/migrations/20261016101300_index_automation_comments_user_id_created_at.sql b/supabase/migrations/20261016101300_index_automation_comments_user_id_created_at.sqlindex f10ee66..24f94c0 100644--- a/supabase/migrations/20261016101300_index_automation_comments_user_id_created_at.sql+++ b/supabase/migrations/20261016101300_index_automation_comments_user_id_created_at.sql@@ -1,2 +1,2 @@--- automationComments.listForUser and automation_stats: where user_id = $1 order by created_at desc+-- adds an index that lists a user's comments newest firstcreate index automation_comments_user_id_created_at_idx on public.automation_comments (user_id, created_at desc);diff --git a/supabase/migrations/20261016101400_index_automation_comments_rule_id.sql b/supabase/migrations/20261016101400_index_automation_comments_rule_id.sqlindex e325e1d..21ddd19 100644--- a/supabase/migrations/20261016101400_index_automation_comments_rule_id.sql+++ b/supabase/migrations/20261016101400_index_automation_comments_rule_id.sql@@ -1,2 +1,2 @@--- removing a rule clears rule_id on its comments, and stats filter by rule+-- adds an index that finds the comments of one rulecreate index automation_comments_rule_id_idx on public.automation_comments (rule_id) where rule_id is not null;diff --git a/supabase/migrations/20261016101500_index_automation_comments_created_at.sql b/supabase/migrations/20261016101500_index_automation_comments_created_at.sqlindex e0350a0..ee60a7f 100644--- a/supabase/migrations/20261016101500_index_automation_comments_created_at.sql+++ b/supabase/migrations/20261016101500_index_automation_comments_created_at.sql@@ -1,2 +1,2 @@--- the daily retention delete across all users+-- adds an index that finds the oldest comments for the daily clean-upcreate index automation_comments_created_at_idx on public.automation_comments (created_at);diff --git a/supabase/migrations/20261016101600_create_automation_attempts.sql b/supabase/migrations/20261016101600_create_automation_attempts.sqlindex a2390da..698e79a 100644--- a/supabase/migrations/20261016101600_create_automation_attempts.sql+++ b/supabase/migrations/20261016101600_create_automation_attempts.sql@@ -1,4 +1,4 @@--- one row per private reply request sent to Instagram, which is what the sending limits count+-- creates automation_attempts, which records every request sent to Instagram so the sending limits can count themcreate table public.automation_attempts (id text primary key,user_id uuid not null references auth.users (id) on delete cascade,diff --git a/supabase/migrations/20261016101700_revoke_browser_access_automation_attempts.sql b/supabase/migrations/20261016101700_revoke_browser_access_automation_attempts.sqlindex da3e8c5..7587f48 100644--- a/supabase/migrations/20261016101700_revoke_browser_access_automation_attempts.sql+++ b/supabase/migrations/20261016101700_revoke_browser_access_automation_attempts.sql@@ -1,3 +1,3 @@--- only the Worker's service role reads automation_attempts; the anon key ships in every browser+-- turns on row level security and removes browser access to automation_attemptsalter table public.automation_attempts enable row level security;revoke all on table public.automation_attempts from anon, authenticated;diff --git a/supabase/migrations/20261016101800_add_automation_attempts_updated_at_trigger.sql b/supabase/migrations/20261016101800_add_automation_attempts_updated_at_trigger.sqlindex bc463a2..12b8e72 100644--- a/supabase/migrations/20261016101800_add_automation_attempts_updated_at_trigger.sql+++ b/supabase/migrations/20261016101800_add_automation_attempts_updated_at_trigger.sql@@ -1,3 +1,3 @@--- set_updated_at() keeps updated_at, so no query has to set it+-- adds the trigger that keeps updated_at current on automation_attemptscreate trigger automation_attempts_set_updated_at before update on public.automation_attemptsfor each row execute function public.set_updated_at();diff --git a/supabase/migrations/20261016101900_index_automation_attempts_started_at.sql b/supabase/migrations/20261016101900_index_automation_attempts_started_at.sqlindex 68e0eb4..a051818 100644--- a/supabase/migrations/20261016101900_index_automation_attempts_started_at.sql+++ b/supabase/migrations/20261016101900_index_automation_attempts_started_at.sql@@ -1,2 +1,2 @@--- reserve_automation_send: sends in the last hour across the instance+-- adds an index that counts the instance's sends in the last hourcreate index automation_attempts_started_at_idx on public.automation_attempts (started_at);diff --git a/supabase/migrations/20261016102000_index_automation_attempts_user_id_started_at.sql b/supabase/migrations/20261016102000_index_automation_attempts_user_id_started_at.sqlindex 0e28c82..be99c78 100644--- a/supabase/migrations/20261016102000_index_automation_attempts_user_id_started_at.sql+++ b/supabase/migrations/20261016102000_index_automation_attempts_user_id_started_at.sql@@ -1,2 +1,2 @@--- reserve_automation_send: sends in the last hour for one member+-- adds an index that counts one user's sends in the last hourcreate index automation_attempts_user_id_started_at_idx on public.automation_attempts (user_id, started_at);diff --git a/supabase/migrations/20261016102100_index_automation_attempts_account_id_started_at.sql b/supabase/migrations/20261016102100_index_automation_attempts_account_id_started_at.sqlindex 6a69b22..c51281c 100644--- a/supabase/migrations/20261016102100_index_automation_attempts_account_id_started_at.sql+++ b/supabase/migrations/20261016102100_index_automation_attempts_account_id_started_at.sql@@ -1,2 +1,2 @@--- reserve_automation_send: sends in the last hour for one Instagram account+-- adds an index that counts one Instagram account's sends in the last hourcreate index automation_attempts_account_id_started_at_idx on public.automation_attempts (account_id, started_at);diff --git a/supabase/migrations/20261016102200_index_automation_attempts_rule_id_started_at.sql b/supabase/migrations/20261016102200_index_automation_attempts_rule_id_started_at.sqlindex 2e97fde..bd7b3e9 100644--- a/supabase/migrations/20261016102200_index_automation_attempts_rule_id_started_at.sql+++ b/supabase/migrations/20261016102200_index_automation_attempts_rule_id_started_at.sql@@ -1,2 +1,2 @@--- reserve_automation_send: sends in the last hour for one rule+-- adds an index that counts one rule's sends in the last hourcreate index automation_attempts_rule_id_started_at_idx on public.automation_attempts (rule_id, started_at) where rule_id is not null;diff --git a/supabase/migrations/20261016102300_index_automation_attempts_recipient.sql b/supabase/migrations/20261016102300_index_automation_attempts_recipient.sqlindex 63857fa..df76069 100644--- a/supabase/migrations/20261016102300_index_automation_attempts_recipient.sql+++ b/supabase/migrations/20261016102300_index_automation_attempts_recipient.sql@@ -1,2 +1,2 @@--- reserve_automation_send: replies to one person from one account in the last day+-- adds an index that counts the replies one person got from one account in the last daycreate index automation_attempts_recipient_idx on public.automation_attempts (account_id, recipient_id, started_at);diff --git a/supabase/migrations/20261016102400_index_automation_attempts_comment.sql b/supabase/migrations/20261016102400_index_automation_attempts_comment.sqlindex 9f92a40..c62f878 100644--- a/supabase/migrations/20261016102400_index_automation_attempts_comment.sql+++ b/supabase/migrations/20261016102400_index_automation_attempts_comment.sql@@ -1,2 +1,2 @@--- finish_automation_send and the claim close the attempts of one comment; the cascade from a comment+-- adds an index that finds the attempts of one commentcreate index automation_attempts_comment_idx on public.automation_attempts (automation_comment_id);diff --git a/supabase/migrations/20261016102500_create_audit_events.sql b/supabase/migrations/20261016102500_create_audit_events.sqlindex f2c4173..3564652 100644--- a/supabase/migrations/20261016102500_create_audit_events.sql+++ b/supabase/migrations/20261016102500_create_audit_events.sql@@ -1,4 +1,4 @@--- who connected, removed or changed what; rows outlive the account they describe, and go with the user+-- creates audit_events, which records who connected, removed or changed whatcreate table public.audit_events (id text primary key,user_id uuid not null references auth.users (id) on delete cascade,diff --git a/supabase/migrations/20261016102600_revoke_browser_access_audit_events.sql b/supabase/migrations/20261016102600_revoke_browser_access_audit_events.sqlindex 8bbb742..ffdd400 100644--- a/supabase/migrations/20261016102600_revoke_browser_access_audit_events.sql+++ b/supabase/migrations/20261016102600_revoke_browser_access_audit_events.sql@@ -1,3 +1,3 @@--- only the Worker's service role reads audit_events; the anon key ships in every browser+-- turns on row level security and removes browser access to audit_eventsalter table public.audit_events enable row level security;revoke all on table public.audit_events from anon, authenticated;diff --git a/supabase/migrations/20261016102700_add_audit_events_updated_at_trigger.sql b/supabase/migrations/20261016102700_add_audit_events_updated_at_trigger.sqlindex 2f7cc48..c1eca59 100644--- a/supabase/migrations/20261016102700_add_audit_events_updated_at_trigger.sql+++ b/supabase/migrations/20261016102700_add_audit_events_updated_at_trigger.sql@@ -1,3 +1,3 @@--- set_updated_at() keeps updated_at, so no query has to set it+-- adds the trigger that keeps updated_at current on audit_eventscreate trigger audit_events_set_updated_at before update on public.audit_eventsfor each row execute function public.set_updated_at();diff --git a/supabase/migrations/20261016102800_index_audit_events_user_id_created_at.sql b/supabase/migrations/20261016102800_index_audit_events_user_id_created_at.sqlindex 86855db..f4e3fd5 100644--- a/supabase/migrations/20261016102800_index_audit_events_user_id_created_at.sql+++ b/supabase/migrations/20261016102800_index_audit_events_user_id_created_at.sql@@ -1,2 +1,2 @@--- auditEvents.listForUser: where user_id = $1 order by created_at desc+-- adds an index that lists a user's audit events newest firstcreate index audit_events_user_id_created_at_idx on public.audit_events (user_id, created_at desc);diff --git a/supabase/migrations/20261016102900_index_audit_events_created_at.sql b/supabase/migrations/20261016102900_index_audit_events_created_at.sqlindex f00688d..fcec86e 100644--- a/supabase/migrations/20261016102900_index_audit_events_created_at.sql+++ b/supabase/migrations/20261016102900_index_audit_events_created_at.sql@@ -1,2 +1,2 @@--- the daily retention delete across all users+-- adds an index that finds the oldest audit events for the daily clean-upcreate index audit_events_created_at_idx on public.audit_events (created_at);diff --git a/supabase/migrations/20261016103000_index_accounts_instagram_user.sql b/supabase/migrations/20261016103000_index_accounts_instagram_user.sqlindex 9972da0..bfefbae 100644--- a/supabase/migrations/20261016103000_index_accounts_instagram_user.sql+++ b/supabase/migrations/20261016103000_index_accounts_instagram_user.sql@@ -1,2 +1,2 @@--- a webhook names the Instagram account by its id, which lives in data, so the lookup needs its own index+-- adds an index that finds an account by its Instagram id when a webhook arrivescreate index if not exists accounts_instagram_user_idx on public.accounts ((data ->> 'igUserId')) where platform = 'instagram';diff --git a/supabase/migrations/20261016103100_create_automation_rules_for_ig_user_function.sql b/supabase/migrations/20261016103100_create_automation_rules_for_ig_user_function.sqlindex 2fba753..6f08d36 100644--- a/supabase/migrations/20261016103100_create_automation_rules_for_ig_user_function.sql+++ b/supabase/migrations/20261016103100_create_automation_rules_for_ig_user_function.sql@@ -1,4 +1,4 @@--- the enabled rules of every connected account a webhook's Instagram account id belongs to, oldest account first+-- creates automation_rules_for_ig_user, which returns the enabled rules for the Instagram account a webhook namescreate or replace function public.automation_rules_for_ig_user(p_ig_user_id text)returns table (id text,diff --git a/supabase/migrations/20261016103200_create_claim_automation_comments_function.sql b/supabase/migrations/20261016103200_create_claim_automation_comments_function.sqlindex 37128d1..01fa3d1 100644--- a/supabase/migrations/20261016103200_create_claim_automation_comments_function.sql+++ b/supabase/migrations/20261016103200_create_claim_automation_comments_function.sql@@ -1,5 +1,4 @@--- hands one run the due reply jobs, at most p_per_account per account so a busy account cannot hold back the others;--- p_ids limits it to the comments a webhook has just stored+-- creates claim_automation_comments, which hands a run the private replies that are due to be sentcreate or replace function public.claim_automation_comments(p_limit integer,p_per_account integer,diff --git a/supabase/migrations/20261016103300_create_reserve_automation_send_function.sql b/supabase/migrations/20261016103300_create_reserve_automation_send_function.sqlindex 591d930..3b51920 100644--- a/supabase/migrations/20261016103300_create_reserve_automation_send_function.sql+++ b/supabase/migrations/20261016103300_create_reserve_automation_send_function.sql@@ -1,5 +1,4 @@--- decides whether a claimed job may send now and, when it may, records the attempt before the request leaves;--- answers ok, gone, paused, cooldown, recipient_limit, or the full scope (rule_limit, account_limit, user_limit, global_limit)+-- creates reserve_automation_send, which checks the limits and records an attempt before a private reply is sentcreate or replace function public.reserve_automation_send(p_id text,p_attempt_id text,diff --git a/supabase/migrations/20261016103400_create_finish_automation_send_function.sql b/supabase/migrations/20261016103400_create_finish_automation_send_function.sqlindex 97361f6..d0c49ab 100644--- a/supabase/migrations/20261016103400_create_finish_automation_send_function.sql+++ b/supabase/migrations/20261016103400_create_finish_automation_send_function.sql@@ -1,5 +1,4 @@--- records what Instagram answered in one transaction: the attempt, the comment's new state, and a cooldown or a hold--- for the account; a reply that comes back after its run was marked interrupted still lands, because the answer is better than a guess+-- creates finish_automation_send, which saves what Instagram answered to a private replycreate or replace function public.finish_automation_send(p_id text,p_attempt_id text,diff --git a/supabase/migrations/20261016103500_create_automation_stats_function.sql b/supabase/migrations/20261016103500_create_automation_stats_function.sqlindex 2d2ab34..f58822e 100644--- a/supabase/migrations/20261016103500_create_automation_stats_function.sql+++ b/supabase/migrations/20261016103500_create_automation_stats_function.sql@@ -1,5 +1,4 @@--- one user's comment counts by status and request counts by outcome for a period, counted in the database--- instead of loading every row; p_account_id and p_rule_id narrow it when set+-- creates automation_stats, which counts a user's comments and requests for a periodcreate or replace function public.automation_stats(p_user_id uuid,p_from timestamptz,diff --git a/supabase/migrations/20261016120000_alter_automation_rules_match_options.sql b/supabase/migrations/20261016120000_alter_automation_rules_match_options.sqlindex 2245da8..e430732 100644--- a/supabase/migrations/20261016120000_alter_automation_rules_match_options.sql+++ b/supabase/migrations/20261016120000_alter_automation_rules_match_options.sql@@ -1,5 +1,4 @@--- rules that answer any comment, and the followers-only option: the private reply asks the person to follow and--- reply, because Instagram reports whether someone follows the account only after they have messaged it+-- adds rules that answer any comment and the followers-only option to automation_rulesalter table public.automation_rulesdrop constraint automation_rules_match_mode_check,drop constraint automation_rules_keywords_check,diff --git a/supabase/migrations/20261016120100_alter_automation_comments_followup_review.sql b/supabase/migrations/20261016120100_alter_automation_comments_followup_review.sqlindex a34b2f5..bea3d05 100644--- a/supabase/migrations/20261016120100_alter_automation_comments_followup_review.sql+++ b/supabase/migrations/20261016120100_alter_automation_comments_followup_review.sql@@ -1,3 +1,4 @@+-- adds the followers-only wait and the review checks to automation_commentsalter table public.automation_comments-- the person Instagram says received the private reply, so their answer can be matched to this commentadd column recipient_id text,diff --git a/supabase/migrations/20261016120200_alter_automation_accounts_limit_fields.sql b/supabase/migrations/20261016120200_alter_automation_accounts_limit_fields.sqlindex 10b5e9b..8714277 100644--- a/supabase/migrations/20261016120200_alter_automation_accounts_limit_fields.sql+++ b/supabase/migrations/20261016120200_alter_automation_accounts_limit_fields.sql@@ -1,3 +1,4 @@+-- adds the hourly limit marker and the confirmed webhook fields to automation_accountsalter table public.automation_accounts-- set when the account reached its hourly reply limit, so runs leave its jobs alone until a send frees upadd column limited_until timestamptz,diff --git a/supabase/migrations/20261016120300_create_automation_followups.sql b/supabase/migrations/20261016120300_create_automation_followups.sqlindex 8f29042..1b3f883 100644--- a/supabase/migrations/20261016120300_create_automation_followups.sql+++ b/supabase/migrations/20261016120300_create_automation_followups.sql@@ -1,5 +1,4 @@--- a message sent after a person answered a followers-only private reply: the reply and link once Instagram says they--- follow the account, a reminder to follow otherwise+-- creates automation_followups, which holds the message sent after someone answers a followers-only replycreate table public.automation_followups (id text primary key,user_id uuid not null references auth.users (id) on delete cascade,diff --git a/supabase/migrations/20261016120400_revoke_browser_access_automation_followups.sql b/supabase/migrations/20261016120400_revoke_browser_access_automation_followups.sqlindex 8e606c0..2d2e7d9 100644--- a/supabase/migrations/20261016120400_revoke_browser_access_automation_followups.sql+++ b/supabase/migrations/20261016120400_revoke_browser_access_automation_followups.sql@@ -1,3 +1,3 @@--- only the Worker's service role reads automation_followups; the anon key ships in every browser+-- turns on row level security and removes browser access to automation_followupsalter table public.automation_followups enable row level security;revoke all on table public.automation_followups from anon, authenticated;diff --git a/supabase/migrations/20261016120500_add_automation_followups_updated_at_trigger.sql b/supabase/migrations/20261016120500_add_automation_followups_updated_at_trigger.sqlindex 6ed3aab..86fd9ac 100644--- a/supabase/migrations/20261016120500_add_automation_followups_updated_at_trigger.sql+++ b/supabase/migrations/20261016120500_add_automation_followups_updated_at_trigger.sql@@ -1,3 +1,3 @@--- set_updated_at() keeps updated_at, so no query has to set it+-- adds the trigger that keeps updated_at current on automation_followupscreate trigger automation_followups_set_updated_at before update on public.automation_followupsfor each row execute function public.set_updated_at();diff --git a/supabase/migrations/20261016120600_index_automation_followups_due.sql b/supabase/migrations/20261016120600_index_automation_followups_due.sqlindex af4affa..981b05b 100644--- a/supabase/migrations/20261016120600_index_automation_followups_due.sql+++ b/supabase/migrations/20261016120600_index_automation_followups_due.sql@@ -1,2 +1,2 @@--- claim_automation_followups and the expiry: each account's follow-ups waiting to go out; partial, so the history is left out+-- adds an index that finds each account's follow-ups waiting to be sentcreate index automation_followups_due_idx on public.automation_followups (account_id, next_attempt_at) where status in ('queued', 'retry_wait');diff --git a/supabase/migrations/20261016120700_index_automation_followups_claimed.sql b/supabase/migrations/20261016120700_index_automation_followups_claimed.sqlindex 19f9a6a..d56a90c 100644--- a/supabase/migrations/20261016120700_index_automation_followups_claimed.sql+++ b/supabase/migrations/20261016120700_index_automation_followups_claimed.sql@@ -1,2 +1,2 @@--- claim_automation_followups: follow-ups whose run stopped holding them+-- adds an index that finds follow-ups held by a run that stoppedcreate index automation_followups_claimed_idx on public.automation_followups (claimed_at) where status in ('processing', 'sending');diff --git a/supabase/migrations/20261016120800_index_automation_followups_open_comment.sql b/supabase/migrations/20261016120800_index_automation_followups_open_comment.sqlindex eebed1d..e24b9bd 100644--- a/supabase/migrations/20261016120800_index_automation_followups_open_comment.sql+++ b/supabase/migrations/20261016120800_index_automation_followups_open_comment.sql@@ -1,3 +1,3 @@--- one open follow-up per comment, so several messages from one person get one answer+-- allows only one open follow-up per comment, so several messages from one person get one answercreate unique index automation_followups_open_comment_key on public.automation_followups (automation_comment_id)where status in ('queued', 'processing', 'retry_wait', 'sending');diff --git a/supabase/migrations/20261016120900_index_automation_followups_comment_id.sql b/supabase/migrations/20261016120900_index_automation_followups_comment_id.sqlindex 7222737..1044ffa 100644--- a/supabase/migrations/20261016120900_index_automation_followups_comment_id.sql+++ b/supabase/migrations/20261016120900_index_automation_followups_comment_id.sql@@ -1,2 +1,2 @@--- deleting a comment removes its follow-ups, and the activity list shows the latest one+-- adds an index that finds the follow-ups of one commentcreate index automation_followups_comment_id_idx on public.automation_followups (automation_comment_id, created_at);diff --git a/supabase/migrations/20261016121000_alter_automation_attempts_kind_digest.sql b/supabase/migrations/20261016121000_alter_automation_attempts_kind_digest.sqlindex cb0d876..e395340 100644--- a/supabase/migrations/20261016121000_alter_automation_attempts_kind_digest.sql+++ b/supabase/migrations/20261016121000_alter_automation_attempts_kind_digest.sql@@ -1,3 +1,4 @@+-- adds the attempt kind, the follow-up link and a digest of the text sent to automation_attemptsalter table public.automation_attempts-- private replies count against Instagram's 750 an hour per account; follow-ups go through the Send API insteadadd column kind text not null default 'private_reply',diff --git a/supabase/migrations/20261016121100_index_automation_comments_due_by_account.sql b/supabase/migrations/20261016121100_index_automation_comments_due_by_account.sqlindex 9c8b66d..3462e52 100644--- a/supabase/migrations/20261016121100_index_automation_comments_due_by_account.sql+++ b/supabase/migrations/20261016121100_index_automation_comments_due_by_account.sql@@ -1,2 +1,2 @@--- claim_automation_comments: each account's oldest due jobs, so accounts take turns however long one queue is+-- adds an index that finds each account's oldest due replies, so accounts can take turnscreate index automation_comments_due_account_idx on public.automation_comments (account_id, next_attempt_at) where status in ('queued', 'retry_wait');diff --git a/supabase/migrations/20261016121200_index_automation_comments_awaiting_reply.sql b/supabase/migrations/20261016121200_index_automation_comments_awaiting_reply.sqlindex 99190df..84b8b62 100644--- a/supabase/migrations/20261016121200_index_automation_comments_awaiting_reply.sql+++ b/supabase/migrations/20261016121200_index_automation_comments_awaiting_reply.sql@@ -1,2 +1,2 @@--- automation_followups_for_messages: a sender's comments that wait for their reply; partial, so it stays small+-- adds an index that finds the followers-only replies waiting for a person's answercreate index automation_comments_awaiting_reply_idx on public.automation_comments (ig_user_id, recipient_id, accepted_at) where gate_status = 'awaiting_reply';diff --git a/supabase/migrations/20261016121300_index_automation_comments_needs_review.sql b/supabase/migrations/20261016121300_index_automation_comments_needs_review.sqlindex 4f55c4e..4d0e1ca 100644--- a/supabase/migrations/20261016121300_index_automation_comments_needs_review.sql+++ b/supabase/migrations/20261016121300_index_automation_comments_needs_review.sql@@ -1,2 +1,2 @@--- automation_review_candidates and the queue health: replies a person may need to check, without scanning the history+-- adds an index that finds replies whose outcome is unknowncreate index automation_comments_needs_review_idx on public.automation_comments (review_checked_at nulls first, updated_at) where status = 'needs_review';diff --git a/supabase/migrations/20261016121400_replace_claim_automation_comments_function.sql b/supabase/migrations/20261016121400_replace_claim_automation_comments_function.sqlindex 4dab75e..b74e96c 100644--- a/supabase/migrations/20261016121400_replace_claim_automation_comments_function.sql+++ b/supabase/migrations/20261016121400_replace_claim_automation_comments_function.sql@@ -1,8 +1,4 @@--- hands one run the due reply jobs with accounts taking turns: each account's oldest job first, then each one's second,--- so a busy account cannot hold back the others and an account alone can fill the batch. Accounts that are paused,--- cooling down or at their hourly limit are left out, so their jobs wait in place instead of being claimed and put--- back on every run; p_ids limits it to the comments a webhook has just stored. The return gains the rule's--- followers-only fields, and the Worker deployed before this change reads the columns it knows+-- replaces claim_automation_comments so accounts take turns and paused, cooling or limited accounts are skippeddrop function if exists public.claim_automation_comments(integer, integer, integer, text[]);create or replace function public.claim_automation_comments(p_limit integer,diff --git a/supabase/migrations/20261016121500_replace_reserve_automation_send_function.sql b/supabase/migrations/20261016121500_replace_reserve_automation_send_function.sqlindex 6f0e089..75e06ce 100644--- a/supabase/migrations/20261016121500_replace_reserve_automation_send_function.sql+++ b/supabase/migrations/20261016121500_replace_reserve_automation_send_function.sql@@ -1,8 +1,4 @@--- decides whether a claimed job may send now and, when it may, records the attempt before the request leaves;--- answers ok, gone, paused, cooldown, recipient_limit, or the full scope (rule_limit, account_limit, user_limit,--- global_limit). Only private replies count, since follow-ups use a different Instagram limit; a full account is--- marked until a send frees up so runs stop claiming its jobs; p_message_digest lets a lost answer be checked later.--- The new parameter has a default, so the Worker deployed before this change still calls it+-- replaces reserve_automation_send so it counts private replies only and marks an account that reached its limitdrop function if exists public.reserve_automation_send(text, text, integer, integer, integer, integer);create or replace function public.reserve_automation_send(p_id text,diff --git a/supabase/migrations/20261016121600_replace_finish_automation_send_function.sql b/supabase/migrations/20261016121600_replace_finish_automation_send_function.sqlindex ed75ea3..c56ab21 100644--- a/supabase/migrations/20261016121600_replace_finish_automation_send_function.sql+++ b/supabase/migrations/20261016121600_replace_finish_automation_send_function.sql@@ -1,7 +1,4 @@--- records what Instagram answered in one transaction: the attempt, the comment's new state, and a cooldown or a hold--- for the account; a reply that comes back after its run was marked interrupted still lands, because the answer is--- better than a guess. p_recipient_id keeps who received an accepted reply and p_gate_status starts a followers-only--- wait; both default to null, so the Worker deployed before this change still calls it+-- replaces finish_automation_send so it keeps who received the reply and starts the followers-only waitdrop function if exists public.finish_automation_send(text, text, text, text, text, text, text, integer, integer, integer, timestamptz, timestamptz, text, text);create or replace function public.finish_automation_send(p_id text,diff --git a/supabase/migrations/20261016121700_create_automation_followups_for_messages_function.sql b/supabase/migrations/20261016121700_create_automation_followups_for_messages_function.sqlindex f423af7..8b90358 100644--- a/supabase/migrations/20261016121700_create_automation_followups_for_messages_function.sql+++ b/supabase/migrations/20261016121700_create_automation_followups_for_messages_function.sql@@ -1,6 +1,4 @@--- turns messages from people waiting on a followers-only reply into follow-up jobs, at most one open job per comment;--- p_messages is [{ "id", "sender_id", "message_id", "sent_at" }] with row ids made by the Worker, and a message Meta--- delivers again, or a second message while one is open, inserts nothing+-- creates automation_followups_for_messages, which turns answers to followers-only replies into follow-up jobscreate or replace function public.automation_followups_for_messages(p_ig_user_id text, p_messages jsonb)returns table (id text)language sqldiff --git a/supabase/migrations/20261016121800_create_claim_automation_followups_function.sql b/supabase/migrations/20261016121800_create_claim_automation_followups_function.sqlindex bee68d5..7f1a2e6 100644--- a/supabase/migrations/20261016121800_create_claim_automation_followups_function.sql+++ b/supabase/migrations/20261016121800_create_claim_automation_followups_function.sql@@ -1,5 +1,4 @@--- hands one run the due follow-ups with accounts taking turns, leaving out paused and cooling accounts, with what a--- follow-up needs: the person, the rule's texts, the comment's followers-only state and the account's token+-- creates claim_automation_followups, which hands a run the follow-ups that are duecreate or replace function public.claim_automation_followups(p_limit integer,p_lease_seconds integer,diff --git a/supabase/migrations/20261016121900_create_reserve_automation_followup_function.sql b/supabase/migrations/20261016121900_create_reserve_automation_followup_function.sqlindex 2181a62..ba062a9 100644--- a/supabase/migrations/20261016121900_create_reserve_automation_followup_function.sql+++ b/supabase/migrations/20261016121900_create_reserve_automation_followup_function.sql@@ -1,6 +1,4 @@--- decides whether a claimed follow-up may send now and records the attempt before the request leaves; answers ok,--- gone, paused or cooldown. Follow-ups use Instagram's Send API, not the private reply allowance, so the hourly--- reply limits do not apply to them+-- creates reserve_automation_followup, which checks the account and records an attempt before a follow-up is sentcreate or replace function public.reserve_automation_followup(p_id text,p_attempt_id text,diff --git a/supabase/migrations/20261016122000_create_finish_automation_followup_function.sql b/supabase/migrations/20261016122000_create_finish_automation_followup_function.sqlindex 332399f..0778789 100644--- a/supabase/migrations/20261016122000_create_finish_automation_followup_function.sql+++ b/supabase/migrations/20261016122000_create_finish_automation_followup_function.sql@@ -1,5 +1,4 @@--- records what Instagram answered to a follow-up in one transaction: the follow-up, its attempt, a cooldown or a hold--- for the account, and the comment's followers-only state (link sent, or one more reminder counted)+-- creates finish_automation_followup, which saves what Instagram answered to a follow-upcreate or replace function public.finish_automation_followup(p_id text,p_attempt_id text,diff --git a/supabase/migrations/20261016122100_create_automation_review_candidates_function.sql b/supabase/migrations/20261016122100_create_automation_review_candidates_function.sqlindex e38ada8..de06dbb 100644--- a/supabase/migrations/20261016122100_create_automation_review_candidates_function.sql+++ b/supabase/migrations/20261016122100_create_automation_review_candidates_function.sql@@ -1,6 +1,4 @@--- replies whose outcome was unknown, ready to be looked for in the conversation on Instagram: the last attempt left--- at least p_settle_seconds ago, fewer than p_max_checks checks so far and none in the last p_recheck_seconds;--- the least checked first+-- creates automation_review_candidates, which lists replies of unknown outcome that are ready to be looked for on Instagramcreate or replace function public.automation_review_candidates(p_limit integer,p_settle_seconds integer,diff --git a/supabase/migrations/20261016122200_create_record_automation_review_function.sql b/supabase/migrations/20261016122200_create_record_automation_review_function.sqlindex bc1925c..e7d703b 100644--- a/supabase/migrations/20261016122200_create_record_automation_review_function.sql+++ b/supabase/migrations/20261016122200_create_record_automation_review_function.sql@@ -1,6 +1,4 @@--- records one check of a reply whose outcome was unknown. Found in the conversation: the comment and its attempt--- become accepted, and a followers-only rule starts waiting for the person's reply. Not found: one more check is--- counted with a note for the person; nothing is ever sent from here. Only a comment still waiting for review changes+-- creates record_automation_review, which saves whether a reply of unknown outcome was found on Instagramcreate or replace function public.record_automation_review(p_id text,p_found boolean,diff --git a/supabase/migrations/20261016122300_create_expire_automation_jobs_function.sql b/supabase/migrations/20261016122300_create_expire_automation_jobs_function.sqlindex 8b07d6b..a792075 100644--- a/supabase/migrations/20261016122300_create_expire_automation_jobs_function.sql+++ b/supabase/migrations/20261016122300_create_expire_automation_jobs_function.sql@@ -1,5 +1,4 @@--- expires up to p_limit replies whose 7 days ran out and up to p_limit follow-ups whose 24 hours ran out, without a--- run claiming each one; rows a run holds are skipped and settled by that run+-- creates expire_automation_jobs, which marks replies and follow-ups whose time ran out as expiredcreate or replace function public.expire_automation_jobs(p_limit integer)returns jsonblanguage sqldiff --git a/supabase/migrations/20261016122400_create_purge_automation_comments_function.sql b/supabase/migrations/20261016122400_create_purge_automation_comments_function.sqlindex 5f99ff5..dcd8b50 100644--- a/supabase/migrations/20261016122400_create_purge_automation_comments_function.sql+++ b/supabase/migrations/20261016122400_create_purge_automation_comments_function.sql@@ -1,5 +1,4 @@--- deletes at most p_limit comments created before p_before, oldest first, and returns how many; their attempts and--- follow-ups go with them. A bounded batch keeps each statement short however much built up+-- creates purge_automation_comments, which deletes old comments in small batchescreate or replace function public.purge_automation_comments(p_before timestamptz, p_limit integer)returns integerlanguage sqldiff --git a/supabase/migrations/20261016122500_create_automation_queue_health_function.sql b/supabase/migrations/20261016122500_create_automation_queue_health_function.sqlindex 8ea3ec3..5870758 100644--- a/supabase/migrations/20261016122500_create_automation_queue_health_function.sql+++ b/supabase/migrations/20261016122500_create_automation_queue_health_function.sql@@ -1,5 +1,4 @@--- the instance's reply queue in one call, each count read through its own partial index: jobs due now and the oldest--- of them, jobs held by runs that stopped, replies that need review, follow-ups due, and accounts that are held+-- creates automation_queue_health, which counts what is waiting, stuck or needs review in the reply queuecreate or replace function public.automation_queue_health(p_lease_seconds integer)returns jsonblanguage sqldiff --git a/supabase/migrations/20261016130000_alter_automation_rules_reply_actions.sql b/supabase/migrations/20261016130000_alter_automation_rules_reply_actions.sqlindex 3a42add..d71f0c0 100644--- a/supabase/migrations/20261016130000_alter_automation_rules_reply_actions.sql+++ b/supabase/migrations/20261016130000_alter_automation_rules_reply_actions.sql@@ -1,6 +1,4 @@--- a rule answers a matching comment with a private reply, a public reply under the comment, or both; existing rules--- keep the private reply alone. A public reply rotates between up to five texts, so a busy post does not fill with--- the same words+-- lets a rule send a private reply, a public reply under the comment, or bothalter table public.automation_rulesdrop constraint automation_rules_reply_text_check,add column private_reply_enabled boolean not null default true,diff --git a/supabase/migrations/20261016130100_alter_automation_accounts_public_reply_fields.sql b/supabase/migrations/20261016130100_alter_automation_accounts_public_reply_fields.sqlindex c4f589f..c2e3ed9 100644--- a/supabase/migrations/20261016130100_alter_automation_accounts_public_reply_fields.sql+++ b/supabase/migrations/20261016130100_alter_automation_accounts_public_reply_fields.sql@@ -1,5 +1,4 @@--- public replies have their own cooldown and hourly limit: Instagram limits commenting and messaging apart, so a--- block on one never holds the other+-- adds a separate cooldown and hourly limit for public replies to automation_accountsalter table public.automation_accountsadd column public_cooldown_until timestamptz,add column public_cooldown_reason text,diff --git a/supabase/migrations/20261016130200_create_automation_public_replies.sql b/supabase/migrations/20261016130200_create_automation_public_replies.sqlindex 9c67ae2..8874bec 100644--- a/supabase/migrations/20261016130200_create_automation_public_replies.sql+++ b/supabase/migrations/20261016130200_create_automation_public_replies.sql@@ -1,5 +1,4 @@--- a public reply under a comment a rule matched, one per comment; it is tracked apart from the private reply, so--- either one can fail, wait or be retried without touching the other+-- creates automation_public_replies, which holds the public reply under each matched comment as its own jobcreate table public.automation_public_replies (id text primary key,user_id uuid not null references auth.users (id) on delete cascade,diff --git a/supabase/migrations/20261016130300_revoke_browser_access_automation_public_replies.sql b/supabase/migrations/20261016130300_revoke_browser_access_automation_public_replies.sqlindex f4bf131..fe3852a 100644--- a/supabase/migrations/20261016130300_revoke_browser_access_automation_public_replies.sql+++ b/supabase/migrations/20261016130300_revoke_browser_access_automation_public_replies.sql@@ -1,3 +1,3 @@--- only the Worker's service role reads automation_public_replies; the anon key ships in every browser+-- turns on row level security and removes browser access to automation_public_repliesalter table public.automation_public_replies enable row level security;revoke all on table public.automation_public_replies from anon, authenticated;diff --git a/supabase/migrations/20261016130400_add_automation_public_replies_updated_at_trigger.sql b/supabase/migrations/20261016130400_add_automation_public_replies_updated_at_trigger.sqlindex 276a225..8644de7 100644--- a/supabase/migrations/20261016130400_add_automation_public_replies_updated_at_trigger.sql+++ b/supabase/migrations/20261016130400_add_automation_public_replies_updated_at_trigger.sql@@ -1,3 +1,3 @@--- set_updated_at() keeps updated_at, so no query has to set it+-- adds the trigger that keeps updated_at current on automation_public_repliescreate trigger automation_public_replies_set_updated_at before update on public.automation_public_repliesfor each row execute function public.set_updated_at();diff --git a/supabase/migrations/20261016130500_index_automation_public_replies_due_by_account.sql b/supabase/migrations/20261016130500_index_automation_public_replies_due_by_account.sqlindex 2cf204a..0361cd1 100644--- a/supabase/migrations/20261016130500_index_automation_public_replies_due_by_account.sql+++ b/supabase/migrations/20261016130500_index_automation_public_replies_due_by_account.sql@@ -1,3 +1,2 @@--- claim_automation_public_replies and the expiry: each account's public replies waiting to go out, so accounts take--- turns however long one queue is; partial, so the history is left out+-- adds an index that finds each account's public replies waiting to be postedcreate index automation_public_replies_due_account_idx on public.automation_public_replies (account_id, next_attempt_at) where status in ('queued', 'retry_wait');diff --git a/supabase/migrations/20261016130600_index_automation_public_replies_claimed.sql b/supabase/migrations/20261016130600_index_automation_public_replies_claimed.sqlindex 2314f2d..6117601 100644--- a/supabase/migrations/20261016130600_index_automation_public_replies_claimed.sql+++ b/supabase/migrations/20261016130600_index_automation_public_replies_claimed.sql@@ -1,2 +1,2 @@--- claim_automation_public_replies: public replies whose run stopped holding them+-- adds an index that finds public replies held by a run that stoppedcreate index automation_public_replies_claimed_idx on public.automation_public_replies (claimed_at) where status in ('processing', 'sending');diff --git a/supabase/migrations/20261016130700_index_automation_public_replies_needs_review.sql b/supabase/migrations/20261016130700_index_automation_public_replies_needs_review.sqlindex c7c5610..c8f0e3f 100644--- a/supabase/migrations/20261016130700_index_automation_public_replies_needs_review.sql+++ b/supabase/migrations/20261016130700_index_automation_public_replies_needs_review.sql@@ -1,2 +1,2 @@--- automation_public_review_candidates and the queue health: public replies whose outcome is unknown+-- adds an index that finds public replies whose outcome is unknowncreate index automation_public_replies_needs_review_idx on public.automation_public_replies (review_checked_at nulls first, updated_at) where status = 'needs_review';diff --git a/supabase/migrations/20261016130800_index_automation_public_replies_recipient.sql b/supabase/migrations/20261016130800_index_automation_public_replies_recipient.sqlindex a55d1af..c7ab6c7 100644--- a/supabase/migrations/20261016130800_index_automation_public_replies_recipient.sql+++ b/supabase/migrations/20261016130800_index_automation_public_replies_recipient.sql@@ -1,3 +1,3 @@--- reserve_automation_public_reply: the public replies one person already got, or may have got, on one post+-- adds an index that checks whether a person already got a public reply on a postcreate index automation_public_replies_recipient_idx on public.automation_public_replies (account_id, from_id, media_id, created_at)where status in ('sending', 'accepted', 'needs_review');diff --git a/supabase/migrations/20261016130850_index_automation_public_replies_user_created.sql b/supabase/migrations/20261016130850_index_automation_public_replies_user_created.sqlindex a59e249..15a8c0b 100644--- a/supabase/migrations/20261016130850_index_automation_public_replies_user_created.sql+++ b/supabase/migrations/20261016130850_index_automation_public_replies_user_created.sql@@ -1,2 +1,2 @@--- automation_stats: one user's public replies in a period+-- adds an index that counts a user's public replies for a periodcreate index automation_public_replies_user_created_idx on public.automation_public_replies (user_id, created_at);diff --git a/supabase/migrations/20261016130900_alter_automation_attempts_public_reply.sql b/supabase/migrations/20261016130900_alter_automation_attempts_public_reply.sqlindex 405162f..bad274a 100644--- a/supabase/migrations/20261016130900_alter_automation_attempts_public_reply.sql+++ b/supabase/migrations/20261016130900_alter_automation_attempts_public_reply.sql@@ -1,5 +1,4 @@--- public replies are counted with the other requests, under their own kind: Instagram limits them apart from--- private replies, so neither kind's hourly limit counts the other+-- lets automation_attempts record public replies as their own kindalter table public.automation_attemptsadd column public_reply_id text references public.automation_public_replies (id) on delete cascade,drop constraint automation_attempts_kind_check,diff --git a/supabase/migrations/20261016131000_index_automation_attempts_public_reply.sql b/supabase/migrations/20261016131000_index_automation_attempts_public_reply.sqlindex 73c117b..a1d8df0 100644--- a/supabase/migrations/20261016131000_index_automation_attempts_public_reply.sql+++ b/supabase/migrations/20261016131000_index_automation_attempts_public_reply.sql@@ -1,2 +1,2 @@--- deleting a public reply removes its attempts, and the review reads them, without scanning every attempt+-- adds an index that finds the attempts of one public replycreate index automation_attempts_public_reply_idx on public.automation_attempts (public_reply_id) where public_reply_id is not null;diff --git a/supabase/migrations/20261016131100_replace_automation_rules_for_ig_user_function.sql b/supabase/migrations/20261016131100_replace_automation_rules_for_ig_user_function.sqlindex 6a7a401..12b56b9 100644--- a/supabase/migrations/20261016131100_replace_automation_rules_for_ig_user_function.sql+++ b/supabase/migrations/20261016131100_replace_automation_rules_for_ig_user_function.sql@@ -1,6 +1,4 @@--- the enabled rules of every connected account a webhook's Instagram account id belongs to, oldest account first,--- with what each one answers with: the private reply, the public reply and its texts. The return only gains--- columns, so the Worker deployed before this change reads the ones it knows+-- replaces automation_rules_for_ig_user so it also returns each rule's public reply settingsdrop function if exists public.automation_rules_for_ig_user(text);create or replace function public.automation_rules_for_ig_user(p_ig_user_id text)returns table (diff --git a/supabase/migrations/20261016131200_create_store_automation_comments_function.sql b/supabase/migrations/20261016131200_create_store_automation_comments_function.sqlindex 6926394..f6f299e 100644--- a/supabase/migrations/20261016131200_create_store_automation_comments_function.sql+++ b/supabase/migrations/20261016131200_create_store_automation_comments_function.sql@@ -1,6 +1,4 @@--- stores a webhook's comments and the public replies their rules ask for in one transaction, so a comment is never--- kept without its public reply. A notification Meta delivers again inserts nothing: comments are unique per account--- and public replies per comment. Answers the new comments' ids and statuses and the new public replies' ids+-- creates store_automation_comments, which saves a webhook's comments and their public replies togethercreate or replace function public.store_automation_comments(p_comments jsonb)returns jsonblanguage plpgsqldiff --git a/supabase/migrations/20261016131300_create_claim_automation_public_replies_function.sql b/supabase/migrations/20261016131300_create_claim_automation_public_replies_function.sqlindex 2d34e5c..d706423 100644--- a/supabase/migrations/20261016131300_create_claim_automation_public_replies_function.sql+++ b/supabase/migrations/20261016131300_create_claim_automation_public_replies_function.sql@@ -1,6 +1,4 @@--- hands one run the due public replies with accounts taking turns, as claim_automation_comments does for private--- replies. Accounts that are paused, or whose public replies are cooling down or at their hourly limit, are left out;--- p_ids limits it to the replies a webhook or a retry has just queued+-- creates claim_automation_public_replies, which hands a run the public replies that are due to be postedcreate or replace function public.claim_automation_public_replies(p_limit integer,p_per_account integer,diff --git a/supabase/migrations/20261016131400_create_reserve_automation_public_reply_function.sql b/supabase/migrations/20261016131400_create_reserve_automation_public_reply_function.sqlindex ac364f0..775db89 100644--- a/supabase/migrations/20261016131400_create_reserve_automation_public_reply_function.sql+++ b/supabase/migrations/20261016131400_create_reserve_automation_public_reply_function.sql@@ -1,6 +1,4 @@--- decides whether a claimed public reply may go out now and, when it may, records the attempt before the request--- leaves; answers ok, gone, paused, cooldown, recipient_limit or account_limit. Only public reply attempts count, and--- a full account is marked until a reply frees up so runs stop claiming its public replies+-- creates reserve_automation_public_reply, which checks the limits and records an attempt before a public reply is postedcreate or replace function public.reserve_automation_public_reply(p_id text,p_attempt_id text,diff --git a/supabase/migrations/20261016131500_create_finish_automation_public_reply_function.sql b/supabase/migrations/20261016131500_create_finish_automation_public_reply_function.sqlindex 7b414e3..7895e88 100644--- a/supabase/migrations/20261016131500_create_finish_automation_public_reply_function.sql+++ b/supabase/migrations/20261016131500_create_finish_automation_public_reply_function.sql@@ -1,6 +1,4 @@--- records what Instagram answered to a public reply in one transaction: the reply, its attempt, a cooldown for the--- account's public replies, or a hold on the whole account when Instagram refused its token. An answer that comes--- back after its run was marked interrupted still lands, because the answer is better than a guess+-- creates finish_automation_public_reply, which saves what Instagram answered to a public replycreate or replace function public.finish_automation_public_reply(p_id text,p_attempt_id text,diff --git a/supabase/migrations/20261016131600_create_automation_public_review_candidates_function.sql b/supabase/migrations/20261016131600_create_automation_public_review_candidates_function.sqlindex acd61d9..f44cfa8 100644--- a/supabase/migrations/20261016131600_create_automation_public_review_candidates_function.sql+++ b/supabase/migrations/20261016131600_create_automation_public_review_candidates_function.sql@@ -1,6 +1,4 @@--- public replies whose outcome was unknown, ready to be looked for among the comment's replies on Instagram: the--- last attempt left at least p_settle_seconds ago, fewer than p_max_checks checks so far and none in the last--- p_recheck_seconds; ambiguous_attempts tells the Worker whether the reply was already sent again once+-- creates automation_public_review_candidates, which lists public replies of unknown outcome that are ready to be looked forcreate or replace function public.automation_public_review_candidates(p_limit integer,p_settle_seconds integer,diff --git a/supabase/migrations/20261016131700_create_record_automation_public_review_function.sql b/supabase/migrations/20261016131700_create_record_automation_public_review_function.sqlindex e85b1f5..24107b9 100644--- a/supabase/migrations/20261016131700_create_record_automation_public_review_function.sql+++ b/supabase/migrations/20261016131700_create_record_automation_public_review_function.sql@@ -1,7 +1,4 @@--- records one check of a public reply whose outcome was unknown. Found among the comment's replies: the reply and--- its latest attempt become accepted. Not found, with p_resend: the Worker read every reply on two checks minutes--- apart and it was in neither, so the reply goes back in the queue once. Otherwise one more check is counted with a--- note for the person. Only a reply still waiting for review changes, so a person's retry in between is never undone+-- creates record_automation_public_review, which saves whether a public reply of unknown outcome was foundcreate or replace function public.record_automation_public_review(p_id text,p_found boolean,diff --git a/supabase/migrations/20261016131800_replace_expire_automation_jobs_function.sql b/supabase/migrations/20261016131800_replace_expire_automation_jobs_function.sqlindex 146f7a3..0fdde67 100644--- a/supabase/migrations/20261016131800_replace_expire_automation_jobs_function.sql+++ b/supabase/migrations/20261016131800_replace_expire_automation_jobs_function.sql@@ -1,6 +1,4 @@--- expires up to p_limit replies whose 7 days ran out, up to p_limit follow-ups whose 24 hours ran out and up to--- p_limit public replies still waiting 7 days after their comment, without a run claiming each one; rows a run holds--- are skipped and settled by that run. The answer gains public_replies, which the earlier Worker ignores+-- replaces expire_automation_jobs so it also expires public repliescreate or replace function public.expire_automation_jobs(p_limit integer)returns jsonblanguage sqldiff --git a/supabase/migrations/20261016131900_replace_automation_queue_health_function.sql b/supabase/migrations/20261016131900_replace_automation_queue_health_function.sqlindex 00411bb..4e53949 100644--- a/supabase/migrations/20261016131900_replace_automation_queue_health_function.sql+++ b/supabase/migrations/20261016131900_replace_automation_queue_health_function.sql@@ -1,6 +1,4 @@--- the instance's reply queue in one call, each count read through its own partial index: jobs due now and the oldest--- of them, jobs held by runs that stopped, replies that need review, follow-ups due, public replies due, held or--- unknown, and accounts that are held. The answer only gains keys, which the earlier Worker ignores+-- replaces automation_queue_health so it also counts public repliescreate or replace function public.automation_queue_health(p_lease_seconds integer)returns jsonblanguage sqldiff --git a/supabase/migrations/20261016132000_replace_automation_stats_function.sql b/supabase/migrations/20261016132000_replace_automation_stats_function.sqlindex 8a92b96..a4b6c90 100644--- a/supabase/migrations/20261016132000_replace_automation_stats_function.sql+++ b/supabase/migrations/20261016132000_replace_automation_stats_function.sql@@ -1,6 +1,4 @@--- one user's comment counts by status, public reply counts by status and request counts by outcome for a period,--- counted in the database instead of loading every row; p_account_id and p_rule_id narrow it when set. The answer--- only gains public_replies, which the earlier Worker ignores+-- replaces automation_stats so it also counts public repliescreate or replace function public.automation_stats(p_user_id uuid,p_from timestamptz,diff --git a/supabase/migrations/20261016132100_replace_claim_automation_comments_private_reply.sql b/supabase/migrations/20261016132100_replace_claim_automation_comments_private_reply.sqlindex 2a22a7b..eb94ffa 100644--- a/supabase/migrations/20261016132100_replace_claim_automation_comments_private_reply.sql+++ b/supabase/migrations/20261016132100_replace_claim_automation_comments_private_reply.sql@@ -1,6 +1,4 @@--- hands one run the due reply jobs with accounts taking turns, as before; a rule whose private reply was turned off--- after its comments were queued now counts as off for them, so they are skipped instead of sent. The signature and--- columns are unchanged, so the Worker deployed before this change calls it the same way+-- replaces claim_automation_comments so a rule whose private reply was turned off sends no private replycreate or replace function public.claim_automation_comments(p_limit integer,p_per_account integer,diff --git a/supabase/migrations/20261017171632_index_accounts_identity.sql b/supabase/migrations/20261017171632_index_accounts_identity.sqlindex 71f9ad0..52fe78d 100644--- a/supabase/migrations/20261017171632_index_accounts_identity.sql+++ b/supabase/migrations/20261017171632_index_accounts_identity.sql@@ -1,5 +1,4 @@--- one row per user, platform and account, so two adds at the same moment cannot store the same account twice; the--- identity is the field each platform's account is matched by in accountService+-- allows each account only once per user, so two adds at the same moment store one rowcreate unique index if not exists accounts_identity_key on public.accounts (user_id,platform,diff --git a/supabase/rollbacks/20261016000400_revoke_browser_access_accounts.sql b/supabase/rollbacks/20261016000400_revoke_browser_access_accounts.sqlindex cf2ac73..94e501d 100644--- a/supabase/rollbacks/20261016000400_revoke_browser_access_accounts.sql+++ b/supabase/rollbacks/20261016000400_revoke_browser_access_accounts.sql@@ -1,3 +1,3 @@--- restores the browser access accounts had before; only for returning to that state+-- gives the browser roles full access to accounts again, which reopens the hole the migration closedgrant all on table public.accounts to anon, authenticated;create policy users_own_accounts on public.accounts for all using (auth.uid() = user_id) with check (auth.uid() = user_id);diff --git a/supabase/rollbacks/20261016000500_revoke_browser_access_settings.sql b/supabase/rollbacks/20261016000500_revoke_browser_access_settings.sqlindex 3cd37af..ec2361b 100644--- a/supabase/rollbacks/20261016000500_revoke_browser_access_settings.sql+++ b/supabase/rollbacks/20261016000500_revoke_browser_access_settings.sql@@ -1,3 +1,3 @@--- restores the browser access settings had before; only for returning to that state+-- gives the browser roles full access to settings again, which reopens the hole the migration closedgrant all on table public.settings to anon, authenticated;create policy users_own_settings on public.settings for all using (auth.uid() = user_id) with check (auth.uid() = user_id);diff --git a/supabase/rollbacks/20261016000600_revoke_browser_access_scheduled_posts.sql b/supabase/rollbacks/20261016000600_revoke_browser_access_scheduled_posts.sqlindex 364292d..2f669c0 100644--- a/supabase/rollbacks/20261016000600_revoke_browser_access_scheduled_posts.sql+++ b/supabase/rollbacks/20261016000600_revoke_browser_access_scheduled_posts.sql@@ -1,3 +1,3 @@--- restores the browser access scheduled_posts had before; only for returning to that state+-- gives the browser roles full access to scheduled_posts again, which reopens the hole the migration closedgrant all on table public.scheduled_posts to anon, authenticated;create policy users_own_posts on public.scheduled_posts for all using (auth.uid() = user_id) with check (auth.uid() = user_id);diff --git a/supabase/rollbacks/20261016000700_revoke_browser_access_tracked_posts.sql b/supabase/rollbacks/20261016000700_revoke_browser_access_tracked_posts.sqlindex c3ef763..318e515 100644--- a/supabase/rollbacks/20261016000700_revoke_browser_access_tracked_posts.sql+++ b/supabase/rollbacks/20261016000700_revoke_browser_access_tracked_posts.sql@@ -1,2 +1,2 @@--- restores the browser access tracked_posts had before; only for returning to that state+-- gives the browser roles full access to tracked_posts again, which reopens the hole the migration closedgrant all on table public.tracked_posts to anon, authenticated;diff --git a/supabase/rollbacks/20261016000800_revoke_browser_default_privileges.sql b/supabase/rollbacks/20261016000800_revoke_browser_default_privileges.sqlindex d2f3297..4a98dbf 100644--- a/supabase/rollbacks/20261016000800_revoke_browser_default_privileges.sql+++ b/supabase/rollbacks/20261016000800_revoke_browser_default_privileges.sql@@ -1,2 +1,3 @@+-- lets new tables and functions give the browser roles access by default againalter default privileges for role postgres in schema public grant all on functions to anon, authenticated;alter default privileges for role postgres in schema public grant all on tables to anon, authenticated;diff --git a/supabase/rollbacks/20261016000900_check_accounts_values.sql b/supabase/rollbacks/20261016000900_check_accounts_values.sqlindex becca94..1291e5c 100644--- a/supabase/rollbacks/20261016000900_check_accounts_values.sql+++ b/supabase/rollbacks/20261016000900_check_accounts_values.sql@@ -1,3 +1,4 @@+-- removes the platform and data checks from accountsalter table public.accountsdrop constraint if exists accounts_data_check,drop constraint if exists accounts_platform_check;diff --git a/supabase/rollbacks/20261016001000_check_settings_values.sql b/supabase/rollbacks/20261016001000_check_settings_values.sqlindex 433ad65..d29f40c 100644--- a/supabase/rollbacks/20261016001000_check_settings_values.sql+++ b/supabase/rollbacks/20261016001000_check_settings_values.sql@@ -1 +1,2 @@+-- removes the value check from settingsalter table public.settings drop constraint if exists settings_value_check;diff --git a/supabase/rollbacks/20261016001100_check_scheduled_posts_values.sql b/supabase/rollbacks/20261016001100_check_scheduled_posts_values.sqlindex 615ec2c..140a5e4 100644--- a/supabase/rollbacks/20261016001100_check_scheduled_posts_values.sql+++ b/supabase/rollbacks/20261016001100_check_scheduled_posts_values.sql@@ -1,3 +1,4 @@+-- removes the status, attempt, claim and data checks from scheduled_postsalter table public.scheduled_postsdrop constraint if exists scheduled_posts_data_check,drop constraint if exists scheduled_posts_claim_check,diff --git a/supabase/rollbacks/20261016001200_check_tracked_posts_values.sql b/supabase/rollbacks/20261016001200_check_tracked_posts_values.sqlindex 6193967..0503a9f 100644--- a/supabase/rollbacks/20261016001200_check_tracked_posts_values.sql+++ b/supabase/rollbacks/20261016001200_check_tracked_posts_values.sql@@ -1,3 +1,4 @@+-- removes the content type, account and data checks from tracked_postsalter table public.tracked_postsdrop constraint if exists tracked_posts_data_check,drop constraint if exists tracked_posts_account_check,diff --git a/supabase/rollbacks/20261016001300_add_accounts_id_user_id_key.sql b/supabase/rollbacks/20261016001300_add_accounts_id_user_id_key.sqlindex d12a87a..97e5245 100644--- a/supabase/rollbacks/20261016001300_add_accounts_id_user_id_key.sql+++ b/supabase/rollbacks/20261016001300_add_accounts_id_user_id_key.sql@@ -1 +1,2 @@+-- removes the unique account id and owner pair; roll back the two account foreign keys firstalter table public.accounts drop constraint if exists accounts_id_user_id_key;diff --git a/supabase/rollbacks/20261016001400_add_scheduled_posts_account_fkey.sql b/supabase/rollbacks/20261016001400_add_scheduled_posts_account_fkey.sqlindex 66711dd..ba9fa02 100644--- a/supabase/rollbacks/20261016001400_add_scheduled_posts_account_fkey.sql+++ b/supabase/rollbacks/20261016001400_add_scheduled_posts_account_fkey.sql@@ -1,2 +1,2 @@--- production had no foreign key here before the migration+-- removes the foreign key from scheduled posts to their account, which production did not have beforealter table public.scheduled_posts drop constraint if exists scheduled_posts_account_fkey;diff --git a/supabase/rollbacks/20261016001500_add_tracked_posts_account_fkey.sql b/supabase/rollbacks/20261016001500_add_tracked_posts_account_fkey.sqlindex 44ffbce..1f9c7b5 100644--- a/supabase/rollbacks/20261016001500_add_tracked_posts_account_fkey.sql+++ b/supabase/rollbacks/20261016001500_add_tracked_posts_account_fkey.sql@@ -1,3 +1,4 @@+-- removes the foreign key from tracked items to their accountalter table public.tracked_posts drop constraint if exists tracked_posts_account_fkey;alter table public.tracked_postsadd constraint tracked_posts_account_id_fkey foreign key (account_id)diff --git a/supabase/rollbacks/20261016001600_create_set_updated_at_function.sql b/supabase/rollbacks/20261016001600_create_set_updated_at_function.sqlindex 9271627..37724df 100644--- a/supabase/rollbacks/20261016001600_create_set_updated_at_function.sql+++ b/supabase/rollbacks/20261016001600_create_set_updated_at_function.sql@@ -1 +1,2 @@+-- removes the set_updated_at function; roll back every updated_at trigger firstdrop function if exists public.set_updated_at();diff --git a/supabase/rollbacks/20261016001700_add_accounts_updated_at.sql b/supabase/rollbacks/20261016001700_add_accounts_updated_at.sqlindex e9756e1..6a21b8f 100644--- a/supabase/rollbacks/20261016001700_add_accounts_updated_at.sql+++ b/supabase/rollbacks/20261016001700_add_accounts_updated_at.sql@@ -1,2 +1,3 @@+-- removes updated_at and its trigger from accountsdrop trigger if exists accounts_set_updated_at on public.accounts;alter table public.accounts drop column if exists updated_at;diff --git a/supabase/rollbacks/20261016001800_add_settings_updated_at.sql b/supabase/rollbacks/20261016001800_add_settings_updated_at.sqlindex 7263805..1ad384e 100644--- a/supabase/rollbacks/20261016001800_add_settings_updated_at.sql+++ b/supabase/rollbacks/20261016001800_add_settings_updated_at.sql@@ -1,2 +1,3 @@+-- removes updated_at and its trigger from settingsdrop trigger if exists settings_set_updated_at on public.settings;alter table public.settings drop column if exists updated_at;diff --git a/supabase/rollbacks/20261016001900_add_scheduled_posts_updated_at.sql b/supabase/rollbacks/20261016001900_add_scheduled_posts_updated_at.sqlindex d1cda3a..37ac67a 100644--- a/supabase/rollbacks/20261016001900_add_scheduled_posts_updated_at.sql+++ b/supabase/rollbacks/20261016001900_add_scheduled_posts_updated_at.sql@@ -1,2 +1,3 @@+-- removes updated_at and its trigger from scheduled_postsdrop trigger if exists scheduled_posts_set_updated_at on public.scheduled_posts;alter table public.scheduled_posts drop column if exists updated_at;diff --git a/supabase/rollbacks/20261016002000_add_tracked_posts_updated_at_trigger.sql b/supabase/rollbacks/20261016002000_add_tracked_posts_updated_at_trigger.sqlindex 264f646..bd95f8c 100644--- a/supabase/rollbacks/20261016002000_add_tracked_posts_updated_at_trigger.sql+++ b/supabase/rollbacks/20261016002000_add_tracked_posts_updated_at_trigger.sql@@ -1 +1,2 @@+-- removes the trigger that keeps updated_at current on tracked_postsdrop trigger if exists tracked_posts_set_updated_at on public.tracked_posts;diff --git a/supabase/rollbacks/20261016002100_create_merge_account_data_function.sql b/supabase/rollbacks/20261016002100_create_merge_account_data_function.sqlindex 2bcf45c..1802d56 100644--- a/supabase/rollbacks/20261016002100_create_merge_account_data_function.sql+++ b/supabase/rollbacks/20261016002100_create_merge_account_data_function.sql@@ -1,2 +1,2 @@--- deploy the code that reads data before writing it again first, or its writes will fail+-- removes merge_account_data; deploy code that no longer calls it firstdrop function if exists public.merge_account_data(text, uuid, jsonb);diff --git a/supabase/rollbacks/20261016002200_create_merge_scheduled_post_function.sql b/supabase/rollbacks/20261016002200_create_merge_scheduled_post_function.sqlindex 7674465..b9febef 100644--- a/supabase/rollbacks/20261016002200_create_merge_scheduled_post_function.sql+++ b/supabase/rollbacks/20261016002200_create_merge_scheduled_post_function.sql@@ -1,2 +1,2 @@--- deploy the code that reads data before writing it again first, or its writes will fail+-- removes merge_scheduled_post; deploy code that no longer calls it firstdrop function if exists public.merge_scheduled_post(text, uuid, jsonb, text, timestamptz, text);diff --git a/supabase/rollbacks/20261016002300_create_merge_tracked_post_data_function.sql b/supabase/rollbacks/20261016002300_create_merge_tracked_post_data_function.sqlindex e05a844..662b87d 100644--- a/supabase/rollbacks/20261016002300_create_merge_tracked_post_data_function.sql+++ b/supabase/rollbacks/20261016002300_create_merge_tracked_post_data_function.sql@@ -1,2 +1,2 @@--- deploy the code that reads data before writing it again first, or its writes will fail+-- removes merge_tracked_post_data; deploy code that no longer calls it firstdrop function if exists public.merge_tracked_post_data(text, uuid, jsonb);diff --git a/supabase/rollbacks/20261016002400_index_accounts_list.sql b/supabase/rollbacks/20261016002400_index_accounts_list.sqlindex c67221f..54f9027 100644--- a/supabase/rollbacks/20261016002400_index_accounts_list.sql+++ b/supabase/rollbacks/20261016002400_index_accounts_list.sql@@ -1 +1,2 @@+-- removes the index that lists a user's accountsdrop index if exists public.accounts_user_id_created_at_idx;diff --git a/supabase/rollbacks/20261016002500_index_scheduled_posts_list.sql b/supabase/rollbacks/20261016002500_index_scheduled_posts_list.sqlindex 6d60c6d..8cae062 100644--- a/supabase/rollbacks/20261016002500_index_scheduled_posts_list.sql+++ b/supabase/rollbacks/20261016002500_index_scheduled_posts_list.sql@@ -1,2 +1,3 @@+-- puts back the plain user index on scheduled_postscreate index if not exists scheduled_posts_user_id_idx on public.scheduled_posts (user_id);drop index if exists public.scheduled_posts_user_id_scheduled_at_idx;diff --git a/supabase/rollbacks/20261016002600_index_scheduled_posts_schedulers.sql b/supabase/rollbacks/20261016002600_index_scheduled_posts_schedulers.sqlindex b3c4568..1530cf6 100644--- a/supabase/rollbacks/20261016002600_index_scheduled_posts_schedulers.sql+++ b/supabase/rollbacks/20261016002600_index_scheduled_posts_schedulers.sql@@ -1,3 +1,4 @@+-- puts back the older scheduler index on scheduled_postsdrop index if exists public.scheduled_posts_claimed_idx;drop index if exists public.scheduled_posts_due_idx;create index scheduled_posts_due_idx on public.scheduled_posts (status, scheduled_at);diff --git a/supabase/rollbacks/20261016002700_index_tracked_posts_list.sql b/supabase/rollbacks/20261016002700_index_tracked_posts_list.sqlindex f351eb0..86a36c7 100644--- a/supabase/rollbacks/20261016002700_index_tracked_posts_list.sql+++ b/supabase/rollbacks/20261016002700_index_tracked_posts_list.sql@@ -1,2 +1,3 @@+-- puts back the plain user index on tracked_postscreate index if not exists tracked_posts_user_id_idx on public.tracked_posts (user_id);drop index if exists public.tracked_posts_user_id_created_at_idx;diff --git a/supabase/rollbacks/20261016100000_create_automation_accounts.sql b/supabase/rollbacks/20261016100000_create_automation_accounts.sqlindex b3d8f3a..21ad16d 100644--- a/supabase/rollbacks/20261016100000_create_automation_accounts.sql+++ b/supabase/rollbacks/20261016100000_create_automation_accounts.sql@@ -1,2 +1,2 @@--- removes every account's pause, cooldown and webhook subscription record+-- removes automation_accounts and every pause, cooldown and subscription in itdrop table if exists public.automation_accounts;diff --git a/supabase/rollbacks/20261016100100_revoke_browser_access_automation_accounts.sql b/supabase/rollbacks/20261016100100_revoke_browser_access_automation_accounts.sqlindex dd7df68..9b93887 100644--- a/supabase/rollbacks/20261016100100_revoke_browser_access_automation_accounts.sql+++ b/supabase/rollbacks/20261016100100_revoke_browser_access_automation_accounts.sql@@ -1,2 +1,2 @@--- the table had no browser grants before, because new tables in public start without them+-- turns row level security off on automation_accounts; it had no browser grants to give backalter table public.automation_accounts disable row level security;diff --git a/supabase/rollbacks/20261016100200_add_automation_accounts_updated_at_trigger.sql b/supabase/rollbacks/20261016100200_add_automation_accounts_updated_at_trigger.sqlindex 0f9112f..556083a 100644--- a/supabase/rollbacks/20261016100200_add_automation_accounts_updated_at_trigger.sql+++ b/supabase/rollbacks/20261016100200_add_automation_accounts_updated_at_trigger.sql@@ -1 +1,2 @@+-- removes the trigger that keeps updated_at current on automation_accountsdrop trigger if exists automation_accounts_set_updated_at on public.automation_accounts;diff --git a/supabase/rollbacks/20261016100300_create_automation_rules.sql b/supabase/rollbacks/20261016100300_create_automation_rules.sqlindex e7aff57..1c45543 100644--- a/supabase/rollbacks/20261016100300_create_automation_rules.sql+++ b/supabase/rollbacks/20261016100300_create_automation_rules.sql@@ -1,2 +1,2 @@--- removes every automation rule; roll back automation_comments and automation_attempts first+-- removes automation_rules and every rule in it; roll back automation_comments and automation_attempts firstdrop table if exists public.automation_rules;diff --git a/supabase/rollbacks/20261016100400_revoke_browser_access_automation_rules.sql b/supabase/rollbacks/20261016100400_revoke_browser_access_automation_rules.sqlindex 0faaf90..a61ed25 100644--- a/supabase/rollbacks/20261016100400_revoke_browser_access_automation_rules.sql+++ b/supabase/rollbacks/20261016100400_revoke_browser_access_automation_rules.sql@@ -1,2 +1,2 @@--- the table had no browser grants before, because new tables in public start without them+-- turns row level security off on automation_rules; it had no browser grants to give backalter table public.automation_rules disable row level security;diff --git a/supabase/rollbacks/20261016100500_add_automation_rules_updated_at_trigger.sql b/supabase/rollbacks/20261016100500_add_automation_rules_updated_at_trigger.sqlindex 85df30c..74cd26b 100644--- a/supabase/rollbacks/20261016100500_add_automation_rules_updated_at_trigger.sql+++ b/supabase/rollbacks/20261016100500_add_automation_rules_updated_at_trigger.sql@@ -1 +1,2 @@+-- removes the trigger that keeps updated_at current on automation_rulesdrop trigger if exists automation_rules_set_updated_at on public.automation_rules;diff --git a/supabase/rollbacks/20261016100600_index_automation_rules_user_id_created_at.sql b/supabase/rollbacks/20261016100600_index_automation_rules_user_id_created_at.sqlindex fb63ece..a3fc11e 100644--- a/supabase/rollbacks/20261016100600_index_automation_rules_user_id_created_at.sql+++ b/supabase/rollbacks/20261016100600_index_automation_rules_user_id_created_at.sql@@ -1 +1,2 @@+-- removes the index that lists a user's rulesdrop index if exists public.automation_rules_user_id_created_at_idx;diff --git a/supabase/rollbacks/20261016100700_index_automation_rules_enabled_account.sql b/supabase/rollbacks/20261016100700_index_automation_rules_enabled_account.sqlindex b0ffd87..a35939e 100644--- a/supabase/rollbacks/20261016100700_index_automation_rules_enabled_account.sql+++ b/supabase/rollbacks/20261016100700_index_automation_rules_enabled_account.sql@@ -1 +1,2 @@+-- removes the index of enabled rules by accountdrop index if exists public.automation_rules_enabled_account_idx;diff --git a/supabase/rollbacks/20261016100800_create_automation_comments.sql b/supabase/rollbacks/20261016100800_create_automation_comments.sqlindex ed19096..4170439 100644--- a/supabase/rollbacks/20261016100800_create_automation_comments.sql+++ b/supabase/rollbacks/20261016100800_create_automation_comments.sql@@ -1,2 +1,2 @@--- removes every received comment and its reply history; roll back automation_attempts first+-- removes automation_comments and every received comment; roll back automation_attempts firstdrop table if exists public.automation_comments;diff --git a/supabase/rollbacks/20261016100900_revoke_browser_access_automation_comments.sql b/supabase/rollbacks/20261016100900_revoke_browser_access_automation_comments.sqlindex f4b7259..48a4e9a 100644--- a/supabase/rollbacks/20261016100900_revoke_browser_access_automation_comments.sql+++ b/supabase/rollbacks/20261016100900_revoke_browser_access_automation_comments.sql@@ -1,2 +1,2 @@--- the table had no browser grants before, because new tables in public start without them+-- turns row level security off on automation_comments; it had no browser grants to give backalter table public.automation_comments disable row level security;diff --git a/supabase/rollbacks/20261016101000_add_automation_comments_updated_at_trigger.sql b/supabase/rollbacks/20261016101000_add_automation_comments_updated_at_trigger.sqlindex 0f9b3f5..b21667f 100644--- a/supabase/rollbacks/20261016101000_add_automation_comments_updated_at_trigger.sql+++ b/supabase/rollbacks/20261016101000_add_automation_comments_updated_at_trigger.sql@@ -1 +1,2 @@+-- removes the trigger that keeps updated_at current on automation_commentsdrop trigger if exists automation_comments_set_updated_at on public.automation_comments;diff --git a/supabase/rollbacks/20261016101100_index_automation_comments_due.sql b/supabase/rollbacks/20261016101100_index_automation_comments_due.sqlindex f2d6fac..e1fdce0 100644--- a/supabase/rollbacks/20261016101100_index_automation_comments_due.sql+++ b/supabase/rollbacks/20261016101100_index_automation_comments_due.sql@@ -1 +1,2 @@+-- removes the index of replies waiting to be sentdrop index if exists public.automation_comments_due_idx;diff --git a/supabase/rollbacks/20261016101200_index_automation_comments_claimed.sql b/supabase/rollbacks/20261016101200_index_automation_comments_claimed.sqlindex cb29b89..9182f28 100644--- a/supabase/rollbacks/20261016101200_index_automation_comments_claimed.sql+++ b/supabase/rollbacks/20261016101200_index_automation_comments_claimed.sql@@ -1 +1,2 @@+-- removes the index of replies held by a rundrop index if exists public.automation_comments_claimed_idx;diff --git a/supabase/rollbacks/20261016101300_index_automation_comments_user_id_created_at.sql b/supabase/rollbacks/20261016101300_index_automation_comments_user_id_created_at.sqlindex 9f30994..0f470df 100644--- a/supabase/rollbacks/20261016101300_index_automation_comments_user_id_created_at.sql+++ b/supabase/rollbacks/20261016101300_index_automation_comments_user_id_created_at.sql@@ -1 +1,2 @@+-- removes the index that lists a user's commentsdrop index if exists public.automation_comments_user_id_created_at_idx;diff --git a/supabase/rollbacks/20261016101400_index_automation_comments_rule_id.sql b/supabase/rollbacks/20261016101400_index_automation_comments_rule_id.sqlindex 5c68358..de10c4f 100644--- a/supabase/rollbacks/20261016101400_index_automation_comments_rule_id.sql+++ b/supabase/rollbacks/20261016101400_index_automation_comments_rule_id.sql@@ -1 +1,2 @@+-- removes the index of comments by ruledrop index if exists public.automation_comments_rule_id_idx;diff --git a/supabase/rollbacks/20261016101500_index_automation_comments_created_at.sql b/supabase/rollbacks/20261016101500_index_automation_comments_created_at.sqlindex a18a09d..5ff6046 100644--- a/supabase/rollbacks/20261016101500_index_automation_comments_created_at.sql+++ b/supabase/rollbacks/20261016101500_index_automation_comments_created_at.sql@@ -1 +1,2 @@+-- removes the index the daily clean-up of comments usesdrop index if exists public.automation_comments_created_at_idx;diff --git a/supabase/rollbacks/20261016101600_create_automation_attempts.sql b/supabase/rollbacks/20261016101600_create_automation_attempts.sqlindex 5ec16dd..44fd78e 100644--- a/supabase/rollbacks/20261016101600_create_automation_attempts.sql+++ b/supabase/rollbacks/20261016101600_create_automation_attempts.sql@@ -1,2 +1,2 @@--- removes the record of every private reply request+-- removes automation_attempts and the record of every request sentdrop table if exists public.automation_attempts;diff --git a/supabase/rollbacks/20261016101700_revoke_browser_access_automation_attempts.sql b/supabase/rollbacks/20261016101700_revoke_browser_access_automation_attempts.sqlindex b9b9826..00008b7 100644--- a/supabase/rollbacks/20261016101700_revoke_browser_access_automation_attempts.sql+++ b/supabase/rollbacks/20261016101700_revoke_browser_access_automation_attempts.sql@@ -1,2 +1,2 @@--- the table had no browser grants before, because new tables in public start without them+-- turns row level security off on automation_attempts; it had no browser grants to give backalter table public.automation_attempts disable row level security;diff --git a/supabase/rollbacks/20261016101800_add_automation_attempts_updated_at_trigger.sql b/supabase/rollbacks/20261016101800_add_automation_attempts_updated_at_trigger.sqlindex 47dc20d..86d8b8e 100644--- a/supabase/rollbacks/20261016101800_add_automation_attempts_updated_at_trigger.sql+++ b/supabase/rollbacks/20261016101800_add_automation_attempts_updated_at_trigger.sql@@ -1 +1,2 @@+-- removes the trigger that keeps updated_at current on automation_attemptsdrop trigger if exists automation_attempts_set_updated_at on public.automation_attempts;diff --git a/supabase/rollbacks/20261016101900_index_automation_attempts_started_at.sql b/supabase/rollbacks/20261016101900_index_automation_attempts_started_at.sqlindex 85bb1eb..d4e322b 100644--- a/supabase/rollbacks/20261016101900_index_automation_attempts_started_at.sql+++ b/supabase/rollbacks/20261016101900_index_automation_attempts_started_at.sql@@ -1 +1,2 @@+-- removes the index that counts the instance's sendsdrop index if exists public.automation_attempts_started_at_idx;diff --git a/supabase/rollbacks/20261016102000_index_automation_attempts_user_id_started_at.sql b/supabase/rollbacks/20261016102000_index_automation_attempts_user_id_started_at.sqlindex 3d1f216..fa2553e 100644--- a/supabase/rollbacks/20261016102000_index_automation_attempts_user_id_started_at.sql+++ b/supabase/rollbacks/20261016102000_index_automation_attempts_user_id_started_at.sql@@ -1 +1,2 @@+-- removes the index that counts one user's sendsdrop index if exists public.automation_attempts_user_id_started_at_idx;diff --git a/supabase/rollbacks/20261016102100_index_automation_attempts_account_id_started_at.sql b/supabase/rollbacks/20261016102100_index_automation_attempts_account_id_started_at.sqlindex e97f9b5..803ad80 100644--- a/supabase/rollbacks/20261016102100_index_automation_attempts_account_id_started_at.sql+++ b/supabase/rollbacks/20261016102100_index_automation_attempts_account_id_started_at.sql@@ -1 +1,2 @@+-- removes the index that counts one account's sendsdrop index if exists public.automation_attempts_account_id_started_at_idx;diff --git a/supabase/rollbacks/20261016102200_index_automation_attempts_rule_id_started_at.sql b/supabase/rollbacks/20261016102200_index_automation_attempts_rule_id_started_at.sqlindex a857e8b..49d5b25 100644--- a/supabase/rollbacks/20261016102200_index_automation_attempts_rule_id_started_at.sql+++ b/supabase/rollbacks/20261016102200_index_automation_attempts_rule_id_started_at.sql@@ -1 +1,2 @@+-- removes the index that counts one rule's sendsdrop index if exists public.automation_attempts_rule_id_started_at_idx;diff --git a/supabase/rollbacks/20261016102300_index_automation_attempts_recipient.sql b/supabase/rollbacks/20261016102300_index_automation_attempts_recipient.sqlindex 7c72c15..facde82 100644--- a/supabase/rollbacks/20261016102300_index_automation_attempts_recipient.sql+++ b/supabase/rollbacks/20261016102300_index_automation_attempts_recipient.sql@@ -1 +1,2 @@+-- removes the index that counts replies to one persondrop index if exists public.automation_attempts_recipient_idx;diff --git a/supabase/rollbacks/20261016102400_index_automation_attempts_comment.sql b/supabase/rollbacks/20261016102400_index_automation_attempts_comment.sqlindex d0e9f6e..b6c5db6 100644--- a/supabase/rollbacks/20261016102400_index_automation_attempts_comment.sql+++ b/supabase/rollbacks/20261016102400_index_automation_attempts_comment.sql@@ -1 +1,2 @@+-- removes the index of attempts by commentdrop index if exists public.automation_attempts_comment_idx;diff --git a/supabase/rollbacks/20261016102500_create_audit_events.sql b/supabase/rollbacks/20261016102500_create_audit_events.sqlindex 57d3861..2e48ab0 100644--- a/supabase/rollbacks/20261016102500_create_audit_events.sql+++ b/supabase/rollbacks/20261016102500_create_audit_events.sql@@ -1,2 +1,2 @@--- removes the audit history of every user+-- removes audit_events and every user's audit historydrop table if exists public.audit_events;diff --git a/supabase/rollbacks/20261016102600_revoke_browser_access_audit_events.sql b/supabase/rollbacks/20261016102600_revoke_browser_access_audit_events.sqlindex c3f3c5d..4f3adb9 100644--- a/supabase/rollbacks/20261016102600_revoke_browser_access_audit_events.sql+++ b/supabase/rollbacks/20261016102600_revoke_browser_access_audit_events.sql@@ -1,2 +1,2 @@--- the table had no browser grants before, because new tables in public start without them+-- turns row level security off on audit_events; it had no browser grants to give backalter table public.audit_events disable row level security;diff --git a/supabase/rollbacks/20261016102700_add_audit_events_updated_at_trigger.sql b/supabase/rollbacks/20261016102700_add_audit_events_updated_at_trigger.sqlindex b0d9ba6..5dea58e 100644--- a/supabase/rollbacks/20261016102700_add_audit_events_updated_at_trigger.sql+++ b/supabase/rollbacks/20261016102700_add_audit_events_updated_at_trigger.sql@@ -1 +1,2 @@+-- removes the trigger that keeps updated_at current on audit_eventsdrop trigger if exists audit_events_set_updated_at on public.audit_events;diff --git a/supabase/rollbacks/20261016102800_index_audit_events_user_id_created_at.sql b/supabase/rollbacks/20261016102800_index_audit_events_user_id_created_at.sqlindex 781cebe..4db4b41 100644--- a/supabase/rollbacks/20261016102800_index_audit_events_user_id_created_at.sql+++ b/supabase/rollbacks/20261016102800_index_audit_events_user_id_created_at.sql@@ -1 +1,2 @@+-- removes the index that lists a user's audit eventsdrop index if exists public.audit_events_user_id_created_at_idx;diff --git a/supabase/rollbacks/20261016102900_index_audit_events_created_at.sql b/supabase/rollbacks/20261016102900_index_audit_events_created_at.sqlindex cd59465..26e523e 100644--- a/supabase/rollbacks/20261016102900_index_audit_events_created_at.sql+++ b/supabase/rollbacks/20261016102900_index_audit_events_created_at.sql@@ -1 +1,2 @@+-- removes the index the daily clean-up of audit events usesdrop index if exists public.audit_events_created_at_idx;diff --git a/supabase/rollbacks/20261016103000_index_accounts_instagram_user.sql b/supabase/rollbacks/20261016103000_index_accounts_instagram_user.sqlindex 1ffd193..dd98053 100644--- a/supabase/rollbacks/20261016103000_index_accounts_instagram_user.sql+++ b/supabase/rollbacks/20261016103000_index_accounts_instagram_user.sql@@ -1 +1,2 @@+-- removes the index of accounts by Instagram iddrop index if exists public.accounts_instagram_user_idx;diff --git a/supabase/rollbacks/20261016103100_create_automation_rules_for_ig_user_function.sql b/supabase/rollbacks/20261016103100_create_automation_rules_for_ig_user_function.sqlindex 6e46e3c..1b388ad 100644--- a/supabase/rollbacks/20261016103100_create_automation_rules_for_ig_user_function.sql+++ b/supabase/rollbacks/20261016103100_create_automation_rules_for_ig_user_function.sql@@ -1 +1,2 @@+-- removes automation_rules_for_ig_userdrop function if exists public.automation_rules_for_ig_user(text);diff --git a/supabase/rollbacks/20261016103200_create_claim_automation_comments_function.sql b/supabase/rollbacks/20261016103200_create_claim_automation_comments_function.sqlindex 5b92cb4..a1fc64a 100644--- a/supabase/rollbacks/20261016103200_create_claim_automation_comments_function.sql+++ b/supabase/rollbacks/20261016103200_create_claim_automation_comments_function.sql@@ -1 +1,2 @@+-- removes claim_automation_commentsdrop function if exists public.claim_automation_comments(integer, integer, integer, text[]);diff --git a/supabase/rollbacks/20261016103300_create_reserve_automation_send_function.sql b/supabase/rollbacks/20261016103300_create_reserve_automation_send_function.sqlindex ba58ed1..2c21d81 100644--- a/supabase/rollbacks/20261016103300_create_reserve_automation_send_function.sql+++ b/supabase/rollbacks/20261016103300_create_reserve_automation_send_function.sql@@ -1 +1,2 @@+-- removes reserve_automation_senddrop function if exists public.reserve_automation_send(text, text, integer, integer, integer, integer);diff --git a/supabase/rollbacks/20261016103400_create_finish_automation_send_function.sql b/supabase/rollbacks/20261016103400_create_finish_automation_send_function.sqlindex a5d3612..59213a9 100644--- a/supabase/rollbacks/20261016103400_create_finish_automation_send_function.sql+++ b/supabase/rollbacks/20261016103400_create_finish_automation_send_function.sql@@ -1 +1,2 @@+-- removes finish_automation_senddrop function if exists public.finish_automation_send(text, text, text, text, text, text, text, integer, integer, integer, timestamptz, timestamptz, text, text);diff --git a/supabase/rollbacks/20261016103500_create_automation_stats_function.sql b/supabase/rollbacks/20261016103500_create_automation_stats_function.sqlindex b6589ed..7453104 100644--- a/supabase/rollbacks/20261016103500_create_automation_stats_function.sql+++ b/supabase/rollbacks/20261016103500_create_automation_stats_function.sql@@ -1 +1,2 @@+-- removes automation_statsdrop function if exists public.automation_stats(uuid, timestamptz, timestamptz, text, text);diff --git a/supabase/rollbacks/20261016120000_alter_automation_rules_match_options.sql b/supabase/rollbacks/20261016120000_alter_automation_rules_match_options.sqlindex aa74b7a..68659cf 100644--- a/supabase/rollbacks/20261016120000_alter_automation_rules_match_options.sql+++ b/supabase/rollbacks/20261016120000_alter_automation_rules_match_options.sql@@ -1,4 +1,4 @@--- the old checks allow no any-comment rule, so those rules are removed first+-- removes the any-comment and followers-only rule options, deleting any-comment rules first because the old checks refuse themdelete from public.automation_rules where match_mode = 'any';alter table public.automation_rulesdrop constraint if exists automation_rules_follow_texts_check,diff --git a/supabase/rollbacks/20261016120100_alter_automation_comments_followup_review.sql b/supabase/rollbacks/20261016120100_alter_automation_comments_followup_review.sqlindex f1d2b66..1ce7fef 100644--- a/supabase/rollbacks/20261016120100_alter_automation_comments_followup_review.sql+++ b/supabase/rollbacks/20261016120100_alter_automation_comments_followup_review.sql@@ -1,3 +1,4 @@+-- removes the followers-only wait and review columns from automation_commentsalter table public.automation_commentsdrop constraint if exists automation_comments_review_checks_check,drop constraint if exists automation_comments_gate_prompts_check,diff --git a/supabase/rollbacks/20261016120200_alter_automation_accounts_limit_fields.sql b/supabase/rollbacks/20261016120200_alter_automation_accounts_limit_fields.sqlindex 3040044..6091688 100644--- a/supabase/rollbacks/20261016120200_alter_automation_accounts_limit_fields.sql+++ b/supabase/rollbacks/20261016120200_alter_automation_accounts_limit_fields.sql@@ -1,3 +1,4 @@+-- removes the hourly limit marker and the webhook fields from automation_accountsalter table public.automation_accountsdrop column if exists subscribed_fields,drop column if exists limited_until;diff --git a/supabase/rollbacks/20261016120300_create_automation_followups.sql b/supabase/rollbacks/20261016120300_create_automation_followups.sqlindex fe06fa8..f3176c2 100644--- a/supabase/rollbacks/20261016120300_create_automation_followups.sql+++ b/supabase/rollbacks/20261016120300_create_automation_followups.sql@@ -1,2 +1,2 @@--- removes every follow-up; roll back the automation_attempts change first+-- removes automation_followups and every follow-up; roll back the automation_attempts kind change firstdrop table if exists public.automation_followups;diff --git a/supabase/rollbacks/20261016120400_revoke_browser_access_automation_followups.sql b/supabase/rollbacks/20261016120400_revoke_browser_access_automation_followups.sqlindex b7bba42..dee910f 100644--- a/supabase/rollbacks/20261016120400_revoke_browser_access_automation_followups.sql+++ b/supabase/rollbacks/20261016120400_revoke_browser_access_automation_followups.sql@@ -1,2 +1,2 @@--- the table had no browser grants before, because new tables in public start without them+-- turns row level security off on automation_followups; it had no browser grants to give backalter table public.automation_followups disable row level security;diff --git a/supabase/rollbacks/20261016120500_add_automation_followups_updated_at_trigger.sql b/supabase/rollbacks/20261016120500_add_automation_followups_updated_at_trigger.sqlindex c17d0f6..85d2281 100644--- a/supabase/rollbacks/20261016120500_add_automation_followups_updated_at_trigger.sql+++ b/supabase/rollbacks/20261016120500_add_automation_followups_updated_at_trigger.sql@@ -1 +1,2 @@+-- removes the trigger that keeps updated_at current on automation_followupsdrop trigger if exists automation_followups_set_updated_at on public.automation_followups;diff --git a/supabase/rollbacks/20261016120600_index_automation_followups_due.sql b/supabase/rollbacks/20261016120600_index_automation_followups_due.sqlindex 41c1cc2..b202d5e 100644--- a/supabase/rollbacks/20261016120600_index_automation_followups_due.sql+++ b/supabase/rollbacks/20261016120600_index_automation_followups_due.sql@@ -1 +1,2 @@+-- removes the index of follow-ups waiting to be sentdrop index if exists public.automation_followups_due_idx;diff --git a/supabase/rollbacks/20261016120700_index_automation_followups_claimed.sql b/supabase/rollbacks/20261016120700_index_automation_followups_claimed.sqlindex 400a7a9..74c60e6 100644--- a/supabase/rollbacks/20261016120700_index_automation_followups_claimed.sql+++ b/supabase/rollbacks/20261016120700_index_automation_followups_claimed.sql@@ -1 +1,2 @@+-- removes the index of follow-ups held by a rundrop index if exists public.automation_followups_claimed_idx;diff --git a/supabase/rollbacks/20261016120800_index_automation_followups_open_comment.sql b/supabase/rollbacks/20261016120800_index_automation_followups_open_comment.sqlindex 83fbd56..1f7b206 100644--- a/supabase/rollbacks/20261016120800_index_automation_followups_open_comment.sql+++ b/supabase/rollbacks/20261016120800_index_automation_followups_open_comment.sql@@ -1 +1,2 @@+-- removes the one open follow-up per comment ruledrop index if exists public.automation_followups_open_comment_key;diff --git a/supabase/rollbacks/20261016120900_index_automation_followups_comment_id.sql b/supabase/rollbacks/20261016120900_index_automation_followups_comment_id.sqlindex 665b9c7..5914087 100644--- a/supabase/rollbacks/20261016120900_index_automation_followups_comment_id.sql+++ b/supabase/rollbacks/20261016120900_index_automation_followups_comment_id.sql@@ -1 +1,2 @@+-- removes the index of follow-ups by commentdrop index if exists public.automation_followups_comment_id_idx;diff --git a/supabase/rollbacks/20261016121000_alter_automation_attempts_kind_digest.sql b/supabase/rollbacks/20261016121000_alter_automation_attempts_kind_digest.sqlindex c2316a5..f898401 100644--- a/supabase/rollbacks/20261016121000_alter_automation_attempts_kind_digest.sql+++ b/supabase/rollbacks/20261016121000_alter_automation_attempts_kind_digest.sql@@ -1,4 +1,4 @@--- follow-up attempts have no place in the old table, so they are removed first+-- removes the attempt kind and digest from automation_attempts, deleting follow-up attempts first because the old table cannot hold themdelete from public.automation_attempts where kind = 'followup';alter table public.automation_attemptsdrop constraint if exists automation_attempts_followup_check,diff --git a/supabase/rollbacks/20261016121100_index_automation_comments_due_by_account.sql b/supabase/rollbacks/20261016121100_index_automation_comments_due_by_account.sqlindex 13d7851..4b1bb03 100644--- a/supabase/rollbacks/20261016121100_index_automation_comments_due_by_account.sql+++ b/supabase/rollbacks/20261016121100_index_automation_comments_due_by_account.sql@@ -1 +1,2 @@+-- removes the index of due replies by accountdrop index if exists public.automation_comments_due_account_idx;diff --git a/supabase/rollbacks/20261016121200_index_automation_comments_awaiting_reply.sql b/supabase/rollbacks/20261016121200_index_automation_comments_awaiting_reply.sqlindex f9e79cc..235942c 100644--- a/supabase/rollbacks/20261016121200_index_automation_comments_awaiting_reply.sql+++ b/supabase/rollbacks/20261016121200_index_automation_comments_awaiting_reply.sql@@ -1 +1,2 @@+-- removes the index of replies waiting for an answerdrop index if exists public.automation_comments_awaiting_reply_idx;diff --git a/supabase/rollbacks/20261016121300_index_automation_comments_needs_review.sql b/supabase/rollbacks/20261016121300_index_automation_comments_needs_review.sqlindex df9259f..f560ec9 100644--- a/supabase/rollbacks/20261016121300_index_automation_comments_needs_review.sql+++ b/supabase/rollbacks/20261016121300_index_automation_comments_needs_review.sql@@ -1 +1,2 @@+-- removes the index of replies that need reviewdrop index if exists public.automation_comments_needs_review_idx;diff --git a/supabase/rollbacks/20261016121400_replace_claim_automation_comments_function.sql b/supabase/rollbacks/20261016121400_replace_claim_automation_comments_function.sqlindex aa9b47e..1da15b8 100644--- a/supabase/rollbacks/20261016121400_replace_claim_automation_comments_function.sql+++ b/supabase/rollbacks/20261016121400_replace_claim_automation_comments_function.sql@@ -1,4 +1,4 @@--- puts back the claim from 20261016103200, which takes the oldest due jobs and at most p_per_account per account+-- puts back the earlier claim_automation_comments, where accounts do not take turnsdrop function if exists public.claim_automation_comments(integer, integer, integer, text[]);create or replace function public.claim_automation_comments(p_limit integer,diff --git a/supabase/rollbacks/20261016121500_replace_reserve_automation_send_function.sql b/supabase/rollbacks/20261016121500_replace_reserve_automation_send_function.sqlindex 6c74f3b..81ad4c7 100644--- a/supabase/rollbacks/20261016121500_replace_reserve_automation_send_function.sql+++ b/supabase/rollbacks/20261016121500_replace_reserve_automation_send_function.sql@@ -1,4 +1,4 @@--- puts back the reservation from 20261016103300, which counts every attempt and marks no account as limited+-- puts back the earlier reserve_automation_send, which counts every attemptdrop function if exists public.reserve_automation_send(text, text, integer, integer, integer, integer, text);create or replace function public.reserve_automation_send(p_id text,diff --git a/supabase/rollbacks/20261016121600_replace_finish_automation_send_function.sql b/supabase/rollbacks/20261016121600_replace_finish_automation_send_function.sqlindex accbe59..dd093a5 100644--- a/supabase/rollbacks/20261016121600_replace_finish_automation_send_function.sql+++ b/supabase/rollbacks/20261016121600_replace_finish_automation_send_function.sql@@ -1,4 +1,4 @@--- puts back the finish from 20261016103400, which keeps no recipient and starts no followers-only wait+-- puts back the earlier finish_automation_send, without the recipient or the followers-only waitdrop function if exists public.finish_automation_send(text, text, text, text, text, text, text, integer, integer, integer, timestamptz, timestamptz, text, text, text, text);create or replace function public.finish_automation_send(p_id text,diff --git a/supabase/rollbacks/20261016121700_create_automation_followups_for_messages_function.sql b/supabase/rollbacks/20261016121700_create_automation_followups_for_messages_function.sqlindex 1dd2cc4..bda8604 100644--- a/supabase/rollbacks/20261016121700_create_automation_followups_for_messages_function.sql+++ b/supabase/rollbacks/20261016121700_create_automation_followups_for_messages_function.sql@@ -1 +1,2 @@+-- removes automation_followups_for_messagesdrop function if exists public.automation_followups_for_messages(text, jsonb);diff --git a/supabase/rollbacks/20261016121800_create_claim_automation_followups_function.sql b/supabase/rollbacks/20261016121800_create_claim_automation_followups_function.sqlindex 9a19c21..20edec1 100644--- a/supabase/rollbacks/20261016121800_create_claim_automation_followups_function.sql+++ b/supabase/rollbacks/20261016121800_create_claim_automation_followups_function.sql@@ -1 +1,2 @@+-- removes claim_automation_followupsdrop function if exists public.claim_automation_followups(integer, integer, text[]);diff --git a/supabase/rollbacks/20261016121900_create_reserve_automation_followup_function.sql b/supabase/rollbacks/20261016121900_create_reserve_automation_followup_function.sqlindex 0cbbce0..7294a10 100644--- a/supabase/rollbacks/20261016121900_create_reserve_automation_followup_function.sql+++ b/supabase/rollbacks/20261016121900_create_reserve_automation_followup_function.sql@@ -1 +1,2 @@+-- removes reserve_automation_followupdrop function if exists public.reserve_automation_followup(text, text, text, text);diff --git a/supabase/rollbacks/20261016122000_create_finish_automation_followup_function.sql b/supabase/rollbacks/20261016122000_create_finish_automation_followup_function.sqlindex c0101d2..feef6d4 100644--- a/supabase/rollbacks/20261016122000_create_finish_automation_followup_function.sql+++ b/supabase/rollbacks/20261016122000_create_finish_automation_followup_function.sql@@ -1 +1,2 @@+-- removes finish_automation_followupdrop function if exists public.finish_automation_followup(text, text, text, text, text, text, text, integer, integer, integer, timestamptz, timestamptz, text, text, text, boolean);diff --git a/supabase/rollbacks/20261016122100_create_automation_review_candidates_function.sql b/supabase/rollbacks/20261016122100_create_automation_review_candidates_function.sqlindex ef3294c..ba90a2c 100644--- a/supabase/rollbacks/20261016122100_create_automation_review_candidates_function.sql+++ b/supabase/rollbacks/20261016122100_create_automation_review_candidates_function.sql@@ -1 +1,2 @@+-- removes automation_review_candidatesdrop function if exists public.automation_review_candidates(integer, integer, integer, integer);diff --git a/supabase/rollbacks/20261016122200_create_record_automation_review_function.sql b/supabase/rollbacks/20261016122200_create_record_automation_review_function.sqlindex 639c143..9e53488 100644--- a/supabase/rollbacks/20261016122200_create_record_automation_review_function.sql+++ b/supabase/rollbacks/20261016122200_create_record_automation_review_function.sql@@ -1 +1,2 @@+-- removes record_automation_reviewdrop function if exists public.record_automation_review(text, boolean, text, timestamptz, text);diff --git a/supabase/rollbacks/20261016122300_create_expire_automation_jobs_function.sql b/supabase/rollbacks/20261016122300_create_expire_automation_jobs_function.sqlindex 3c16649..f1aa75b 100644--- a/supabase/rollbacks/20261016122300_create_expire_automation_jobs_function.sql+++ b/supabase/rollbacks/20261016122300_create_expire_automation_jobs_function.sql@@ -1 +1,2 @@+-- removes expire_automation_jobsdrop function if exists public.expire_automation_jobs(integer);diff --git a/supabase/rollbacks/20261016122400_create_purge_automation_comments_function.sql b/supabase/rollbacks/20261016122400_create_purge_automation_comments_function.sqlindex 1446de2..89f61ac 100644--- a/supabase/rollbacks/20261016122400_create_purge_automation_comments_function.sql+++ b/supabase/rollbacks/20261016122400_create_purge_automation_comments_function.sql@@ -1 +1,2 @@+-- removes purge_automation_commentsdrop function if exists public.purge_automation_comments(timestamptz, integer);diff --git a/supabase/rollbacks/20261016122500_create_automation_queue_health_function.sql b/supabase/rollbacks/20261016122500_create_automation_queue_health_function.sqlindex eacfd23..1f4f43d 100644--- a/supabase/rollbacks/20261016122500_create_automation_queue_health_function.sql+++ b/supabase/rollbacks/20261016122500_create_automation_queue_health_function.sql@@ -1 +1,2 @@+-- removes automation_queue_healthdrop function if exists public.automation_queue_health(integer);diff --git a/supabase/rollbacks/20261016130000_alter_automation_rules_reply_actions.sql b/supabase/rollbacks/20261016130000_alter_automation_rules_reply_actions.sqlindex 8b6c14e..b950fe5 100644--- a/supabase/rollbacks/20261016130000_alter_automation_rules_reply_actions.sql+++ b/supabase/rollbacks/20261016130000_alter_automation_rules_reply_actions.sql@@ -1,4 +1,4 @@--- a rule without the private reply has no place in the old shape, so such rules are removed first+-- removes the public reply options from automation_rules, deleting rules without a private reply first because the old shape refuses themdelete from public.automation_rules where not private_reply_enabled;alter table public.automation_rulesdrop constraint if exists automation_rules_follow_private_check,diff --git a/supabase/rollbacks/20261016130100_alter_automation_accounts_public_reply_fields.sql b/supabase/rollbacks/20261016130100_alter_automation_accounts_public_reply_fields.sqlindex 78c388d..2d20ee5 100644--- a/supabase/rollbacks/20261016130100_alter_automation_accounts_public_reply_fields.sql+++ b/supabase/rollbacks/20261016130100_alter_automation_accounts_public_reply_fields.sql@@ -1,3 +1,4 @@+-- removes the public reply cooldown and limit from automation_accountsalter table public.automation_accountsdrop constraint if exists automation_accounts_public_cooldown_reason_check,drop column if exists public_limited_until,diff --git a/supabase/rollbacks/20261016130200_create_automation_public_replies.sql b/supabase/rollbacks/20261016130200_create_automation_public_replies.sqlindex c5b00d3..05d9d61 100644--- a/supabase/rollbacks/20261016130200_create_automation_public_replies.sql+++ b/supabase/rollbacks/20261016130200_create_automation_public_replies.sql@@ -1,2 +1,2 @@--- removes every public reply; roll back the automation_attempts change first+-- removes automation_public_replies and every public reply; roll back the automation_attempts public reply change firstdrop table if exists public.automation_public_replies;diff --git a/supabase/rollbacks/20261016130300_revoke_browser_access_automation_public_replies.sql b/supabase/rollbacks/20261016130300_revoke_browser_access_automation_public_replies.sqlindex 897ad81..fe25519 100644--- a/supabase/rollbacks/20261016130300_revoke_browser_access_automation_public_replies.sql+++ b/supabase/rollbacks/20261016130300_revoke_browser_access_automation_public_replies.sql@@ -1 +1,2 @@+-- turns row level security off on automation_public_replies; it had no browser grants to give backalter table if exists public.automation_public_replies disable row level security;diff --git a/supabase/rollbacks/20261016130400_add_automation_public_replies_updated_at_trigger.sql b/supabase/rollbacks/20261016130400_add_automation_public_replies_updated_at_trigger.sqlindex 68f9756..975aad2 100644--- a/supabase/rollbacks/20261016130400_add_automation_public_replies_updated_at_trigger.sql+++ b/supabase/rollbacks/20261016130400_add_automation_public_replies_updated_at_trigger.sql@@ -1 +1,2 @@+-- removes the trigger that keeps updated_at current on automation_public_repliesdrop trigger if exists automation_public_replies_set_updated_at on public.automation_public_replies;diff --git a/supabase/rollbacks/20261016130500_index_automation_public_replies_due_by_account.sql b/supabase/rollbacks/20261016130500_index_automation_public_replies_due_by_account.sqlindex 8666346..cff0484 100644--- a/supabase/rollbacks/20261016130500_index_automation_public_replies_due_by_account.sql+++ b/supabase/rollbacks/20261016130500_index_automation_public_replies_due_by_account.sql@@ -1 +1,2 @@+-- removes the index of public replies waiting to be posteddrop index if exists public.automation_public_replies_due_account_idx;diff --git a/supabase/rollbacks/20261016130600_index_automation_public_replies_claimed.sql b/supabase/rollbacks/20261016130600_index_automation_public_replies_claimed.sqlindex 64f8a96..b0f06ad 100644--- a/supabase/rollbacks/20261016130600_index_automation_public_replies_claimed.sql+++ b/supabase/rollbacks/20261016130600_index_automation_public_replies_claimed.sql@@ -1 +1,2 @@+-- removes the index of public replies held by a rundrop index if exists public.automation_public_replies_claimed_idx;diff --git a/supabase/rollbacks/20261016130700_index_automation_public_replies_needs_review.sql b/supabase/rollbacks/20261016130700_index_automation_public_replies_needs_review.sqlindex d46df96..323870e 100644--- a/supabase/rollbacks/20261016130700_index_automation_public_replies_needs_review.sql+++ b/supabase/rollbacks/20261016130700_index_automation_public_replies_needs_review.sql@@ -1 +1,2 @@+-- removes the index of public replies that need reviewdrop index if exists public.automation_public_replies_needs_review_idx;diff --git a/supabase/rollbacks/20261016130800_index_automation_public_replies_recipient.sql b/supabase/rollbacks/20261016130800_index_automation_public_replies_recipient.sqlindex 79d26c1..73fd601 100644--- a/supabase/rollbacks/20261016130800_index_automation_public_replies_recipient.sql+++ b/supabase/rollbacks/20261016130800_index_automation_public_replies_recipient.sql@@ -1 +1,2 @@+-- removes the index of public replies by person and postdrop index if exists public.automation_public_replies_recipient_idx;diff --git a/supabase/rollbacks/20261016130850_index_automation_public_replies_user_created.sql b/supabase/rollbacks/20261016130850_index_automation_public_replies_user_created.sqlindex db7fdf3..8d4cb85 100644--- a/supabase/rollbacks/20261016130850_index_automation_public_replies_user_created.sql+++ b/supabase/rollbacks/20261016130850_index_automation_public_replies_user_created.sql@@ -1 +1,2 @@+-- removes the index that counts a user's public repliesdrop index if exists public.automation_public_replies_user_created_idx;diff --git a/supabase/rollbacks/20261016130900_alter_automation_attempts_public_reply.sql b/supabase/rollbacks/20261016130900_alter_automation_attempts_public_reply.sqlindex 42f058a..1dfe58a 100644--- a/supabase/rollbacks/20261016130900_alter_automation_attempts_public_reply.sql+++ b/supabase/rollbacks/20261016130900_alter_automation_attempts_public_reply.sql@@ -1,4 +1,4 @@--- public reply attempts have no place in the old table, so they are removed first+-- removes the public reply kind from automation_attempts, deleting public reply attempts first because the old table cannot hold themdelete from public.automation_attempts where kind = 'public_reply';alter table public.automation_attemptsdrop constraint if exists automation_attempts_public_reply_check,diff --git a/supabase/rollbacks/20261016131000_index_automation_attempts_public_reply.sql b/supabase/rollbacks/20261016131000_index_automation_attempts_public_reply.sqlindex 272fd0e..7371ca6 100644--- a/supabase/rollbacks/20261016131000_index_automation_attempts_public_reply.sql+++ b/supabase/rollbacks/20261016131000_index_automation_attempts_public_reply.sql@@ -1 +1,2 @@+-- removes the index of attempts by public replydrop index if exists public.automation_attempts_public_reply_idx;diff --git a/supabase/rollbacks/20261016131100_replace_automation_rules_for_ig_user_function.sql b/supabase/rollbacks/20261016131100_replace_automation_rules_for_ig_user_function.sqlindex c19fcf7..18375dc 100644--- a/supabase/rollbacks/20261016131100_replace_automation_rules_for_ig_user_function.sql+++ b/supabase/rollbacks/20261016131100_replace_automation_rules_for_ig_user_function.sql@@ -1,4 +1,4 @@--- puts back the function from 20261016103100, without the public reply columns+-- puts back the earlier automation_rules_for_ig_user, without the public reply settingsdrop function if exists public.automation_rules_for_ig_user(text);-- the enabled rules of every connected account a webhook's Instagram account id belongs to, oldest account firstcreate or replace function public.automation_rules_for_ig_user(p_ig_user_id text)diff --git a/supabase/rollbacks/20261016131200_create_store_automation_comments_function.sql b/supabase/rollbacks/20261016131200_create_store_automation_comments_function.sqlindex bdb03d8..1b73e32 100644--- a/supabase/rollbacks/20261016131200_create_store_automation_comments_function.sql+++ b/supabase/rollbacks/20261016131200_create_store_automation_comments_function.sql@@ -1 +1,2 @@+-- removes store_automation_commentsdrop function if exists public.store_automation_comments(jsonb);diff --git a/supabase/rollbacks/20261016131300_create_claim_automation_public_replies_function.sql b/supabase/rollbacks/20261016131300_create_claim_automation_public_replies_function.sqlindex 0c750fd..805fd11 100644--- a/supabase/rollbacks/20261016131300_create_claim_automation_public_replies_function.sql+++ b/supabase/rollbacks/20261016131300_create_claim_automation_public_replies_function.sql@@ -1 +1,2 @@+-- removes claim_automation_public_repliesdrop function if exists public.claim_automation_public_replies(integer, integer, integer, text[]);diff --git a/supabase/rollbacks/20261016131400_create_reserve_automation_public_reply_function.sql b/supabase/rollbacks/20261016131400_create_reserve_automation_public_reply_function.sqlindex 3d50876..21337a5 100644--- a/supabase/rollbacks/20261016131400_create_reserve_automation_public_reply_function.sql+++ b/supabase/rollbacks/20261016131400_create_reserve_automation_public_reply_function.sql@@ -1 +1,2 @@+-- removes reserve_automation_public_replydrop function if exists public.reserve_automation_public_reply(text, text, integer, text);diff --git a/supabase/rollbacks/20261016131500_create_finish_automation_public_reply_function.sql b/supabase/rollbacks/20261016131500_create_finish_automation_public_reply_function.sqlindex 6753812..04f2f10 100644--- a/supabase/rollbacks/20261016131500_create_finish_automation_public_reply_function.sql+++ b/supabase/rollbacks/20261016131500_create_finish_automation_public_reply_function.sql@@ -1 +1,2 @@+-- removes finish_automation_public_replydrop function if exists public.finish_automation_public_reply(text, text, text, text, text, text, text, integer, integer, integer, timestamptz, timestamptz, text, text);diff --git a/supabase/rollbacks/20261016131600_create_automation_public_review_candidates_function.sql b/supabase/rollbacks/20261016131600_create_automation_public_review_candidates_function.sqlindex f0b96ef..7cabe5d 100644--- a/supabase/rollbacks/20261016131600_create_automation_public_review_candidates_function.sql+++ b/supabase/rollbacks/20261016131600_create_automation_public_review_candidates_function.sql@@ -1 +1,2 @@+-- removes automation_public_review_candidatesdrop function if exists public.automation_public_review_candidates(integer, integer, integer, integer);diff --git a/supabase/rollbacks/20261016131700_create_record_automation_public_review_function.sql b/supabase/rollbacks/20261016131700_create_record_automation_public_review_function.sqlindex 2a8f67d..a76a7a9 100644--- a/supabase/rollbacks/20261016131700_create_record_automation_public_review_function.sql+++ b/supabase/rollbacks/20261016131700_create_record_automation_public_review_function.sql@@ -1 +1,2 @@+-- removes record_automation_public_reviewdrop function if exists public.record_automation_public_review(text, boolean, text, timestamptz, text, boolean);diff --git a/supabase/rollbacks/20261016131800_replace_expire_automation_jobs_function.sql b/supabase/rollbacks/20261016131800_replace_expire_automation_jobs_function.sqlindex 7f877ac..1719c48 100644--- a/supabase/rollbacks/20261016131800_replace_expire_automation_jobs_function.sql+++ b/supabase/rollbacks/20261016131800_replace_expire_automation_jobs_function.sql@@ -1,6 +1,4 @@--- puts back the function from 20261016122300, without the public reply columns--- expires up to p_limit replies whose 7 days ran out and up to p_limit follow-ups whose 24 hours ran out, without a--- run claiming each one; rows a run holds are skipped and settled by that run+-- puts back the earlier expire_automation_jobs, without public repliescreate or replace function public.expire_automation_jobs(p_limit integer)returns jsonblanguage sqldiff --git a/supabase/rollbacks/20261016131900_replace_automation_queue_health_function.sql b/supabase/rollbacks/20261016131900_replace_automation_queue_health_function.sqlindex 4dbf28a..6de108e 100644--- a/supabase/rollbacks/20261016131900_replace_automation_queue_health_function.sql+++ b/supabase/rollbacks/20261016131900_replace_automation_queue_health_function.sql@@ -1,6 +1,4 @@--- puts back the function from 20261016122500, without the public reply columns--- the instance's reply queue in one call, each count read through its own partial index: jobs due now and the oldest--- of them, jobs held by runs that stopped, replies that need review, follow-ups due, and accounts that are held+-- puts back the earlier automation_queue_health, without public repliescreate or replace function public.automation_queue_health(p_lease_seconds integer)returns jsonblanguage sqldiff --git a/supabase/rollbacks/20261016132000_replace_automation_stats_function.sql b/supabase/rollbacks/20261016132000_replace_automation_stats_function.sqlindex a331350..09ab9ea 100644--- a/supabase/rollbacks/20261016132000_replace_automation_stats_function.sql+++ b/supabase/rollbacks/20261016132000_replace_automation_stats_function.sql@@ -1,6 +1,4 @@--- puts back the function from 20261016103500, without the public reply columns--- one user's comment counts by status and request counts by outcome for a period, counted in the database--- instead of loading every row; p_account_id and p_rule_id narrow it when set+-- puts back the earlier automation_stats, without public repliescreate or replace function public.automation_stats(p_user_id uuid,p_from timestamptz,diff --git a/supabase/rollbacks/20261016132100_replace_claim_automation_comments_private_reply.sql b/supabase/rollbacks/20261016132100_replace_claim_automation_comments_private_reply.sqlindex 153f415..df38fab 100644--- a/supabase/rollbacks/20261016132100_replace_claim_automation_comments_private_reply.sql+++ b/supabase/rollbacks/20261016132100_replace_claim_automation_comments_private_reply.sql@@ -1,4 +1,4 @@--- puts back the claim from 20261016121400, which ignores whether the rule still sends a private reply+-- puts back the earlier claim_automation_comments, which ignores whether the private reply is oncreate or replace function public.claim_automation_comments(p_limit integer,p_per_account integer,diff --git a/supabase/rollbacks/20261017171632_index_accounts_identity.sql b/supabase/rollbacks/20261017171632_index_accounts_identity.sqlindex 9fb227c..30cfb82 100644--- a/supabase/rollbacks/20261017171632_index_accounts_identity.sql+++ b/supabase/rollbacks/20261017171632_index_accounts_identity.sql@@ -1 +1,2 @@+-- removes the rule that allows each account only once per userdrop index if exists public.accounts_identity_key;