CREATE TABLE "avatar_model" ( "id" text PRIMARY KEY NOT NULL, "name" text NOT NULL, "type" text NOT NULL, "description" text NOT NULL, "config" jsonb NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "characters" ( "id" text PRIMARY KEY NOT NULL, "version" text NOT NULL, "cover_url" text NOT NULL, "creator_id" text NOT NULL, "owner_id" text NOT NULL, "character_id" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "character_capabilities" ( "id" text PRIMARY KEY NOT NULL, "character_id" text NOT NULL, "type" text NOT NULL, "config" jsonb NOT NULL ); --> statement-breakpoint CREATE TABLE "character_i18n" ( "id" text PRIMARY KEY NOT NULL, "character_id" text NOT NULL, "language" text NOT NULL, "name" text NOT NULL, "description" text NOT NULL, "tags" text[] NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "character_prompts" ( "id" text PRIMARY KEY NOT NULL, "character_id" text NOT NULL, "language" text NOT NULL, "type" text NOT NULL, "content" text NOT NULL ); --> statement-breakpoint CREATE TABLE "chat_members" ( "id" text PRIMARY KEY NOT NULL, "chat_id" text NOT NULL, "user_id" text NOT NULL ); --> statement-breakpoint CREATE TABLE "chats" ( "id" text PRIMARY KEY NOT NULL, "type" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, "deleted_at" timestamp ); --> statement-breakpoint CREATE TABLE "media" ( "id" text PRIMARY KEY NOT NULL, "url" text NOT NULL, "mime_type" text NOT NULL, "size" integer NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "messages" ( "id" text PRIMARY KEY NOT NULL, "chat_id" text NOT NULL, "sender_id" text NOT NULL, "content" text NOT NULL, "media_ids" text[] NOT NULL, "sticker_ids" text[] NOT NULL, "reply_message_id" text, "forward_from_message_id" text, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, "deleted_at" timestamp ); --> statement-breakpoint CREATE TABLE "sticker_packs" ( "id" text PRIMARY KEY NOT NULL, "name" text NOT NULL, "description" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "stickers" ( "id" text PRIMARY KEY NOT NULL, "url" text NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint ALTER TABLE "characters" ADD CONSTRAINT "characters_creator_id_user_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "characters" ADD CONSTRAINT "characters_owner_id_user_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "character_capabilities" ADD CONSTRAINT "character_capabilities_character_id_characters_id_fk" FOREIGN KEY ("character_id") REFERENCES "public"."characters"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "character_i18n" ADD CONSTRAINT "character_i18n_character_id_characters_id_fk" FOREIGN KEY ("character_id") REFERENCES "public"."characters"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "character_prompts" ADD CONSTRAINT "character_prompts_character_id_characters_id_fk" FOREIGN KEY ("character_id") REFERENCES "public"."characters"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "chat_members" ADD CONSTRAINT "chat_members_chat_id_chats_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."chats"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "chat_members" ADD CONSTRAINT "chat_members_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "messages" ADD CONSTRAINT "messages_chat_id_chats_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."chats"("id") ON DELETE cascade ON UPDATE no action;