feat(db): Add favicon support and improve remote followers uniqueness constraint
- Add favicon_url column to nodes table for storing node instance favicons - Replace actor_url unique constraint with composite unique index on (user_id, actor_url) in remote_followers table - Update database schema and migration files to reflect new constraints - Improve data integrity by ensuring remote followers are unique per user and actor combination
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE "remote_followers" DROP CONSTRAINT "remote_followers_actor_url_unique";--> statement-breakpoint
|
||||||
|
ALTER TABLE "nodes" ADD COLUMN "favicon_url" text;--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "remote_followers_user_actor_unique" ON "remote_followers" USING btree ("user_id","actor_url");
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,13 @@
|
|||||||
"when": 1769377790354,
|
"when": 1769377790354,
|
||||||
"tag": "0004_luxuriant_lockheed",
|
"tag": "0004_luxuriant_lockheed",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 5,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1769422771465,
|
||||||
|
"tag": "0005_yummy_millenium_guard",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+3
-2
@@ -1,4 +1,4 @@
|
|||||||
import { pgTable, text, timestamp, uuid, integer, boolean, index, foreignKey } from 'drizzle-orm/pg-core';
|
import { pgTable, text, timestamp, uuid, integer, boolean, index, foreignKey, uniqueIndex } from 'drizzle-orm/pg-core';
|
||||||
import { relations } from 'drizzle-orm';
|
import { relations } from 'drizzle-orm';
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
@@ -252,7 +252,7 @@ export const remoteFollows = pgTable('remote_follows', {
|
|||||||
export const remoteFollowers = pgTable('remote_followers', {
|
export const remoteFollowers = pgTable('remote_followers', {
|
||||||
id: uuid('id').primaryKey().defaultRandom(),
|
id: uuid('id').primaryKey().defaultRandom(),
|
||||||
userId: uuid('user_id').notNull().references(() => users.id, { onDelete: 'cascade' }), // Local user being followed
|
userId: uuid('user_id').notNull().references(() => users.id, { onDelete: 'cascade' }), // Local user being followed
|
||||||
actorUrl: text('actor_url').notNull().unique(), // Remote actor URL (unique per local user)
|
actorUrl: text('actor_url').notNull(), // Remote actor URL
|
||||||
inboxUrl: text('inbox_url').notNull(), // Remote user's inbox
|
inboxUrl: text('inbox_url').notNull(), // Remote user's inbox
|
||||||
sharedInboxUrl: text('shared_inbox_url'), // Optional shared inbox
|
sharedInboxUrl: text('shared_inbox_url'), // Optional shared inbox
|
||||||
handle: text('handle'), // Remote user's handle (e.g., user@mastodon.social)
|
handle: text('handle'), // Remote user's handle (e.g., user@mastodon.social)
|
||||||
@@ -261,6 +261,7 @@ export const remoteFollowers = pgTable('remote_followers', {
|
|||||||
}, (table) => [
|
}, (table) => [
|
||||||
index('remote_followers_user_idx').on(table.userId),
|
index('remote_followers_user_idx').on(table.userId),
|
||||||
index('remote_followers_actor_idx').on(table.actorUrl),
|
index('remote_followers_actor_idx').on(table.actorUrl),
|
||||||
|
uniqueIndex('remote_followers_user_actor_unique').on(table.userId, table.actorUrl),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
|
|||||||
Reference in New Issue
Block a user