Skip to content

Commit 3884deb

Browse files
Kitenitedevin-ai-integration[bot]kiet@onlook.dev
authored
Supabase CI/CD (#1891)
* Add GitHub Actions workflows for Supabase staging and production environments * add migration files * update migration path --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: kiet@onlook.dev <kiet@onlook.dev>
1 parent 534182a commit 3884deb

File tree

9 files changed

+1089
-4
lines changed

9 files changed

+1089
-4
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Deploy Drizzle Migrations to Supabase Staging
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
env:
13+
SUPABASE_DATABASE_URL: ${{ secrets.STAGING_SUPABASE_DATABASE_URL }}
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: oven-sh/setup-bun@v1
19+
with:
20+
bun-version: 1.2.x
21+
22+
- run: bun install
23+
24+
- run: bun run db:push
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
CREATE TYPE "public"."frame_type" AS ENUM('web');--> statement-breakpoint
2+
CREATE TYPE "public"."role" AS ENUM('user', 'assistant', 'system');--> statement-breakpoint
3+
CREATE TABLE "canvas" (
4+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
5+
"project_id" uuid NOT NULL,
6+
"scale" numeric NOT NULL,
7+
"x" numeric NOT NULL,
8+
"y" numeric NOT NULL
9+
);
10+
--> statement-breakpoint
11+
ALTER TABLE "canvas" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
12+
CREATE TABLE "frames" (
13+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
14+
"canvas_id" uuid NOT NULL,
15+
"type" "frame_type" NOT NULL,
16+
"url" varchar NOT NULL,
17+
"x" numeric NOT NULL,
18+
"y" numeric NOT NULL,
19+
"width" numeric NOT NULL,
20+
"height" numeric NOT NULL
21+
);
22+
--> statement-breakpoint
23+
ALTER TABLE "frames" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
24+
CREATE TABLE "conversations" (
25+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
26+
"project_id" uuid NOT NULL,
27+
"display_name" varchar,
28+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
29+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
30+
);
31+
--> statement-breakpoint
32+
CREATE TABLE "messages" (
33+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
34+
"conversation_id" uuid NOT NULL,
35+
"content" text NOT NULL,
36+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
37+
"role" "role" NOT NULL,
38+
"applied" boolean DEFAULT false NOT NULL,
39+
"snapshots" jsonb DEFAULT '{}'::jsonb NOT NULL,
40+
"context" jsonb DEFAULT '[]'::jsonb NOT NULL,
41+
"parts" jsonb DEFAULT '[]'::jsonb NOT NULL
42+
);
43+
--> statement-breakpoint
44+
CREATE TABLE "projects" (
45+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
46+
"name" varchar NOT NULL,
47+
"sandbox_id" varchar NOT NULL,
48+
"sandbox_url" varchar NOT NULL,
49+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
50+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
51+
"preview_img" varchar,
52+
"description" text
53+
);
54+
--> statement-breakpoint
55+
ALTER TABLE "projects" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
56+
CREATE TABLE "users" (
57+
"id" uuid PRIMARY KEY NOT NULL
58+
);
59+
--> statement-breakpoint
60+
ALTER TABLE "users" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
61+
CREATE TABLE "user_projects" (
62+
"user_id" uuid NOT NULL,
63+
"project_id" uuid NOT NULL,
64+
"created_at" timestamp with time zone DEFAULT now(),
65+
CONSTRAINT "user_projects_user_id_project_id_pk" PRIMARY KEY("user_id","project_id")
66+
);
67+
--> statement-breakpoint
68+
ALTER TABLE "user_projects" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
69+
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
70+
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
71+
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
72+
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
73+
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
74+
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
75+
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;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "conversations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
2+
ALTER TABLE "messages" ENABLE ROW LEVEL SECURITY;

0 commit comments

Comments
 (0)