From 75c4e119d617881bddaf5292a4f6897265297b6b Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Sun, 15 Jun 2025 12:12:07 -0400 Subject: [PATCH] add handle to bsky_profiles table --- appview/index.ts | 7 +++++++ drizzle/schema.ts | 1 + supabase/database.types.ts | 3 +++ .../20250615154505_add_handle_to_bsky_profiles.sql | 1 + 4 files changed, 12 insertions(+) create mode 100644 supabase/migrations/20250615154505_add_handle_to_bsky_profiles.sql diff --git a/appview/index.ts b/appview/index.ts index 2e52bef8..dee2819a 100644 --- a/appview/index.ts +++ b/appview/index.ts @@ -50,6 +50,13 @@ async function main() { ids.AppBskyActorProfile, ], handleEvent: async (evt) => { + if (evt.event === "identity") { + if (evt.handle) + await supabase + .from("bsky_profiles") + .update({ handle: evt.handle }) + .eq("did", evt.did); + } if ( evt.event == "account" || evt.event === "identity" || diff --git a/drizzle/schema.ts b/drizzle/schema.ts index b4d00f48..c22ca6d2 100644 --- a/drizzle/schema.ts +++ b/drizzle/schema.ts @@ -28,6 +28,7 @@ export const bsky_profiles = pgTable("bsky_profiles", { did: text("did").primaryKey().notNull().references(() => identities.atp_did, { onDelete: "cascade" } ), record: jsonb("record").notNull(), indexed_at: timestamp("indexed_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), + handle: text("handle"), }); export const publications = pgTable("publications", { diff --git a/supabase/database.types.ts b/supabase/database.types.ts index a4b87174..d1ebcd44 100644 --- a/supabase/database.types.ts +++ b/supabase/database.types.ts @@ -37,16 +37,19 @@ export type Database = { bsky_profiles: { Row: { did: string + handle: string | null indexed_at: string record: Json } Insert: { did: string + handle?: string | null indexed_at?: string record: Json } Update: { did?: string + handle?: string | null indexed_at?: string record?: Json } diff --git a/supabase/migrations/20250615154505_add_handle_to_bsky_profiles.sql b/supabase/migrations/20250615154505_add_handle_to_bsky_profiles.sql new file mode 100644 index 00000000..493af010 --- /dev/null +++ b/supabase/migrations/20250615154505_add_handle_to_bsky_profiles.sql @@ -0,0 +1 @@ +alter table "public"."bsky_profiles" add column "handle" text; -- 2.51.2