Files
Synapsis/drizzle/0002_add_logo_url.sql
T
AskIt b9316552c2 feat(db,admin): Add logo URL support and refactor bot schema with owner relationships
- Add logo_url column to nodes table for custom branding
- Refactor bots table to use owner_id foreign key relationship with users
- Add is_bot and bot_owner_id columns to users table for bot account tracking
- Add bot_id foreign key to posts table for bot-generated content tracking
- Create database indexes on owner_id, bot_id, is_bot, and bot_owner_id for query performance
- Remove bot handle, bio, avatar_url, and cryptographic keys from bots table (moved to user accounts)
- Update bot_content_sources schema and remove fetch_interval_minutes column
- Fix bot_content_items foreign key constraint with set null on delete
- Remove hardcoded NODE_NAME and NODE_DESCRIPTION from environment configuration
- Update admin panel, bot settings, and layout components to support new schema
- Add AccentColorContext and ToastContext for improved UI state management
- Update PostCard, Sidebar, RightSidebar, and LayoutWrapper components for context integration
2026-01-25 20:15:35 +01:00

24 lines
2.2 KiB
SQL

ALTER TABLE "bots" DROP CONSTRAINT "bots_handle_unique";--> statement-breakpoint
ALTER TABLE "bot_content_items" DROP CONSTRAINT "bot_content_items_post_id_posts_id_fk";
--> statement-breakpoint
DROP INDEX "bots_handle_idx";--> statement-breakpoint
ALTER TABLE "bot_content_sources" ADD COLUMN "source_config" text;--> statement-breakpoint
ALTER TABLE "bots" ADD COLUMN "owner_id" uuid NOT NULL;--> statement-breakpoint
ALTER TABLE "nodes" ADD COLUMN "logo_url" text;--> statement-breakpoint
ALTER TABLE "posts" ADD COLUMN "bot_id" uuid;--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "is_bot" boolean DEFAULT false NOT NULL;--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "bot_owner_id" uuid;--> statement-breakpoint
ALTER TABLE "bot_content_items" ADD CONSTRAINT "bot_content_items_post_id_posts_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."posts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "bots" ADD CONSTRAINT "bots_owner_id_users_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "posts" ADD CONSTRAINT "posts_bot_id_bots_id_fk" FOREIGN KEY ("bot_id") REFERENCES "public"."bots"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "users" ADD CONSTRAINT "users_bot_owner_id_users_id_fk" FOREIGN KEY ("bot_owner_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "bots_owner_id_idx" ON "bots" USING btree ("owner_id");--> statement-breakpoint
CREATE INDEX "posts_bot_id_idx" ON "posts" USING btree ("bot_id");--> statement-breakpoint
CREATE INDEX "users_is_bot_idx" ON "users" USING btree ("is_bot");--> statement-breakpoint
CREATE INDEX "users_bot_owner_idx" ON "users" USING btree ("bot_owner_id");--> statement-breakpoint
ALTER TABLE "bot_content_sources" DROP COLUMN "fetch_interval_minutes";--> statement-breakpoint
ALTER TABLE "bots" DROP COLUMN "handle";--> statement-breakpoint
ALTER TABLE "bots" DROP COLUMN "bio";--> statement-breakpoint
ALTER TABLE "bots" DROP COLUMN "avatar_url";--> statement-breakpoint
ALTER TABLE "bots" DROP COLUMN "public_key";--> statement-breakpoint
ALTER TABLE "bots" DROP COLUMN "private_key_encrypted";