diff --git a/.github/workflows/supabase-staging.yml b/.github/workflows/supabase-staging.yml new file mode 100644 index 0000000000..90789bd762 --- /dev/null +++ b/.github/workflows/supabase-staging.yml @@ -0,0 +1,24 @@ +name: Deploy Drizzle Migrations to Supabase Staging + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + env: + SUPABASE_DATABASE_URL: ${{ secrets.STAGING_SUPABASE_DATABASE_URL }} + + steps: + - uses: actions/checkout@v4 + + - uses: oven-sh/setup-bun@v1 + with: + bun-version: 1.2.x + + - run: bun install + + - run: bun run db:push diff --git a/apps/backend/supabase/migrations/0000_same_human_robot.sql b/apps/backend/supabase/migrations/0000_same_human_robot.sql new file mode 100644 index 0000000000..9eb09649a0 --- /dev/null +++ b/apps/backend/supabase/migrations/0000_same_human_robot.sql @@ -0,0 +1,75 @@ +CREATE TYPE "public"."frame_type" AS ENUM('web');--> statement-breakpoint +CREATE TYPE "public"."role" AS ENUM('user', 'assistant', 'system');--> statement-breakpoint +CREATE TABLE "canvas" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "project_id" uuid NOT NULL, + "scale" numeric NOT NULL, + "x" numeric NOT NULL, + "y" numeric NOT NULL +); +--> statement-breakpoint +ALTER TABLE "canvas" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "frames" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "canvas_id" uuid NOT NULL, + "type" "frame_type" NOT NULL, + "url" varchar NOT NULL, + "x" numeric NOT NULL, + "y" numeric NOT NULL, + "width" numeric NOT NULL, + "height" numeric NOT NULL +); +--> statement-breakpoint +ALTER TABLE "frames" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "conversations" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "project_id" uuid NOT NULL, + "display_name" varchar, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "messages" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "conversation_id" uuid NOT NULL, + "content" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "role" "role" NOT NULL, + "applied" boolean DEFAULT false NOT NULL, + "snapshots" jsonb DEFAULT '{}'::jsonb NOT NULL, + "context" jsonb DEFAULT '[]'::jsonb NOT NULL, + "parts" jsonb DEFAULT '[]'::jsonb NOT NULL +); +--> statement-breakpoint +CREATE TABLE "projects" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "name" varchar NOT NULL, + "sandbox_id" varchar NOT NULL, + "sandbox_url" varchar NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + "preview_img" varchar, + "description" text +); +--> statement-breakpoint +ALTER TABLE "projects" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "users" ( + "id" uuid PRIMARY KEY NOT NULL +); +--> statement-breakpoint +ALTER TABLE "users" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "user_projects" ( + "user_id" uuid NOT NULL, + "project_id" uuid NOT NULL, + "created_at" timestamp with time zone DEFAULT now(), + CONSTRAINT "user_projects_user_id_project_id_pk" PRIMARY KEY("user_id","project_id") +); +--> statement-breakpoint +ALTER TABLE "user_projects" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +ALTER TABLE "canvas" ADD CONSTRAINT "canvas_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "frames" ADD CONSTRAINT "frames_canvas_id_canvas_id_fk" FOREIGN KEY ("canvas_id") REFERENCES "public"."canvas"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "conversations" ADD CONSTRAINT "conversations_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "messages" ADD CONSTRAINT "messages_conversation_id_conversations_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."conversations"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "users" ADD CONSTRAINT "users_id_users_id_fk" FOREIGN KEY ("id") REFERENCES "auth"."users"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "user_projects" ADD CONSTRAINT "user_projects_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint +ALTER TABLE "user_projects" ADD CONSTRAINT "user_projects_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE cascade; \ No newline at end of file diff --git a/apps/backend/supabase/migrations/0001_graceful_exodus.sql b/apps/backend/supabase/migrations/0001_graceful_exodus.sql new file mode 100644 index 0000000000..4c1280ebc1 --- /dev/null +++ b/apps/backend/supabase/migrations/0001_graceful_exodus.sql @@ -0,0 +1,2 @@ +ALTER TABLE "conversations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +ALTER TABLE "messages" ENABLE ROW LEVEL SECURITY; \ No newline at end of file diff --git a/apps/backend/supabase/migrations/meta/0000_snapshot.json b/apps/backend/supabase/migrations/meta/0000_snapshot.json new file mode 100644 index 0000000000..af17fcd408 --- /dev/null +++ b/apps/backend/supabase/migrations/meta/0000_snapshot.json @@ -0,0 +1,482 @@ +{ + "id": "95612ed1-7374-41c8-8f07-1ee3b064226b", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.canvas": { + "name": "canvas", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "scale": { + "name": "scale", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "canvas_project_id_projects_id_fk": { + "name": "canvas_project_id_projects_id_fk", + "tableFrom": "canvas", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.frames": { + "name": "frames", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "canvas_id": { + "name": "canvas_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "frame_type", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "frames_canvas_id_canvas_id_fk": { + "name": "frames_canvas_id_canvas_id_fk", + "tableFrom": "frames", + "tableTo": "canvas", + "columnsFrom": [ + "canvas_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "conversations_project_id_projects_id_fk": { + "name": "conversations_project_id_projects_id_fk", + "tableFrom": "conversations", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.messages": { + "name": "messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "role", + "primaryKey": false, + "notNull": true + }, + "applied": { + "name": "applied", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "snapshots": { + "name": "snapshots", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "context": { + "name": "context", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "parts": { + "name": "parts", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + } + }, + "indexes": {}, + "foreignKeys": { + "messages_conversation_id_conversations_id_fk": { + "name": "messages_conversation_id_conversations_id_fk", + "tableFrom": "messages", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.projects": { + "name": "projects", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "sandbox_id": { + "name": "sandbox_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "sandbox_url": { + "name": "sandbox_url", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "preview_img": { + "name": "preview_img", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "users_id_users_id_fk": { + "name": "users_id_users_id_fk", + "tableFrom": "users", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.user_projects": { + "name": "user_projects", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_projects_user_id_users_id_fk": { + "name": "user_projects_user_id_users_id_fk", + "tableFrom": "user_projects", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "user_projects_project_id_projects_id_fk": { + "name": "user_projects_project_id_projects_id_fk", + "tableFrom": "user_projects", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": { + "user_projects_user_id_project_id_pk": { + "name": "user_projects_user_id_project_id_pk", + "columns": [ + "user_id", + "project_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + } + }, + "enums": { + "public.frame_type": { + "name": "frame_type", + "schema": "public", + "values": [ + "web" + ] + }, + "public.role": { + "name": "role", + "schema": "public", + "values": [ + "user", + "assistant", + "system" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/supabase/migrations/meta/0001_snapshot.json b/apps/backend/supabase/migrations/meta/0001_snapshot.json new file mode 100644 index 0000000000..a3600e599f --- /dev/null +++ b/apps/backend/supabase/migrations/meta/0001_snapshot.json @@ -0,0 +1,482 @@ +{ + "id": "7fab2c6f-cf80-420e-bad4-3d6065d58b9c", + "prevId": "95612ed1-7374-41c8-8f07-1ee3b064226b", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.canvas": { + "name": "canvas", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "scale": { + "name": "scale", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "canvas_project_id_projects_id_fk": { + "name": "canvas_project_id_projects_id_fk", + "tableFrom": "canvas", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.frames": { + "name": "frames", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "canvas_id": { + "name": "canvas_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "frame_type", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "frames_canvas_id_canvas_id_fk": { + "name": "frames_canvas_id_canvas_id_fk", + "tableFrom": "frames", + "tableTo": "canvas", + "columnsFrom": [ + "canvas_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "conversations_project_id_projects_id_fk": { + "name": "conversations_project_id_projects_id_fk", + "tableFrom": "conversations", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.messages": { + "name": "messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "role", + "primaryKey": false, + "notNull": true + }, + "applied": { + "name": "applied", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "snapshots": { + "name": "snapshots", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "context": { + "name": "context", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "parts": { + "name": "parts", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + } + }, + "indexes": {}, + "foreignKeys": { + "messages_conversation_id_conversations_id_fk": { + "name": "messages_conversation_id_conversations_id_fk", + "tableFrom": "messages", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.projects": { + "name": "projects", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "sandbox_id": { + "name": "sandbox_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "sandbox_url": { + "name": "sandbox_url", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "preview_img": { + "name": "preview_img", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "users_id_users_id_fk": { + "name": "users_id_users_id_fk", + "tableFrom": "users", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + }, + "public.user_projects": { + "name": "user_projects", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_projects_user_id_users_id_fk": { + "name": "user_projects_user_id_users_id_fk", + "tableFrom": "user_projects", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "user_projects_project_id_projects_id_fk": { + "name": "user_projects_project_id_projects_id_fk", + "tableFrom": "user_projects", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": { + "user_projects_user_id_project_id_pk": { + "name": "user_projects_user_id_project_id_pk", + "columns": [ + "user_id", + "project_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": true + } + }, + "enums": { + "public.frame_type": { + "name": "frame_type", + "schema": "public", + "values": [ + "web" + ] + }, + "public.role": { + "name": "role", + "schema": "public", + "values": [ + "user", + "assistant", + "system" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/supabase/migrations/meta/_journal.json b/apps/backend/supabase/migrations/meta/_journal.json new file mode 100644 index 0000000000..7cd5be3793 --- /dev/null +++ b/apps/backend/supabase/migrations/meta/_journal.json @@ -0,0 +1,20 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1747780205535, + "tag": "0000_same_human_robot", + "breakpoints": true + }, + { + "idx": 1, + "version": "7", + "when": 1747780749310, + "tag": "0001_graceful_exodus", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/packages/db/drizzle.config.ts b/packages/db/drizzle.config.ts index d001b8ffaa..8adc520b82 100644 --- a/packages/db/drizzle.config.ts +++ b/packages/db/drizzle.config.ts @@ -3,10 +3,10 @@ import { defineConfig } from 'drizzle-kit'; const DEFAULT_DATABASE_URL = 'postgresql://postgres:postgres@127.0.0.1:54322/postgres'; export default defineConfig({ schema: './src/schema', - out: './src/migrations', + out: '../../apps/backend/supabase/migrations', dialect: "postgresql", schemaFilter: ["public"], dbCredentials: { url: process.env.SUPABASE_DATABASE_URL ?? DEFAULT_DATABASE_URL, }, -}); +}); \ No newline at end of file diff --git a/packages/db/src/schema/project/chat/conversation.ts b/packages/db/src/schema/project/chat/conversation.ts index ae9cc23682..a5f0da0d4f 100644 --- a/packages/db/src/schema/project/chat/conversation.ts +++ b/packages/db/src/schema/project/chat/conversation.ts @@ -14,7 +14,7 @@ export const conversations = pgTable("conversations", { displayName: varchar("display_name"), createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(), updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(), -}); +}).enableRLS(); export const conversationInsertSchema = createInsertSchema(conversations); diff --git a/packages/db/src/schema/project/chat/message.ts b/packages/db/src/schema/project/chat/message.ts index 4b4995e260..cb8da3b8f3 100644 --- a/packages/db/src/schema/project/chat/message.ts +++ b/packages/db/src/schema/project/chat/message.ts @@ -20,7 +20,7 @@ export const messages = pgTable("messages", { snapshots: jsonb("snapshots").$type().default({}).notNull(), context: jsonb("context").$type().default([]).notNull(), parts: jsonb("parts").$type().default([]).notNull(), -}); +}).enableRLS(); export const messageInsertSchema = createInsertSchema(messages);