settlekit/packages/database/drizzle/0004_auth_persistence.sql
2026-06-16 02:51:34 +03:00

48 lines
2.2 KiB
SQL

CREATE TABLE "auth_accounts" (
"id" text PRIMARY KEY NOT NULL,
"type" text NOT NULL,
"email" text NOT NULL,
"organization_id" text,
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "auth_accounts_email_unique" UNIQUE("email")
);
--> statement-breakpoint
CREATE TABLE "auth_magic_links" (
"id" text PRIMARY KEY NOT NULL,
"token_hash" text NOT NULL,
"email" text NOT NULL,
"expires_at" timestamp with time zone NOT NULL,
"consumed_at" timestamp with time zone,
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "auth_magic_links_token_hash_unique" UNIQUE("token_hash")
);
--> statement-breakpoint
CREATE TABLE "auth_password_credentials" (
"id" text PRIMARY KEY NOT NULL,
"account_id" text NOT NULL,
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "auth_password_credentials_account_id_unique" UNIQUE("account_id")
);
--> statement-breakpoint
CREATE TABLE "auth_sessions" (
"id" text PRIMARY KEY NOT NULL,
"token_hash" text NOT NULL,
"account_id" text NOT NULL,
"expires_at" timestamp with time zone NOT NULL,
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "auth_sessions_token_hash_unique" UNIQUE("token_hash")
);
--> statement-breakpoint
CREATE INDEX "auth_accounts_email_idx" ON "auth_accounts" USING btree ("email");--> statement-breakpoint
CREATE INDEX "auth_magic_links_token_hash_idx" ON "auth_magic_links" USING btree ("token_hash");--> statement-breakpoint
CREATE INDEX "auth_password_credentials_account_id_idx" ON "auth_password_credentials" USING btree ("account_id");--> statement-breakpoint
CREATE INDEX "auth_sessions_token_hash_idx" ON "auth_sessions" USING btree ("token_hash");--> statement-breakpoint
CREATE INDEX "auth_sessions_account_id_idx" ON "auth_sessions" USING btree ("account_id");