1CREATE TABLE "posts" (
2 "id" serial PRIMARY KEY,
3 "user_id" integer NOT NULL,
4 "title" text NOT NULL,
5 "body" text NOT NULL,
6 "created_at" timestamp with time zone DEFAULT now() NOT NULL
7);
8
9--> statement-breakpoint
10CREATE TABLE "users" (
11 "id" serial PRIMARY KEY,
12 "email" text NOT NULL UNIQUE,
13 "name" text NOT NULL,
14 "created_at" timestamp with time zone DEFAULT now() NOT NULL
15);
16
17--> statement-breakpoint
18ALTER TABLE "posts" ADD CONSTRAINT "posts_user_id_users_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE;