Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/supabase-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Validate Supabase Migrations

on:
pull_request:
branches:
- develop
- main
workflow_dispatch:

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: supabase/setup-cli@v1
with:
version: latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pin the Supabase CLI version instead of using 'latest' to prevent unexpected breaking changes.

Suggested change
version: latest
version: 1.123.4


- name: Start Supabase local development environment
run: supabase start

- name: Validate migrations
run: |
# Check if migrations can be applied without errors
supabase db reset

# Additional validation can be added here
echo "Migrations validated successfully"
25 changes: 25 additions & 0 deletions .github/workflows/supabase-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy Drizzle Migrations to Supabase Staging

on:
push:
branches:
- main
- ci/supabase
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
env:
DATABASE_URL: ${{ secrets.STAGING_SUPABASE_DATABASE_URL }}

steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pin the Bun version rather than using 'latest' to ensure stable builds.

Suggested change
bun-version: latest
bun-version: 1.0.25


- run: bun install

- run: bun run drizzle:push
75 changes: 75 additions & 0 deletions packages/db/src/migrations/0000_salty_blink.sql
Original file line number Diff line number Diff line change
@@ -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;
Loading
Loading