a tool for shared writing and social publishing

add bsky_follows table

+122 -1
+20 -1
drizzle/relations.ts
··· 1 1 import { relations } from "drizzle-orm/relations"; 2 - import { identities, bsky_profiles, publications, documents, comments_on_documents, entities, facts, entity_sets, permission_tokens, email_subscriptions_to_entity, email_auth_tokens, custom_domains, phone_rsvps_to_entity, custom_domain_routes, poll_votes_on_entity, subscribers_to_publications, document_mentions_in_bsky, bsky_posts, permission_token_on_homepage, documents_in_publications, publication_domains, publication_subscriptions, leaflets_in_publications, permission_token_rights } from "./schema"; 2 + import { identities, bsky_profiles, publications, documents, comments_on_documents, entities, facts, entity_sets, permission_tokens, email_subscriptions_to_entity, email_auth_tokens, custom_domains, phone_rsvps_to_entity, custom_domain_routes, poll_votes_on_entity, bsky_follows, subscribers_to_publications, document_mentions_in_bsky, bsky_posts, permission_token_on_homepage, documents_in_publications, publication_domains, publication_subscriptions, leaflets_in_publications, permission_token_rights } from "./schema"; 3 3 4 4 export const bsky_profilesRelations = relations(bsky_profiles, ({one, many}) => ({ 5 5 identity: one(identities, { ··· 22 22 }), 23 23 custom_domains_identity_id: many(custom_domains, { 24 24 relationName: "custom_domains_identity_id_identities_id" 25 + }), 26 + bsky_follows_follows: many(bsky_follows, { 27 + relationName: "bsky_follows_follows_identities_atp_did" 28 + }), 29 + bsky_follows_identity: many(bsky_follows, { 30 + relationName: "bsky_follows_identity_identities_atp_did" 25 31 }), 26 32 subscribers_to_publications: many(subscribers_to_publications), 27 33 permission_token_on_homepages: many(permission_token_on_homepage), ··· 173 179 fields: [poll_votes_on_entity.poll_entity], 174 180 references: [entities.id], 175 181 relationName: "poll_votes_on_entity_poll_entity_entities_id" 182 + }), 183 + })); 184 + 185 + export const bsky_followsRelations = relations(bsky_follows, ({one}) => ({ 186 + identity_follows: one(identities, { 187 + fields: [bsky_follows.follows], 188 + references: [identities.atp_did], 189 + relationName: "bsky_follows_follows_identities_atp_did" 190 + }), 191 + identity_identity: one(identities, { 192 + fields: [bsky_follows.identity], 193 + references: [identities.atp_did], 194 + relationName: "bsky_follows_identity_identities_atp_did" 176 195 }), 177 196 })); 178 197
+10
drizzle/schema.ts
··· 184 184 voter_token: uuid("voter_token").notNull(), 185 185 }); 186 186 187 + export const bsky_follows = pgTable("bsky_follows", { 188 + identity: text("identity").default('').notNull().references(() => identities.atp_did, { onDelete: "cascade" } ), 189 + follows: text("follows").notNull().references(() => identities.atp_did, { onDelete: "cascade" } ), 190 + }, 191 + (table) => { 192 + return { 193 + bsky_follows_pkey: primaryKey({ columns: [table.identity, table.follows], name: "bsky_follows_pkey"}), 194 + } 195 + }); 196 + 187 197 export const subscribers_to_publications = pgTable("subscribers_to_publications", { 188 198 identity: text("identity").notNull().references(() => identities.email, { onUpdate: "cascade" } ), 189 199 publication: text("publication").notNull().references(() => publications.uri),
+30
supabase/database.types.ts
··· 34 34 } 35 35 public: { 36 36 Tables: { 37 + bsky_follows: { 38 + Row: { 39 + follows: string 40 + identity: string 41 + } 42 + Insert: { 43 + follows: string 44 + identity?: string 45 + } 46 + Update: { 47 + follows?: string 48 + identity?: string 49 + } 50 + Relationships: [ 51 + { 52 + foreignKeyName: "bsky_follows_follows_fkey" 53 + columns: ["follows"] 54 + isOneToOne: false 55 + referencedRelation: "identities" 56 + referencedColumns: ["atp_did"] 57 + }, 58 + { 59 + foreignKeyName: "bsky_follows_identity_fkey" 60 + columns: ["identity"] 61 + isOneToOne: false 62 + referencedRelation: "identities" 63 + referencedColumns: ["atp_did"] 64 + }, 65 + ] 66 + } 37 67 bsky_posts: { 38 68 Row: { 39 69 cid: string
+62
supabase/migrations/20251014215602_add_bsky_follows_table.sql
··· 1 + create table "public"."bsky_follows" ( 2 + "identity" text not null, 3 + "follows" text not null 4 + ); 5 + 6 + alter table "public"."bsky_follows" enable row level security; 7 + 8 + CREATE UNIQUE INDEX bsky_follows_pkey ON public.bsky_follows USING btree (identity, follows); 9 + 10 + CREATE INDEX facts_reference_idx ON public.facts USING btree (((data ->> 'value'::text))) WHERE (((data ->> 'type'::text) = 'reference'::text) OR ((data ->> 'type'::text) = 'ordered-reference'::text)); 11 + 12 + alter table "public"."bsky_follows" add constraint "bsky_follows_pkey" PRIMARY KEY using index "bsky_follows_pkey"; 13 + 14 + alter table "public"."bsky_follows" add constraint "bsky_follows_follows_fkey" FOREIGN KEY (follows) REFERENCES identities(atp_did) ON DELETE CASCADE not valid; 15 + 16 + alter table "public"."bsky_follows" validate constraint "bsky_follows_follows_fkey"; 17 + 18 + alter table "public"."bsky_follows" add constraint "bsky_follows_identity_fkey" FOREIGN KEY (identity) REFERENCES identities(atp_did) ON DELETE CASCADE not valid; 19 + 20 + alter table "public"."bsky_follows" validate constraint "bsky_follows_identity_fkey"; 21 + 22 + grant delete on table "public"."bsky_follows" to "anon"; 23 + 24 + grant insert on table "public"."bsky_follows" to "anon"; 25 + 26 + grant references on table "public"."bsky_follows" to "anon"; 27 + 28 + grant select on table "public"."bsky_follows" to "anon"; 29 + 30 + grant trigger on table "public"."bsky_follows" to "anon"; 31 + 32 + grant truncate on table "public"."bsky_follows" to "anon"; 33 + 34 + grant update on table "public"."bsky_follows" to "anon"; 35 + 36 + grant delete on table "public"."bsky_follows" to "authenticated"; 37 + 38 + grant insert on table "public"."bsky_follows" to "authenticated"; 39 + 40 + grant references on table "public"."bsky_follows" to "authenticated"; 41 + 42 + grant select on table "public"."bsky_follows" to "authenticated"; 43 + 44 + grant trigger on table "public"."bsky_follows" to "authenticated"; 45 + 46 + grant truncate on table "public"."bsky_follows" to "authenticated"; 47 + 48 + grant update on table "public"."bsky_follows" to "authenticated"; 49 + 50 + grant delete on table "public"."bsky_follows" to "service_role"; 51 + 52 + grant insert on table "public"."bsky_follows" to "service_role"; 53 + 54 + grant references on table "public"."bsky_follows" to "service_role"; 55 + 56 + grant select on table "public"."bsky_follows" to "service_role"; 57 + 58 + grant trigger on table "public"."bsky_follows" to "service_role"; 59 + 60 + grant truncate on table "public"."bsky_follows" to "service_role"; 61 + 62 + grant update on table "public"."bsky_follows" to "service_role";