Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/src/lib/app/db/*
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ next-env.d.ts
# webstorm
.idea

# db
/src/api/schema
/drizzle/relations.ts
/drizzle/schema.ts
Binary file modified bun.lockb
Binary file not shown.
12 changes: 12 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'dotenv/config'
import type { Config } from 'drizzle-kit'

export default {
schema: './app/db/schema.ts',
out: './drizzle',
dialect: 'postgresql',
schemaFilter: ['public', 'neon_auth'],
dbCredentials: {
url: process.env.NEON_DATABASE_URL!
}
} satisfies Config
135 changes: 135 additions & 0 deletions drizzle/0000_wooden_mercury.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
-- Current sql file was generated after introspecting the database
-- If you want to run this migration please uncomment this code before executing migrations
/*
CREATE SCHEMA "neon_auth";
--> statement-breakpoint
CREATE TABLE "neon_auth"."invitation" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"organizationId" uuid NOT NULL,
"email" text NOT NULL,
"role" text,
"status" text NOT NULL,
"expiresAt" timestamp with time zone NOT NULL,
"createdAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
"inviterId" uuid NOT NULL
);
--> statement-breakpoint
CREATE TABLE "neon_auth"."user" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"name" text NOT NULL,
"email" text NOT NULL,
"emailVerified" boolean NOT NULL,
"image" text,
"createdAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
"updatedAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
"role" text,
"banned" boolean,
"banReason" text,
"banExpires" timestamp with time zone,
CONSTRAINT "user_email_key" UNIQUE("email")
);
--> statement-breakpoint
CREATE TABLE "neon_auth"."session" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"expiresAt" timestamp with time zone NOT NULL,
"token" text NOT NULL,
"createdAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
"updatedAt" timestamp with time zone NOT NULL,
"ipAddress" text,
"userAgent" text,
"userId" uuid NOT NULL,
"impersonatedBy" text,
"activeOrganizationId" text,
CONSTRAINT "session_token_key" UNIQUE("token")
);
--> statement-breakpoint
CREATE TABLE "neon_auth"."organization" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"name" text NOT NULL,
"slug" text NOT NULL,
"logo" text,
"createdAt" timestamp with time zone NOT NULL,
"metadata" text,
CONSTRAINT "organization_slug_key" UNIQUE("slug")
);
--> statement-breakpoint
CREATE TABLE "neon_auth"."account" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"accountId" text NOT NULL,
"providerId" text NOT NULL,
"userId" uuid NOT NULL,
"accessToken" text,
"refreshToken" text,
"idToken" text,
"accessTokenExpiresAt" timestamp with time zone,
"refreshTokenExpiresAt" timestamp with time zone,
"scope" text,
"password" text,
"createdAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
"updatedAt" timestamp with time zone NOT NULL
);
--> statement-breakpoint
CREATE TABLE "neon_auth"."verification" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"identifier" text NOT NULL,
"value" text NOT NULL,
"expiresAt" timestamp with time zone NOT NULL,
"createdAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
"updatedAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--> statement-breakpoint
CREATE TABLE "neon_auth"."jwks" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"publicKey" text NOT NULL,
"privateKey" text NOT NULL,
"createdAt" timestamp with time zone NOT NULL,
"expiresAt" timestamp with time zone
);
--> statement-breakpoint
CREATE TABLE "neon_auth"."member" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"organizationId" uuid NOT NULL,
"userId" uuid NOT NULL,
"role" text NOT NULL,
"createdAt" timestamp with time zone NOT NULL
);
--> statement-breakpoint
CREATE TABLE "neon_auth"."project_config" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"name" text NOT NULL,
"endpoint_id" text NOT NULL,
"created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
"updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
"trusted_origins" jsonb NOT NULL,
"social_providers" jsonb NOT NULL,
"email_provider" jsonb,
"email_and_password" jsonb,
"allow_localhost" boolean NOT NULL,
CONSTRAINT "project_config_endpoint_id_key" UNIQUE("endpoint_id")
);
--> statement-breakpoint
CREATE TABLE "test" (
"id" uuid PRIMARY KEY NOT NULL,
"user_id" text NOT NULL,
"data" text,
"is_published" boolean DEFAULT false NOT NULL
);
--> statement-breakpoint
ALTER TABLE "test" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
ALTER TABLE "neon_auth"."invitation" ADD CONSTRAINT "invitation_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "neon_auth"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "neon_auth"."invitation" ADD CONSTRAINT "invitation_inviterId_fkey" FOREIGN KEY ("inviterId") REFERENCES "neon_auth"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "neon_auth"."session" ADD CONSTRAINT "session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "neon_auth"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "neon_auth"."account" ADD CONSTRAINT "account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "neon_auth"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "neon_auth"."member" ADD CONSTRAINT "member_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "neon_auth"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "neon_auth"."member" ADD CONSTRAINT "member_userId_fkey" FOREIGN KEY ("userId") REFERENCES "neon_auth"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "invitation_email_idx" ON "neon_auth"."invitation" USING btree ("email" text_ops);--> statement-breakpoint
CREATE INDEX "invitation_organizationId_idx" ON "neon_auth"."invitation" USING btree ("organizationId" uuid_ops);--> statement-breakpoint
CREATE INDEX "session_userId_idx" ON "neon_auth"."session" USING btree ("userId" uuid_ops);--> statement-breakpoint
CREATE UNIQUE INDEX "organization_slug_uidx" ON "neon_auth"."organization" USING btree ("slug" text_ops);--> statement-breakpoint
CREATE INDEX "account_userId_idx" ON "neon_auth"."account" USING btree ("userId" uuid_ops);--> statement-breakpoint
CREATE INDEX "verification_identifier_idx" ON "neon_auth"."verification" USING btree ("identifier" text_ops);--> statement-breakpoint
CREATE INDEX "member_organizationId_idx" ON "neon_auth"."member" USING btree ("organizationId" uuid_ops);--> statement-breakpoint
CREATE INDEX "member_userId_idx" ON "neon_auth"."member" USING btree ("userId" uuid_ops);--> statement-breakpoint
CREATE POLICY "read_published" ON "test" AS PERMISSIVE FOR SELECT TO "authenticated" USING ((is_published = true));--> statement-breakpoint
CREATE POLICY "manage_own" ON "test" AS PERMISSIVE FOR ALL TO "authenticated";
*/
Loading