Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.
chore(db): commit the schema generated after applying the 3.1.0 and 3.2.0 migrations
spacesdrivea3d04e8a0f36
diff --git a/supabase/schemas/.pgdelta-export.json b/supabase/schemas/.pgdelta-export.jsonindex f88353e..1c9b340 100644--- a/supabase/schemas/.pgdelta-export.json+++ b/supabase/schemas/.pgdelta-export.json@@ -15,9 +15,9 @@"public/tables/automation_followups.sql","public/tables/automation_public_replies.sql","public/tables/automation_rules.sql",- "public/tables/media_assets.sql","public/tables/mcp_access_tokens.sql","public/tables/mcp_client_grants.sql",+ "public/tables/media_assets.sql","public/tables/scheduled_posts.sql","public/tables/settings.sql","public/tables/tracked_posts.sql",@@ -30,10 +30,10 @@"public/functions/automation_review_candidates.sql","public/functions/automation_rules_for_ig_user.sql","public/functions/automation_stats.sql",- "public/functions/claim_youtube_upload.sql","public/functions/claim_automation_comments.sql","public/functions/claim_automation_followups.sql","public/functions/claim_automation_public_replies.sql",+ "public/functions/claim_youtube_upload.sql","public/functions/expire_automation_jobs.sql","public/functions/finish_automation_followup.sql","public/functions/finish_automation_public_reply.sql",@@ -42,12 +42,12 @@"public/functions/merge_scheduled_post.sql","public/functions/merge_tracked_post_data.sql","public/functions/purge_automation_comments.sql",- "public/functions/reserve_youtube_quota.sql","public/functions/record_automation_public_review.sql","public/functions/record_automation_review.sql","public/functions/reserve_automation_followup.sql","public/functions/reserve_automation_public_reply.sql","public/functions/reserve_automation_send.sql",+ "public/functions/reserve_youtube_quota.sql","public/functions/set_updated_at.sql","public/functions/store_automation_comments.sql","public/default_privileges.sql"@@ -65,10 +65,10 @@"public/functions/automation_review_candidates.sql","public/functions/automation_rules_for_ig_user.sql","public/functions/automation_stats.sql",- "public/functions/claim_youtube_upload.sql","public/functions/claim_automation_comments.sql","public/functions/claim_automation_followups.sql","public/functions/claim_automation_public_replies.sql",+ "public/functions/claim_youtube_upload.sql","public/functions/expire_automation_jobs.sql","public/functions/finish_automation_followup.sql","public/functions/finish_automation_public_reply.sql",@@ -77,12 +77,12 @@"public/functions/merge_scheduled_post.sql","public/functions/merge_tracked_post_data.sql","public/functions/purge_automation_comments.sql",- "public/functions/reserve_youtube_quota.sql","public/functions/record_automation_public_review.sql","public/functions/record_automation_review.sql","public/functions/reserve_automation_followup.sql","public/functions/reserve_automation_public_reply.sql","public/functions/reserve_automation_send.sql",+ "public/functions/reserve_youtube_quota.sql","public/functions/set_updated_at.sql","public/functions/store_automation_comments.sql","public/schema.sql",@@ -94,9 +94,9 @@"public/tables/automation_followups.sql","public/tables/automation_public_replies.sql","public/tables/automation_rules.sql",- "public/tables/media_assets.sql","public/tables/mcp_access_tokens.sql","public/tables/mcp_client_grants.sql",+ "public/tables/media_assets.sql","public/tables/scheduled_posts.sql","public/tables/settings.sql","public/tables/tracked_posts.sql",diff --git a/supabase/schemas/public/functions/claim_youtube_upload.sql b/supabase/schemas/public/functions/claim_youtube_upload.sqlindex a50188f..e9b3d3c 100644--- a/supabase/schemas/public/functions/claim_youtube_upload.sql+++ b/supabase/schemas/public/functions/claim_youtube_upload.sql@@ -1,8 +1,11 @@-create or replace function public.claim_youtube_upload(p_owner text, p_lease_seconds integer)-returns setof public.youtube_uploads-language plpgsql-set search_path = ''-as $$+CREATE OR REPLACE FUNCTION public.claim_youtube_upload (+ p_owner text,+ p_lease_seconds integer+)+ RETURNS SETOF public.youtube_uploads+ LANGUAGE plpgsql+ SET search_path TO ''+ AS $function$beginreturn queryupdate public.youtube_uploads u@@ -18,7 +21,7 @@ begin)returning u.*;end;-$$;+$function$;GRANT EXECUTE ON FUNCTION "public"."claim_youtube_upload"(text, integer) TO "service_role";diff --git a/supabase/schemas/public/functions/reserve_youtube_quota.sql b/supabase/schemas/public/functions/reserve_youtube_quota.sqlindex 0f56928..cb7c34f 100644--- a/supabase/schemas/public/functions/reserve_youtube_quota.sql+++ b/supabase/schemas/public/functions/reserve_youtube_quota.sql@@ -1,8 +1,13 @@-create or replace function public.reserve_youtube_quota(p_day date, p_bucket text, p_units integer, p_limit integer)-returns boolean-language plpgsql-set search_path = ''-as $$+CREATE OR REPLACE FUNCTION public.reserve_youtube_quota (+ p_day date,+ p_bucket text,+ p_units integer,+ p_limit integer+)+ RETURNS boolean+ LANGUAGE plpgsql+ SET search_path TO ''+ AS $function$declarereserved integer;begin@@ -20,7 +25,7 @@ beginend if;return true;end;-$$;+$function$;GRANT EXECUTE ON FUNCTION "public"."reserve_youtube_quota"(date, text, integer, integer) TO "service_role";diff --git a/supabase/schemas/public/tables/youtube_connections.sql b/supabase/schemas/public/tables/youtube_connections.sqlindex 0cbd3e7..d78af7b 100644--- a/supabase/schemas/public/tables/youtube_connections.sql+++ b/supabase/schemas/public/tables/youtube_connections.sql@@ -1,22 +1,21 @@-create table public.youtube_connections (- id text primary key,- user_id uuid not null references auth.users (id) on delete cascade,- -- the analytics account for the same channel, when the person has one- account_id text,- channel_id text not null,- channel_title text not null default '',- scopes text[] not null default '{}',- status text not null default 'active',- -- AES-GCM sealed with a key derived from TOKEN_ENCRYPTION_KEY; never sent to a browser, a log or Claude- refresh_token_enc text not null,- access_token_enc text,- access_token_expires_at timestamptz,- created_at timestamptz not null default now(),- updated_at timestamptz not null default now(),- constraint youtube_connections_user_channel_key unique (user_id, channel_id),- constraint youtube_connections_status_check check (status in ('active', 'needs_reconnect')),- constraint youtube_connections_account_fkey foreign key (account_id, user_id)- references public.accounts (id, user_id) on delete set null (account_id)+CREATE TABLE "public"."youtube_connections" (+ "id" text NOT NULL,+ "user_id" uuid NOT NULL,+ "account_id" text,+ "channel_id" text NOT NULL,+ "channel_title" text NOT NULL DEFAULT ''::text,+ "scopes" text[] NOT NULL DEFAULT '{}'::text[],+ "status" text NOT NULL DEFAULT 'active'::text,+ "refresh_token_enc" text NOT NULL,+ "access_token_enc" text,+ "access_token_expires_at" timestamp with time zone,+ "created_at" timestamp with time zone NOT NULL DEFAULT now(),+ "updated_at" timestamp with time zone NOT NULL DEFAULT now(),+ CONSTRAINT "youtube_connections_account_fkey" FOREIGN KEY (account_id, user_id) REFERENCES public.accounts(id, user_id) ON DELETE SET NULL (account_id),+ CONSTRAINT "youtube_connections_pkey" PRIMARY KEY (id),+ CONSTRAINT "youtube_connections_status_check" CHECK ((status = ANY (ARRAY['active'::text, 'needs_reconnect'::text]))),+ CONSTRAINT "youtube_connections_user_channel_key" UNIQUE (user_id, channel_id),+ CONSTRAINT "youtube_connections_user_id_fkey" FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE);ALTER TABLE "public"."youtube_connections"diff --git a/supabase/schemas/public/tables/youtube_quota_usage.sql b/supabase/schemas/public/tables/youtube_quota_usage.sqlindex a18c4d6..e11b46f 100644--- a/supabase/schemas/public/tables/youtube_quota_usage.sql+++ b/supabase/schemas/public/tables/youtube_quota_usage.sql@@ -1,11 +1,10 @@-create table public.youtube_quota_usage (- day date not null,- -- uploads: videos.insert calls, 100 a day; default: every other call, 10,000 units a day- bucket text not null,- units integer not null default 0,- constraint youtube_quota_usage_pkey primary key (day, bucket),- constraint youtube_quota_usage_bucket_check check (bucket in ('uploads', 'default')),- constraint youtube_quota_usage_units_check check (units >= 0)+CREATE TABLE "public"."youtube_quota_usage" (+ "day" date NOT NULL,+ "bucket" text NOT NULL,+ "units" integer NOT NULL DEFAULT 0,+ CONSTRAINT "youtube_quota_usage_bucket_check" CHECK ((bucket = ANY (ARRAY['uploads'::text, 'default'::text]))),+ CONSTRAINT "youtube_quota_usage_pkey" PRIMARY KEY (day, bucket),+ CONSTRAINT "youtube_quota_usage_units_check" CHECK ((units >= 0)));ALTER TABLE "public"."youtube_quota_usage"diff --git a/supabase/schemas/public/tables/youtube_uploads.sql b/supabase/schemas/public/tables/youtube_uploads.sqlindex 32895e8..fa07423 100644--- a/supabase/schemas/public/tables/youtube_uploads.sql+++ b/supabase/schemas/public/tables/youtube_uploads.sql@@ -1,51 +1,54 @@-create table public.youtube_uploads (- id text primary key,- user_id uuid not null references auth.users (id) on delete cascade,- connection_id text not null references public.youtube_connections (id) on delete cascade,- -- the source on the instance's Cloudinary account, read in byte ranges- source_url text not null,- source_bytes bigint not null,- content_type text not null,- thumbnail_url text,- is_short boolean not null default false,- -- a snapshot of what the person asked for; editing is only possible before the upload starts- title text not null,- description text not null default '',- tags text[] not null default '{}',- category_id text not null default '22',- privacy text not null,- publish_at timestamptz,- made_for_kids boolean not null default false,- synthetic_media boolean not null default false,- notify_subscribers boolean not null default true,- state text not null default 'queued',- -- saved before any bytes are sent, so a lost answer never starts a second upload of the same video- session_uri text,- bytes_confirmed bigint not null default 0,- video_id text,- attempts integer not null default 0,- next_attempt_at timestamptz not null default now(),- lease_owner text,- lease_until timestamptz,- last_error text,- client_request_id text,- created_at timestamptz not null default now(),- updated_at timestamptz not null default now(),- constraint youtube_uploads_user_request_key unique (user_id, client_request_id),- constraint youtube_uploads_state_check check (state in ('queued', 'uploading', 'processing', 'finalizing', 'done', 'waiting_quota', 'needs_reconnect', 'needs_review', 'failed', 'cancelled')),- constraint youtube_uploads_privacy_check check (privacy in ('private', 'unlisted', 'public')),- constraint youtube_uploads_title_check check (char_length(title) between 1 and 100),- constraint youtube_uploads_source_url_check check (source_url ~ '^https://'),- constraint youtube_uploads_source_bytes_check check (source_bytes > 0),- constraint youtube_uploads_bytes_confirmed_check check (bytes_confirmed between 0 and source_bytes),- -- YouTube only schedules private videos- constraint youtube_uploads_publish_at_check check (publish_at is null or privacy = 'private')+CREATE TABLE "public"."youtube_uploads" (+ "id" text NOT NULL,+ "user_id" uuid NOT NULL,+ "connection_id" text NOT NULL,+ "source_url" text NOT NULL,+ "source_bytes" bigint NOT NULL,+ "content_type" text NOT NULL,+ "thumbnail_url" text,+ "is_short" boolean NOT NULL DEFAULT false,+ "title" text NOT NULL,+ "description" text NOT NULL DEFAULT ''::text,+ "tags" text[] NOT NULL DEFAULT '{}'::text[],+ "category_id" text NOT NULL DEFAULT '22'::text,+ "privacy" text NOT NULL,+ "publish_at" timestamp with time zone,+ "made_for_kids" boolean NOT NULL DEFAULT false,+ "synthetic_media" boolean NOT NULL DEFAULT false,+ "notify_subscribers" boolean NOT NULL DEFAULT true,+ "state" text NOT NULL DEFAULT 'queued'::text,+ "session_uri" text,+ "bytes_confirmed" bigint NOT NULL DEFAULT 0,+ "video_id" text,+ "attempts" integer NOT NULL DEFAULT 0,+ "next_attempt_at" timestamp with time zone NOT NULL DEFAULT now(),+ "lease_owner" text,+ "lease_until" timestamp with time zone,+ "last_error" text,+ "client_request_id" text,+ "created_at" timestamp with time zone NOT NULL DEFAULT now(),+ "updated_at" timestamp with time zone NOT NULL DEFAULT now(),+ CONSTRAINT "youtube_uploads_bytes_confirmed_check" CHECK (((bytes_confirmed >= 0) AND (bytes_confirmed <= source_bytes))),+ CONSTRAINT "youtube_uploads_connection_id_fkey" FOREIGN KEY (connection_id) REFERENCES public.youtube_connections(id) ON DELETE CASCADE,+ CONSTRAINT "youtube_uploads_pkey" PRIMARY KEY (id),+ CONSTRAINT "youtube_uploads_privacy_check" CHECK ((privacy = ANY (ARRAY['private'::text, 'unlisted'::text, 'public'::text]))),+ CONSTRAINT "youtube_uploads_publish_at_check" CHECK (((publish_at IS NULL) OR (privacy = 'private'::text))),+ CONSTRAINT "youtube_uploads_source_bytes_check" CHECK ((source_bytes > 0)),+ CONSTRAINT "youtube_uploads_source_url_check" CHECK ((source_url ~ '^https://'::text)),+ CONSTRAINT "youtube_uploads_state_check"+ CHECK+ ((state = ANY (ARRAY['queued'::text, 'uploading'::text, 'processing'::text, 'finalizing'::text, 'done'::text, 'waiting_quota'::text, 'needs_reconnect'::text,+ 'needs_review'::text, 'failed'::text, 'cancelled'::text]))),+ CONSTRAINT "youtube_uploads_title_check" CHECK (((char_length(title) >= 1) AND (char_length(title) <= 100))),+ CONSTRAINT "youtube_uploads_user_id_fkey" FOREIGN KEY (user_id) REFERENCES auth.users(id) ON DELETE CASCADE,+ CONSTRAINT "youtube_uploads_user_request_key" UNIQUE (user_id, client_request_id));ALTER TABLE "public"."youtube_uploads"ENABLE ROW LEVEL SECURITY;-CREATE INDEX youtube_uploads_due_idx ON public.youtube_uploads USING btree (next_attempt_at) WHERE (state = ANY (ARRAY['queued'::text, 'uploading'::text, 'processing'::text, 'finalizing'::text, 'waiting_quota'::text]));+CREATE INDEX youtube_uploads_due_idx ON public.youtube_uploads USING btree (next_attempt_at)+ WHERE (state = ANY (ARRAY['queued'::text, 'uploading'::text, 'processing'::text, 'finalizing'::text, 'waiting_quota'::text]));CREATE INDEX youtube_uploads_user_created_idx ON public.youtube_uploads USING btree (user_id, created_at DESC);