8ad3b97b7e
- Add bot management system with creation, suspension, and reinstatement functionality - Implement autonomous bot posting with scheduling, rate limiting, and content generation - Add content fetching system supporting RSS feeds and multiple content sources - Implement LLM-based content generation with customizable bot personalities - Add mention handling and automated response system for bot interactions - Implement API key management with encryption using AUTH_SECRET for simplified deployment - Add comprehensive bot logging system for activity tracking and error monitoring - Create bot administration pages and settings UI for managing bot configurations - Add database migrations for bot system schema including users, sources, and content items - Implement cron job system for automated bot operations and scheduled tasks - Add extensive test coverage with unit and property-based tests for core bot modules - Simplify encryption by deriving keys from AUTH_SECRET instead of separate environment variable - Implement automatic content fetching on post trigger with retry logic - Add Reddit-specific link preview handling using oEmbed API for reliable metadata extraction - Create utility scripts for bot inspection and cleanup operations - Add comprehensive bot system documentation and improvement tracking
35 lines
1.5 KiB
SQL
35 lines
1.5 KiB
SQL
-- Bots as First-Class Users Migration
|
|
-- This migration transforms bots to have their own user accounts
|
|
|
|
-- Add bot-related fields to users table
|
|
ALTER TABLE "users" ADD COLUMN "is_bot" boolean DEFAULT false NOT NULL;
|
|
ALTER TABLE "users" ADD COLUMN "bot_owner_id" uuid REFERENCES "users"("id") ON DELETE CASCADE;
|
|
|
|
-- Create indexes for bot fields
|
|
CREATE INDEX IF NOT EXISTS "users_is_bot_idx" ON "users" ("is_bot");
|
|
CREATE INDEX IF NOT EXISTS "users_bot_owner_idx" ON "users" ("bot_owner_id");
|
|
|
|
-- Add owner_id to bots table (will be populated during migration)
|
|
ALTER TABLE "bots" ADD COLUMN "owner_id" uuid REFERENCES "users"("id") ON DELETE CASCADE;
|
|
|
|
-- Copy existing userId to ownerId (existing bots were owned by the user)
|
|
UPDATE "bots" SET "owner_id" = "user_id";
|
|
|
|
-- Make owner_id NOT NULL after populating
|
|
ALTER TABLE "bots" ALTER COLUMN "owner_id" SET NOT NULL;
|
|
|
|
-- Create index for owner_id
|
|
CREATE INDEX IF NOT EXISTS "bots_owner_id_idx" ON "bots" ("owner_id");
|
|
|
|
-- Remove columns that are now on the user account
|
|
-- Note: handle, bio, avatarUrl, publicKey, privateKeyEncrypted move to users table
|
|
-- We'll keep them for now and handle migration in application code
|
|
-- ALTER TABLE "bots" DROP COLUMN "handle";
|
|
-- ALTER TABLE "bots" DROP COLUMN "bio";
|
|
-- ALTER TABLE "bots" DROP COLUMN "avatar_url";
|
|
-- ALTER TABLE "bots" DROP COLUMN "public_key";
|
|
-- ALTER TABLE "bots" DROP COLUMN "private_key_encrypted";
|
|
|
|
-- Drop the handle index since handle is now on users
|
|
DROP INDEX IF EXISTS "bots_handle_idx";
|