t3-code-android-nightly/.repos/alchemy-effect/examples/fly-postgres/migrations/20260504073935_migration/migration.sql

18 lines
543 B
SQL

CREATE TABLE "posts" (
"id" serial PRIMARY KEY,
"user_id" integer NOT NULL,
"title" text NOT NULL,
"body" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "users" (
"id" serial PRIMARY KEY,
"email" text NOT NULL UNIQUE,
"name" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "posts" ADD CONSTRAINT "posts_user_id_users_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE;