import type { Migration } from "../src/migrate.ts"; /** * Better Auth 1.7.7 schema (email+password core + `organization` + `admin` plugins), generated with * `getMigrations(auth.options).compileMigrations()` and checked in so one migration pipeline governs * every table (ADR-0010). Regenerate when plugins change; never edit by hand. */ export const migration0002Auth: Migration = { name: "0002_auth", sql: ` create table "user" ("id" text not null primary key, "name" text not null, "email" text not null unique, "emailVerified" integer not null, "image" text, "createdAt" date not null, "updatedAt" date not null, "role" text, "banned" integer, "banReason" text, "banExpires" date); create table "session" ("id" text not null primary key, "expiresAt" date not null, "token" text not null unique, "createdAt" date not null, "updatedAt" date not null, "ipAddress" text, "userAgent" text, "userId" text not null references "user" ("id") on delete cascade, "activeOrganizationId" text, "impersonatedBy" text); create table "account" ("id" text not null primary key, "accountId" text not null, "providerId" text not null, "userId" text not null references "user" ("id") on delete cascade, "accessToken" text, "refreshToken" text, "idToken" text, "accessTokenExpiresAt" date, "refreshTokenExpiresAt" date, "scope" text, "password" text, "createdAt" date not null, "updatedAt" date not null); create table "verification" ("id" text not null primary key, "identifier" text not null, "value" text not null, "expiresAt" date not null, "createdAt" date not null, "updatedAt" date not null); create table "organization" ("id" text not null primary key, "name" text not null, "slug" text not null unique, "logo" text, "createdAt" date not null, "metadata" text); create table "member" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "userId" text not null references "user" ("id") on delete cascade, "role" text not null, "createdAt" date not null); create table "invitation" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "email" text not null, "role" text, "teamId" text, "status" text not null, "expiresAt" date not null, "createdAt" date not null, "inviterId" text not null references "user" ("id") on delete cascade); create index "session_userId_idx" on "session" ("userId"); create index "account_userId_idx" on "account" ("userId"); create index "verification_identifier_idx" on "verification" ("identifier"); create index "member_organizationId_idx" on "member" ("organizationId"); create index "member_userId_idx" on "member" ("userId"); create index "invitation_organizationId_idx" on "invitation" ("organizationId"); create index "invitation_email_idx" on "invitation" ("email"); `, };