auth 1.5.7-beta.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.mts +1 -2
- package/dist/api.mjs +0 -2
- package/dist/index.mjs +7 -12
- package/package.json +7 -11
- package/dist/api.mjs.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/api.d.mts
CHANGED
|
@@ -41,5 +41,4 @@ declare const generateKyselySchema: SchemaGenerator;
|
|
|
41
41
|
//#region src/generators/prisma.d.ts
|
|
42
42
|
declare const generatePrismaSchema: SchemaGenerator;
|
|
43
43
|
//#endregion
|
|
44
|
-
export { type DBAdapter, type SchemaGenerator, type SchemaGeneratorResult, adapters, generateDrizzleSchema, generateKyselySchema, generatePrismaSchema, generateSchema };
|
|
45
|
-
//# sourceMappingURL=api.d.mts.map
|
|
44
|
+
export { type DBAdapter, type SchemaGenerator, type SchemaGeneratorResult, adapters, generateDrizzleSchema, generateKyselySchema, generatePrismaSchema, generateSchema };
|
package/dist/api.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -890,7 +890,7 @@ async function tryCatch(promise) {
|
|
|
890
890
|
};
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
|
-
const generateSecretHash
|
|
893
|
+
const generateSecretHash = () => {
|
|
894
894
|
return Crypto.randomBytes(16).toString("hex");
|
|
895
895
|
};
|
|
896
896
|
const spawnCommand = (cmd, cwd = process.cwd()) => new Promise((resolve, reject) => {
|
|
@@ -5869,7 +5869,7 @@ async function initAction(opts) {
|
|
|
5869
5869
|
cancel("✋ Operation cancelled.");
|
|
5870
5870
|
process.exit(0);
|
|
5871
5871
|
}
|
|
5872
|
-
const envs = [`BETTER_AUTH_SECRET="${providedSecret || generateSecretHash
|
|
5872
|
+
const envs = [`BETTER_AUTH_SECRET="${providedSecret || generateSecretHash()}"`, `BETTER_AUTH_URL="${providedURL}"`];
|
|
5873
5873
|
envFiles.set(".env", envs);
|
|
5874
5874
|
filesToWrite.push(() => createEnvFile(cwd, envs));
|
|
5875
5875
|
}
|
|
@@ -5897,7 +5897,7 @@ async function initAction(opts) {
|
|
|
5897
5897
|
cancel("✋ Operation cancelled.");
|
|
5898
5898
|
process.exit(0);
|
|
5899
5899
|
}
|
|
5900
|
-
envs.push(`BETTER_AUTH_SECRET="${providedSecret || generateSecretHash
|
|
5900
|
+
envs.push(`BETTER_AUTH_SECRET="${providedSecret || generateSecretHash()}"`);
|
|
5901
5901
|
} else if (v === "BETTER_AUTH_URL") {
|
|
5902
5902
|
const { providedURL } = await prompts({
|
|
5903
5903
|
type: "text",
|
|
@@ -5928,7 +5928,7 @@ async function initAction(opts) {
|
|
|
5928
5928
|
process.exit(0);
|
|
5929
5929
|
}
|
|
5930
5930
|
if (filesToUpdate) {
|
|
5931
|
-
const secretHash = generateSecretHash
|
|
5931
|
+
const secretHash = generateSecretHash();
|
|
5932
5932
|
for (const file of filesToUpdate) {
|
|
5933
5933
|
const envs = missingEnvVars.find((x) => x.file === file).var.map((v) => {
|
|
5934
5934
|
if (v === "BETTER_AUTH_SECRET") return `BETTER_AUTH_SECRET="${secretHash}"`;
|
|
@@ -6624,7 +6624,7 @@ async function logoutAction() {
|
|
|
6624
6624
|
const logout = new Command("logout").description("Logout from Better Auth Infrastructure").action(logoutAction);
|
|
6625
6625
|
//#endregion
|
|
6626
6626
|
//#region src/commands/mcp.ts
|
|
6627
|
-
const REMOTE_MCP_URL = "https://mcp.
|
|
6627
|
+
const REMOTE_MCP_URL = "https://mcp.better-auth.com/mcp";
|
|
6628
6628
|
async function mcpAction(options) {
|
|
6629
6629
|
if (options.cursor) await handleCursorAction();
|
|
6630
6630
|
else if (options.claudeCode) handleClaudeCodeAction();
|
|
@@ -6884,13 +6884,10 @@ const migrate = new Command("migrate").option("-c, --cwd <cwd>", "the working di
|
|
|
6884
6884
|
//#endregion
|
|
6885
6885
|
//#region src/commands/secret.ts
|
|
6886
6886
|
const generateSecret = new Command("secret").action(() => {
|
|
6887
|
-
const secret =
|
|
6888
|
-
console.log(`\nAdd the following to your .env file:
|
|
6887
|
+
const secret = Crypto.randomBytes(32).toString("hex");
|
|
6888
|
+
console.log(`\nAdd the following to your .env file:
|
|
6889
6889
|
${chalk.gray("# Auth Secret") + chalk.green(`\nBETTER_AUTH_SECRET=${secret}`)}`);
|
|
6890
6890
|
});
|
|
6891
|
-
const generateSecretHash = () => {
|
|
6892
|
-
return Crypto.randomBytes(32).toString("hex");
|
|
6893
|
-
};
|
|
6894
6891
|
//#endregion
|
|
6895
6892
|
//#region src/utils/fetch-latest-version.ts
|
|
6896
6893
|
async function fetchLatestVersion(packageName) {
|
|
@@ -7028,5 +7025,3 @@ main().catch((error) => {
|
|
|
7028
7025
|
});
|
|
7029
7026
|
//#endregion
|
|
7030
7027
|
export { cliVersion };
|
|
7031
|
-
|
|
7032
|
-
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auth",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "The CLI for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,27 +46,23 @@
|
|
|
46
46
|
"@babel/core": "^7.29.0",
|
|
47
47
|
"@babel/preset-react": "^7.28.5",
|
|
48
48
|
"@babel/preset-typescript": "^7.28.5",
|
|
49
|
-
"@better-auth/utils": "0.
|
|
49
|
+
"@better-auth/utils": "0.4.0",
|
|
50
50
|
"@clack/prompts": "^0.11.0",
|
|
51
51
|
"@mrleebo/prisma-ast": "^0.13.1",
|
|
52
|
-
"@prisma/client": "^7.4.1",
|
|
53
|
-
"@types/pg": "^8.16.0",
|
|
54
52
|
"c12": "^3.3.3",
|
|
55
53
|
"chalk": "^5.6.2",
|
|
56
54
|
"commander": "^12.1.0",
|
|
57
55
|
"dotenv": "^17.3.1",
|
|
58
|
-
"drizzle-orm": "^0.41.0",
|
|
59
56
|
"get-tsconfig": "^4.13.6",
|
|
60
57
|
"open": "^10.2.0",
|
|
61
|
-
"pg": "^8.19.0",
|
|
62
58
|
"prettier": "^3.8.1",
|
|
63
59
|
"prompts": "^2.4.2",
|
|
64
60
|
"semver": "^7.7.4",
|
|
65
61
|
"yocto-spinner": "^0.2.3",
|
|
66
62
|
"zod": "^4.3.6",
|
|
67
|
-
"@better-auth/
|
|
68
|
-
"
|
|
69
|
-
"better-auth": "1.
|
|
63
|
+
"@better-auth/core": "1.6.0",
|
|
64
|
+
"better-auth": "1.6.0",
|
|
65
|
+
"@better-auth/telemetry": "1.6.0"
|
|
70
66
|
},
|
|
71
67
|
"devDependencies": {
|
|
72
68
|
"@types/better-sqlite3": "^7.6.13",
|
|
@@ -79,13 +75,13 @@
|
|
|
79
75
|
"tsx": "^4.21.0",
|
|
80
76
|
"type-fest": "^5.4.4",
|
|
81
77
|
"typescript": "^5.9.3",
|
|
82
|
-
"@better-auth/passkey": "1.
|
|
78
|
+
"@better-auth/passkey": "1.6.0"
|
|
83
79
|
},
|
|
84
80
|
"scripts": {
|
|
85
81
|
"build": "tsdown",
|
|
86
82
|
"dev": "tsx ./src/index.ts",
|
|
87
83
|
"start": "node ./dist/index.mjs",
|
|
88
|
-
"lint:package": "publint run --strict",
|
|
84
|
+
"lint:package": "publint run --strict --pack false",
|
|
89
85
|
"lint:types": "attw --profile esm-only --pack .",
|
|
90
86
|
"typecheck": "tsc --project tsconfig.json",
|
|
91
87
|
"test": "vitest",
|
package/dist/api.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.mjs","names":[],"sources":["../src/generators/drizzle.ts","../src/generators/kysely.ts","../src/utils/get-package-info.ts","../src/generators/prisma.ts","../src/generators/index.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { initGetFieldName, initGetModelName } from \"better-auth/adapters\";\nimport type { BetterAuthDBSchema, DBFieldAttribute } from \"better-auth/db\";\nimport { getAuthTables } from \"better-auth/db\";\nimport type { BetterAuthOptions } from \"better-auth/types\";\nimport prettier from \"prettier\";\nimport type { SchemaGenerator } from \"./types\";\n\nfunction convertToSnakeCase(str: string, camelCase?: boolean) {\n\tif (camelCase) {\n\t\treturn str;\n\t}\n\t// Handle consecutive capitals (like ID, URL, API) by treating them as a single word\n\treturn str\n\t\t.replace(/([A-Z]+)([A-Z][a-z])/g, \"$1_$2\") // Handle AABb -> AA_Bb\n\t\t.replace(/([a-z\\d])([A-Z])/g, \"$1_$2\") // Handle aBb -> a_Bb\n\t\t.toLowerCase();\n}\n\nexport const generateDrizzleSchema: SchemaGenerator = async ({\n\toptions,\n\tfile,\n\tadapter,\n}) => {\n\tconst tables = getAuthTables(options);\n\tconst filePath = file || \"./auth-schema.ts\";\n\tconst databaseType: \"sqlite\" | \"mysql\" | \"pg\" | undefined =\n\t\tadapter.options?.provider;\n\n\tif (!databaseType) {\n\t\tthrow new Error(\n\t\t\t`Database provider type is undefined during Drizzle schema generation. Please define a \\`provider\\` in the Drizzle adapter config. Read more at https://better-auth.com/docs/adapters/drizzle`,\n\t\t);\n\t}\n\tconst fileExist = existsSync(filePath);\n\n\tlet code: string = generateImport({\n\t\tdatabaseType,\n\t\ttables,\n\t\toptions,\n\t});\n\n\tconst getModelName = initGetModelName({\n\t\tschema: tables,\n\t\tusePlural: adapter.options?.adapterConfig?.usePlural,\n\t});\n\n\tconst getFieldName = initGetFieldName({\n\t\tschema: tables,\n\t\tusePlural: adapter.options?.adapterConfig?.usePlural,\n\t});\n\n\tfor (const tableKey in tables) {\n\t\tconst table = tables[tableKey]!;\n\t\tconst modelName = getModelName(tableKey);\n\t\tconst fields = table.fields;\n\n\t\tfunction getType(name: string, field: DBFieldAttribute) {\n\t\t\t// Not possible to reach, it's here to make typescript happy\n\t\t\tif (!databaseType) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Database provider type is undefined during Drizzle schema generation. Please define a \\`provider\\` in the Drizzle adapter config. Read more at https://better-auth.com/docs/adapters/drizzle`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tname = convertToSnakeCase(name, adapter.options?.camelCase);\n\t\t\tif (field.references?.field === \"id\") {\n\t\t\t\tconst useNumberId = options.advanced?.database?.generateId === \"serial\";\n\t\t\t\tconst useUUIDs = options.advanced?.database?.generateId === \"uuid\";\n\t\t\t\tif (useNumberId) {\n\t\t\t\t\tif (databaseType === \"pg\") {\n\t\t\t\t\t\treturn `integer('${name}')`;\n\t\t\t\t\t} else if (databaseType === \"mysql\") {\n\t\t\t\t\t\treturn `int('${name}')`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// using sqlite\n\t\t\t\t\t\treturn `integer('${name}')`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (useUUIDs && databaseType === \"pg\") {\n\t\t\t\t\treturn `uuid('${name}')`;\n\t\t\t\t}\n\t\t\t\tif (field.references.field) {\n\t\t\t\t\tif (databaseType === \"mysql\") {\n\t\t\t\t\t\treturn `varchar('${name}', { length: 36 })`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn `text('${name}')`;\n\t\t\t}\n\t\t\tconst type = field.type;\n\t\t\tif (typeof type !== \"string\") {\n\t\t\t\tif (Array.isArray(type) && type.every((x) => typeof x === \"string\")) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsqlite: `text({ enum: [${type.map((x) => `'${x}'`).join(\", \")}] })`,\n\t\t\t\t\t\tpg: `text('${name}', { enum: [${type.map((x) => `'${x}'`).join(\", \")}] })`,\n\t\t\t\t\t\tmysql: `mysqlEnum([${type.map((x) => `'${x}'`).join(\", \")}])`,\n\t\t\t\t\t}[databaseType];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`Invalid field type for field ${name} in model ${modelName}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst typeMap: Record<\n\t\t\t\ttypeof type,\n\t\t\t\tRecord<typeof databaseType, string>\n\t\t\t> = {\n\t\t\t\tstring: {\n\t\t\t\t\tsqlite: `text('${name}')`,\n\t\t\t\t\tpg: `text('${name}')`,\n\t\t\t\t\tmysql: field.unique\n\t\t\t\t\t\t? `varchar('${name}', { length: 255 })`\n\t\t\t\t\t\t: field.references\n\t\t\t\t\t\t\t? `varchar('${name}', { length: 36 })`\n\t\t\t\t\t\t\t: field.sortable\n\t\t\t\t\t\t\t\t? `varchar('${name}', { length: 255 })`\n\t\t\t\t\t\t\t\t: field.index\n\t\t\t\t\t\t\t\t\t? `varchar('${name}', { length: 255 })`\n\t\t\t\t\t\t\t\t\t: `text('${name}')`,\n\t\t\t\t},\n\t\t\t\tboolean: {\n\t\t\t\t\tsqlite: `integer('${name}', { mode: 'boolean' })`,\n\t\t\t\t\tpg: `boolean('${name}')`,\n\t\t\t\t\tmysql: `boolean('${name}')`,\n\t\t\t\t},\n\t\t\t\tnumber: {\n\t\t\t\t\tsqlite: `integer('${name}')`,\n\t\t\t\t\tpg: field.bigint\n\t\t\t\t\t\t? `bigint('${name}', { mode: 'number' })`\n\t\t\t\t\t\t: `integer('${name}')`,\n\t\t\t\t\tmysql: field.bigint\n\t\t\t\t\t\t? `bigint('${name}', { mode: 'number' })`\n\t\t\t\t\t\t: `int('${name}')`,\n\t\t\t\t},\n\t\t\t\tdate: {\n\t\t\t\t\tsqlite: `integer('${name}', { mode: 'timestamp_ms' })`,\n\t\t\t\t\tpg: `timestamp('${name}')`,\n\t\t\t\t\tmysql: `timestamp('${name}', { fsp: 3 })`,\n\t\t\t\t},\n\t\t\t\t\"number[]\": {\n\t\t\t\t\tsqlite: `text('${name}', { mode: \"json\" })`,\n\t\t\t\t\tpg: field.bigint\n\t\t\t\t\t\t? `bigint('${name}', { mode: 'number' }).array()`\n\t\t\t\t\t\t: `integer('${name}').array()`,\n\t\t\t\t\tmysql: `text('${name}', { mode: 'json' })`,\n\t\t\t\t},\n\t\t\t\t\"string[]\": {\n\t\t\t\t\tsqlite: `text('${name}', { mode: \"json\" })`,\n\t\t\t\t\tpg: `text('${name}').array()`,\n\t\t\t\t\tmysql: `text('${name}', { mode: \"json\" })`,\n\t\t\t\t},\n\t\t\t\tjson: {\n\t\t\t\t\tsqlite: `text('${name}', { mode: \"json\" })`,\n\t\t\t\t\tpg: `jsonb('${name}')`,\n\t\t\t\t\tmysql: `json('${name}', { mode: \"json\" })`,\n\t\t\t\t},\n\t\t\t} as const;\n\t\t\tconst dbTypeMap = (\n\t\t\t\ttypeMap as Record<string, Record<typeof databaseType, string>>\n\t\t\t)[type as string];\n\t\t\tif (!dbTypeMap) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Unsupported field type '${field.type}' for field '${name}'.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn dbTypeMap[databaseType];\n\t\t}\n\n\t\tlet id: string = \"\";\n\n\t\tconst useNumberId = options.advanced?.database?.generateId === \"serial\";\n\t\tconst useUUIDs = options.advanced?.database?.generateId === \"uuid\";\n\n\t\tif (useUUIDs && databaseType === \"pg\") {\n\t\t\tid = `uuid(\"id\").default(sql\\`pg_catalog.gen_random_uuid()\\`).primaryKey()`;\n\t\t} else if (useNumberId) {\n\t\t\tif (databaseType === \"pg\") {\n\t\t\t\tid = `integer(\"id\").generatedByDefaultAsIdentity().primaryKey()`;\n\t\t\t} else if (databaseType === \"sqlite\") {\n\t\t\t\tid = `integer(\"id\", { mode: \"number\" }).primaryKey({ autoIncrement: true })`;\n\t\t\t} else {\n\t\t\t\tid = `int(\"id\").autoincrement().primaryKey()`;\n\t\t\t}\n\t\t} else {\n\t\t\tif (databaseType === \"mysql\") {\n\t\t\t\tid = `varchar('id', { length: 36 }).primaryKey()`;\n\t\t\t} else if (databaseType === \"pg\") {\n\t\t\t\tid = `text('id').primaryKey()`;\n\t\t\t} else {\n\t\t\t\tid = `text('id').primaryKey()`;\n\t\t\t}\n\t\t}\n\n\t\ttype Index = { type: \"uniqueIndex\" | \"index\"; name: string; on: string };\n\n\t\tconst indexes: Index[] = [];\n\n\t\tconst assignIndexes = (indexes: Index[]): string => {\n\t\t\tif (!indexes.length) return \"\";\n\n\t\t\tconst code: string[] = [`, (table) => [`];\n\n\t\t\tfor (const index of indexes) {\n\t\t\t\tcode.push(` ${index.type}(\"${index.name}\").on(table.${index.on}),`);\n\t\t\t}\n\n\t\t\tcode.push(`]`);\n\n\t\t\treturn code.join(\"\\n\");\n\t\t};\n\n\t\tconst schema = `export const ${modelName} = ${databaseType}Table(\"${convertToSnakeCase(\n\t\t\tmodelName,\n\t\t\tadapter.options?.camelCase,\n\t\t)}\", {\n\t\t\t\t\tid: ${id},\n\t\t\t\t\t${Object.keys(fields)\n\t\t\t\t\t\t.map((field) => {\n\t\t\t\t\t\t\tconst attr = fields[field]!;\n\t\t\t\t\t\t\tconst fieldName = attr.fieldName || field;\n\t\t\t\t\t\t\tlet type = getType(fieldName, attr);\n\n\t\t\t\t\t\t\tif (attr.index && !attr.unique) {\n\t\t\t\t\t\t\t\tindexes.push({\n\t\t\t\t\t\t\t\t\ttype: \"index\",\n\t\t\t\t\t\t\t\t\tname: `${modelName}_${fieldName}_idx`,\n\t\t\t\t\t\t\t\t\ton: fieldName,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else if (attr.index && attr.unique) {\n\t\t\t\t\t\t\t\tindexes.push({\n\t\t\t\t\t\t\t\t\ttype: \"uniqueIndex\",\n\t\t\t\t\t\t\t\t\tname: `${modelName}_${fieldName}_uidx`,\n\t\t\t\t\t\t\t\t\ton: fieldName,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tattr.defaultValue !== null &&\n\t\t\t\t\t\t\t\ttypeof attr.defaultValue !== \"undefined\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tif (typeof attr.defaultValue === \"function\") {\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tattr.type === \"date\" &&\n\t\t\t\t\t\t\t\t\t\tattr.defaultValue.toString().includes(\"new Date()\")\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tif (databaseType === \"sqlite\") {\n\t\t\t\t\t\t\t\t\t\t\ttype += `.default(sql\\`(cast(unixepoch('subsecond') * 1000 as integer))\\`)`;\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\ttype += `.defaultNow()`;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t// we are intentionally not adding .$defaultFn(${attr.defaultValue})\n\t\t\t\t\t\t\t\t\t\t// this is because if the defaultValue is a function, it could have\n\t\t\t\t\t\t\t\t\t\t// custom logic within that function that might not work in drizzle's context.\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else if (typeof attr.defaultValue === \"string\") {\n\t\t\t\t\t\t\t\t\ttype += `.default(\"${attr.defaultValue}\")`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\ttype += `.default(${attr.defaultValue})`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Add .$onUpdate() for fields with onUpdate property\n\t\t\t\t\t\t\t// Supported for all database types: PostgreSQL, MySQL, and SQLite\n\t\t\t\t\t\t\tif (attr.onUpdate && attr.type === \"date\") {\n\t\t\t\t\t\t\t\tif (typeof attr.onUpdate === \"function\") {\n\t\t\t\t\t\t\t\t\ttype += `.$onUpdate(${attr.onUpdate})`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn `${fieldName}: ${type}${attr.required !== false ? \".notNull()\" : \"\"}${\n\t\t\t\t\t\t\t\tattr.unique ? \".unique()\" : \"\"\n\t\t\t\t\t\t\t}${\n\t\t\t\t\t\t\t\tattr.references\n\t\t\t\t\t\t\t\t\t? `.references(()=> ${getModelName(\n\t\t\t\t\t\t\t\t\t\t\tattr.references.model,\n\t\t\t\t\t\t\t\t\t\t)}.${getFieldName({ model: attr.references.model, field: attr.references.field })}, { onDelete: '${\n\t\t\t\t\t\t\t\t\t\t\tattr.references.onDelete || \"cascade\"\n\t\t\t\t\t\t\t\t\t\t}' })`\n\t\t\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t\t\t}`;\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join(\",\\n \")}\n\t\t\t\t\t}${assignIndexes(indexes)});`;\n\t\tcode += `\\n${schema}\\n`;\n\t}\n\n\tlet relationsString: string = \"\";\n\tfor (const tableKey in tables) {\n\t\tconst table = tables[tableKey]!;\n\t\tconst modelName = getModelName(tableKey);\n\n\t\ttype Relation = {\n\t\t\t/**\n\t\t\t * The key of the relation that will be defined in the Drizzle schema.\n\t\t\t * For \"one\" relations: singular (e.g., \"user\")\n\t\t\t * For \"many\" relations: plural (e.g., \"posts\")\n\t\t\t */\n\t\t\tkey: string;\n\t\t\t/**\n\t\t\t * The model name being referenced.\n\t\t\t */\n\t\t\tmodel: string;\n\t\t\t/**\n\t\t\t * The type of the relation: \"one\" (many-to-one) or \"many\" (one-to-many).\n\t\t\t */\n\t\t\ttype: \"one\" | \"many\";\n\t\t\t/**\n\t\t\t * Foreign key field name and reference details (only for \"one\" relations).\n\t\t\t */\n\t\t\treference?: {\n\t\t\t\tfield: string;\n\t\t\t\treferences: string;\n\t\t\t\tfieldName: string; // Original field name for generating unique relation export names\n\t\t\t};\n\t\t};\n\n\t\tconst oneRelations: Relation[] = [];\n\t\tconst manyRelations: Relation[] = [];\n\t\t// Set to track \"many\" relations by key to prevent duplicates\n\t\tconst manyRelationsSet = new Set<string>();\n\n\t\t// 1. Find all foreign keys in THIS table (creates \"one\" relations)\n\t\tconst fields = Object.entries(table.fields);\n\t\tconst foreignFields = fields.filter(([_, field]) => field.references);\n\n\t\tfor (const [fieldName, field] of foreignFields) {\n\t\t\tconst referencedModel = field.references!.model;\n\t\t\tconst relationKey = getModelName(referencedModel);\n\t\t\tconst fieldRef = `${getModelName(tableKey)}.${getFieldName({ model: tableKey, field: fieldName })}`;\n\t\t\tconst referenceRef = `${getModelName(referencedModel)}.${getFieldName({ model: referencedModel, field: field.references!.field || \"id\" })}`;\n\n\t\t\t// Create a separate relation for each foreign key\n\t\t\toneRelations.push({\n\t\t\t\tkey: relationKey,\n\t\t\t\tmodel: getModelName(referencedModel),\n\t\t\t\ttype: \"one\",\n\t\t\t\treference: {\n\t\t\t\t\tfield: fieldRef,\n\t\t\t\t\treferences: referenceRef,\n\t\t\t\t\tfieldName: fieldName,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// 2. Find all OTHER tables that reference THIS table (creates \"many\" relations)\n\t\tconst otherModels = Object.entries(tables).filter(\n\t\t\t([modelName]) => modelName !== tableKey,\n\t\t);\n\n\t\t// Map to track relations by model name to determine if unique or many\n\t\tconst modelRelationsMap = new Map<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tmodelName: string;\n\t\t\t\thasUnique: boolean;\n\t\t\t\thasMany: boolean;\n\t\t\t}\n\t\t>();\n\n\t\tfor (const [modelName, otherTable] of otherModels) {\n\t\t\tconst foreignKeysPointingHere = Object.entries(otherTable.fields).filter(\n\t\t\t\t([_, field]) =>\n\t\t\t\t\tfield.references?.model === tableKey ||\n\t\t\t\t\tfield.references?.model === getModelName(tableKey),\n\t\t\t);\n\n\t\t\tif (foreignKeysPointingHere.length === 0) continue;\n\n\t\t\t// Check if any foreign key is unique\n\t\t\tconst hasUnique = foreignKeysPointingHere.some(\n\t\t\t\t([_, field]) => !!field.unique,\n\t\t\t);\n\t\t\tconst hasMany = foreignKeysPointingHere.some(\n\t\t\t\t([_, field]) => !field.unique,\n\t\t\t);\n\n\t\t\tmodelRelationsMap.set(modelName, {\n\t\t\t\tmodelName,\n\t\t\t\thasUnique,\n\t\t\t\thasMany,\n\t\t\t});\n\t\t}\n\n\t\t// Add relations, deduplicating by relationKey\n\t\tfor (const { modelName, hasMany } of modelRelationsMap.values()) {\n\t\t\t// Determine relation type: if all are unique, it's \"one\", otherwise \"many\"\n\t\t\tconst relationType = hasMany ? \"many\" : \"one\";\n\t\t\tlet relationKey = getModelName(modelName);\n\n\t\t\t// We have to apply this after checking if they have usePlural because otherwise they will end up seeing:\n\t\t\t/* cspell:disable-next-line */\n\t\t\t// \"sesionss\", or \"accountss\" - double s's.\n\t\t\tif (\n\t\t\t\t!adapter.options?.adapterConfig?.usePlural &&\n\t\t\t\trelationType === \"many\"\n\t\t\t) {\n\t\t\t\trelationKey = `${relationKey}s`;\n\t\t\t}\n\n\t\t\t// Only add if we haven't seen this key before\n\t\t\tif (!manyRelationsSet.has(relationKey)) {\n\t\t\t\tmanyRelationsSet.add(relationKey);\n\t\t\t\tmanyRelations.push({\n\t\t\t\t\tkey: relationKey,\n\t\t\t\t\tmodel: getModelName(modelName),\n\t\t\t\t\ttype: relationType,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Group \"one\" relations by referenced model to detect duplicates\n\t\tconst relationsByModel = new Map<string, Relation[]>();\n\t\tfor (const relation of oneRelations) {\n\t\t\tif (relation.reference) {\n\t\t\t\tconst modelKey = relation.key;\n\t\t\t\tif (!relationsByModel.has(modelKey)) {\n\t\t\t\t\trelationsByModel.set(modelKey, []);\n\t\t\t\t}\n\t\t\t\trelationsByModel.get(modelKey)!.push(relation);\n\t\t\t}\n\t\t}\n\n\t\t// Separate relations with duplicates (same model) from those without\n\t\tconst duplicateRelations: Relation[] = [];\n\t\tconst singleRelations: Relation[] = [];\n\n\t\tfor (const [_modelKey, relations] of relationsByModel.entries()) {\n\t\t\tif (relations.length > 1) {\n\t\t\t\t// Multiple relations to the same model - these need field-specific naming\n\t\t\t\tduplicateRelations.push(...relations);\n\t\t\t} else {\n\t\t\t\t// Single relation to this model - can be combined with others\n\t\t\t\tsingleRelations.push(relations[0]!);\n\t\t\t}\n\t\t}\n\n\t\t// Generate field-specific exports for duplicate relations\n\t\tfor (const relation of duplicateRelations) {\n\t\t\tif (relation.reference) {\n\t\t\t\tconst fieldName = relation.reference.fieldName;\n\t\t\t\tconst relationExportName = `${modelName}${fieldName.charAt(0).toUpperCase() + fieldName.slice(1)}Relations`;\n\n\t\t\t\tconst tableRelation = `export const ${relationExportName} = relations(${getModelName(\n\t\t\t\t\ttable.modelName,\n\t\t\t\t)}, ({ one }) => ({\n\t\t\t\t${relation.key}: one(${relation.model}, {\n\t\t\t\t\tfields: [${relation.reference.field}],\n\t\t\t\t\treferences: [${relation.reference.references}],\n\t\t\t\t})\n\t\t\t}))`;\n\n\t\t\t\trelationsString += `\\n${tableRelation}\\n`;\n\t\t\t}\n\t\t}\n\n\t\t// Combine all single \"one\" relations and \"many\" relations into exports\n\t\tconst hasOne = singleRelations.length > 0;\n\t\tconst hasMany = manyRelations.length > 0;\n\n\t\tif (hasOne && hasMany) {\n\t\t\t// Both \"one\" and \"many\" relations exist - combine in one export\n\t\t\tconst tableRelation = `export const ${modelName}Relations = relations(${getModelName(\n\t\t\t\ttable.modelName,\n\t\t\t)}, ({ one, many }) => ({\n\t\t\t\t${singleRelations\n\t\t\t\t\t.map((relation) =>\n\t\t\t\t\t\trelation.reference\n\t\t\t\t\t\t\t? ` ${relation.key}: one(${relation.model}, {\n\t\t\t\t\tfields: [${relation.reference.field}],\n\t\t\t\t\treferences: [${relation.reference.references}],\n\t\t\t\t})`\n\t\t\t\t\t\t\t: \"\",\n\t\t\t\t\t)\n\t\t\t\t\t.filter((x) => x !== \"\")\n\t\t\t\t\t.join(\",\\n \")}${\n\t\t\t\t\tsingleRelations.length > 0 && manyRelations.length > 0 ? \",\" : \"\"\n\t\t\t\t}\n\t\t\t\t${manyRelations\n\t\t\t\t\t.map(({ key, model }) => ` ${key}: many(${model})`)\n\t\t\t\t\t.join(\",\\n \")}\n\t\t\t}))`;\n\n\t\t\trelationsString += `\\n${tableRelation}\\n`;\n\t\t} else if (hasOne) {\n\t\t\t// Only \"one\" relations exist\n\t\t\tconst tableRelation = `export const ${modelName}Relations = relations(${getModelName(\n\t\t\t\ttable.modelName,\n\t\t\t)}, ({ one }) => ({\n\t\t\t\t${singleRelations\n\t\t\t\t\t.map((relation) =>\n\t\t\t\t\t\trelation.reference\n\t\t\t\t\t\t\t? ` ${relation.key}: one(${relation.model}, {\n\t\t\t\t\tfields: [${relation.reference.field}],\n\t\t\t\t\treferences: [${relation.reference.references}],\n\t\t\t\t})`\n\t\t\t\t\t\t\t: \"\",\n\t\t\t\t\t)\n\t\t\t\t\t.filter((x) => x !== \"\")\n\t\t\t\t\t.join(\",\\n \")}\n\t\t\t}))`;\n\n\t\t\trelationsString += `\\n${tableRelation}\\n`;\n\t\t} else if (hasMany) {\n\t\t\t// Only \"many\" relations exist\n\t\t\tconst tableRelation = `export const ${modelName}Relations = relations(${getModelName(\n\t\t\t\ttable.modelName,\n\t\t\t)}, ({ many }) => ({\n\t\t\t\t${manyRelations\n\t\t\t\t\t.map(({ key, model }) => ` ${key}: many(${model})`)\n\t\t\t\t\t.join(\",\\n \")}\n\t\t\t}))`;\n\n\t\t\trelationsString += `\\n${tableRelation}\\n`;\n\t\t}\n\t}\n\tcode += `\\n${relationsString}`;\n\n\tconst formattedCode = await prettier.format(code, {\n\t\tparser: \"typescript\",\n\t});\n\treturn {\n\t\tcode: formattedCode,\n\t\tfileName: filePath,\n\t\toverwrite: fileExist,\n\t};\n};\n\nfunction generateImport({\n\tdatabaseType,\n\ttables,\n\toptions,\n}: {\n\tdatabaseType: \"sqlite\" | \"mysql\" | \"pg\";\n\ttables: BetterAuthDBSchema;\n\toptions: BetterAuthOptions;\n}) {\n\tconst rootImports: string[] = [\"relations\"];\n\tconst coreImports: string[] = [];\n\n\tlet hasBigint = false;\n\tlet hasJson = false;\n\n\tfor (const table of Object.values(tables)) {\n\t\tfor (const field of Object.values(table.fields)) {\n\t\t\tif (field.bigint) hasBigint = true;\n\t\t\tif (field.type === \"json\") hasJson = true;\n\t\t}\n\t\tif (hasJson && hasBigint) break;\n\t}\n\n\tconst useNumberId = options.advanced?.database?.generateId === \"serial\";\n\n\tconst useUUIDs = options.advanced?.database?.generateId === \"uuid\";\n\n\tcoreImports.push(`${databaseType}Table`);\n\tcoreImports.push(\n\t\tdatabaseType === \"mysql\"\n\t\t\t? \"varchar, text\"\n\t\t\t: databaseType === \"pg\"\n\t\t\t\t? \"text\"\n\t\t\t\t: \"text\",\n\t);\n\tcoreImports.push(\n\t\thasBigint ? (databaseType !== \"sqlite\" ? \"bigint\" : \"\") : \"\",\n\t);\n\tcoreImports.push(databaseType !== \"sqlite\" ? \"timestamp, boolean\" : \"\");\n\tif (databaseType === \"mysql\") {\n\t\t// Only include int for MySQL if actually needed\n\t\tconst hasNonBigintNumber = Object.values(tables).some((table) =>\n\t\t\tObject.values(table.fields).some(\n\t\t\t\t(field) =>\n\t\t\t\t\t(field.type === \"number\" || field.type === \"number[]\") &&\n\t\t\t\t\t!field.bigint,\n\t\t\t),\n\t\t);\n\t\tconst needsInt = useNumberId || hasNonBigintNumber;\n\t\tif (needsInt) {\n\t\t\tcoreImports.push(\"int\");\n\t\t}\n\t\tconst hasEnum = Object.values(tables).some((table) =>\n\t\t\tObject.values(table.fields).some(\n\t\t\t\t(field) =>\n\t\t\t\t\ttypeof field.type !== \"string\" &&\n\t\t\t\t\tArray.isArray(field.type) &&\n\t\t\t\t\tfield.type.every((x) => typeof x === \"string\"),\n\t\t\t),\n\t\t);\n\t\tif (hasEnum) {\n\t\t\tcoreImports.push(\"mysqlEnum\");\n\t\t}\n\t} else if (databaseType === \"pg\") {\n\t\tif (useUUIDs) {\n\t\t\trootImports.push(\"sql\");\n\t\t}\n\n\t\t// Only include integer for PG if actually needed\n\t\tconst hasNonBigintNumber = Object.values(tables).some((table) =>\n\t\t\tObject.values(table.fields).some(\n\t\t\t\t(field) =>\n\t\t\t\t\t(field.type === \"number\" || field.type === \"number[]\") &&\n\t\t\t\t\t!field.bigint,\n\t\t\t),\n\t\t);\n\t\tconst hasFkToId = Object.values(tables).some((table) =>\n\t\t\tObject.values(table.fields).some(\n\t\t\t\t(field) => field.references?.field === \"id\",\n\t\t\t),\n\t\t);\n\t\t// handles the references field with useNumberId\n\t\tconst needsInteger =\n\t\t\thasNonBigintNumber ||\n\t\t\t(options.advanced?.database?.generateId === \"serial\" && hasFkToId);\n\t\tif (needsInteger) {\n\t\t\tcoreImports.push(\"integer\");\n\t\t}\n\t} else {\n\t\tcoreImports.push(\"integer\");\n\t}\n\tif (databaseType === \"pg\" && useUUIDs) {\n\t\tcoreImports.push(\"uuid\");\n\t}\n\n\t//handle json last on the import order\n\tif (hasJson) {\n\t\tif (databaseType === \"pg\") coreImports.push(\"jsonb\");\n\t\tif (databaseType === \"mysql\") coreImports.push(\"json\");\n\t\t// sqlite uses text for JSON, so there's no need to handle this case\n\t}\n\n\t// Add sql import for SQLite timestamps with defaultNow\n\tconst hasSQLiteTimestamp =\n\t\tdatabaseType === \"sqlite\" &&\n\t\tObject.values(tables).some((table) =>\n\t\t\tObject.values(table.fields).some(\n\t\t\t\t(field) =>\n\t\t\t\t\tfield.type === \"date\" &&\n\t\t\t\t\tfield.defaultValue &&\n\t\t\t\t\ttypeof field.defaultValue === \"function\" &&\n\t\t\t\t\tfield.defaultValue.toString().includes(\"new Date()\"),\n\t\t\t),\n\t\t);\n\n\tif (hasSQLiteTimestamp) {\n\t\trootImports.push(\"sql\");\n\t}\n\n\t//handle indexes\n\tconst hasIndexes = Object.values(tables).some((table) =>\n\t\tObject.values(table.fields).some((field) => field.index && !field.unique),\n\t);\n\tconst hasUniqueIndexes = Object.values(tables).some((table) =>\n\t\tObject.values(table.fields).some((field) => field.unique && field.index),\n\t);\n\tif (hasIndexes) {\n\t\tcoreImports.push(\"index\");\n\t}\n\tif (hasUniqueIndexes) {\n\t\tcoreImports.push(\"uniqueIndex\");\n\t}\n\n\treturn `${rootImports.length > 0 ? `import { ${rootImports.join(\", \")} } from \"drizzle-orm\";\\n` : \"\"}import { ${coreImports\n\t\t.map((x) => x.trim())\n\t\t.filter((x) => x !== \"\")\n\t\t.join(\", \")} } from \"drizzle-orm/${databaseType}-core\";\\n`;\n}\n","import { getMigrations } from \"better-auth/db/migration\";\nimport type { SchemaGenerator } from \"./types\";\n\nexport const generateKyselySchema: SchemaGenerator = async ({\n\toptions,\n\tfile,\n}) => {\n\tconst { compileMigrations } = await getMigrations(options);\n\tconst migrations = await compileMigrations();\n\treturn {\n\t\tcode: migrations.trim() === \";\" ? \"\" : migrations,\n\t\tfileName:\n\t\t\tfile ||\n\t\t\t`./better-auth_migrations/${new Date()\n\t\t\t\t.toISOString()\n\t\t\t\t.replace(/:/g, \"-\")}.sql`,\n\t};\n};\n","import { readFileSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { tryCatch } from \"./helper\";\n\nexport function getPackageInfo(cwd?: string) {\n\tconst packageJsonPath = cwd\n\t\t? path.join(cwd, \"package.json\")\n\t\t: path.join(\"package.json\");\n\treturn JSON.parse(readFileSync(packageJsonPath, \"utf-8\"));\n}\n\nexport function getPrismaVersion(cwd?: string): number | null {\n\ttry {\n\t\tconst packageInfo = getPackageInfo(cwd);\n\t\tconst prismaVersion =\n\t\t\tpackageInfo.dependencies?.prisma ||\n\t\t\tpackageInfo.devDependencies?.prisma ||\n\t\t\tpackageInfo.dependencies?.[\"@prisma/client\"] ||\n\t\t\tpackageInfo.devDependencies?.[\"@prisma/client\"];\n\n\t\tif (!prismaVersion) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Extract major version number from version string\n\t\t// Handles versions like \"^5.0.0\", \"~7.1.0\", \"7.0.0\", etc.\n\t\tconst match = prismaVersion.match(/(\\d+)/);\n\t\treturn match ? parseInt(match[1], 10) : null;\n\t} catch {\n\t\t// If package.json doesn't exist or can't be read, return null\n\t\treturn null;\n\t}\n}\n\n/**\n * Checks if a package has a specific dependency.\n *\n * @param packageJson The package.json object\n * @param dependency The dependency to check for\n * @returns true if the package has the dependency\n */\nexport function hasDependency(packageJson: any, dependency: string) {\n\tlet hasDependency = false;\n\n\tif (\n\t\tpackageJson.dependencies?.[dependency] ||\n\t\tpackageJson.devDependencies?.[dependency] ||\n\t\tpackageJson.peerDependencies?.[dependency] ||\n\t\tpackageJson.optionalDependencies?.[dependency]\n\t) {\n\t\thasDependency = true;\n\t}\n\n\treturn hasDependency;\n}\n\n/**\n * Checks if a directory is a monorepo root by looking for common monorepo indicators.\n *\n * @param dir Directory to check\n * @returns true if the directory appears to be a monorepo root\n */\nasync function isMonorepoRoot(dir: string) {\n\tconst { data: files } = await tryCatch(fs.readdir(dir, \"utf-8\"));\n\tif (!files) return false;\n\n\t// Check for pnpm workspace\n\tif (files.includes(\"pnpm-workspace.yaml\")) {\n\t\treturn true;\n\t}\n\n\t// Check for yarn/npm workspaces in package.json\n\tif (files.includes(\"package.json\")) {\n\t\tconst packageJsonPath = path.join(dir, \"package.json\");\n\t\tconst { data } = await tryCatch(fs.readFile(packageJsonPath, \"utf-8\"));\n\t\tif (data) {\n\t\t\ttry {\n\t\t\t\tconst packageJson = JSON.parse(data);\n\t\t\t\t// Check for workspaces field (npm/yarn workspaces)\n\t\t\t\t// Workspaces can be an array or an object\n\t\t\t\tif (\n\t\t\t\t\tpackageJson.workspaces &&\n\t\t\t\t\t(Array.isArray(packageJson.workspaces) ||\n\t\t\t\t\t\ttypeof packageJson.workspaces === \"object\")\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore JSON parse errors\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check for other monorepo indicators\n\tconst monorepoIndicators = [\n\t\t\"lerna.json\", // Lerna\n\t\t/* cSpell:disable */\n\t\t\"turbo.json\", // Turborepo\n\t\t\"nx.json\", // Nx\n\t\t\"rush.json\", // Rush\n\t];\n\n\treturn monorepoIndicators.some((indicator) => files.includes(indicator));\n}\n\n/**\n * Finds the monorepo root by walking up the directory tree.\n *\n * @param startDir Starting directory\n * @returns Path to monorepo root, or null if not found\n */\nexport async function findMonorepoRoot(\n\tstartDir: string,\n): Promise<string | null> {\n\tlet currentDir = path.resolve(startDir);\n\tconst root = path.parse(currentDir).root;\n\n\twhile (currentDir !== root) {\n\t\tif (await isMonorepoRoot(currentDir)) {\n\t\t\treturn currentDir;\n\t\t}\n\t\tconst parentDir = path.dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\tbreak;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n\n\treturn null;\n}\n","import { existsSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { capitalizeFirstLetter } from \"@better-auth/core/utils/string\";\nimport { produceSchema } from \"@mrleebo/prisma-ast\";\nimport { initGetFieldName, initGetModelName } from \"better-auth/adapters\";\nimport type { DBFieldType } from \"better-auth/db\";\nimport { getAuthTables } from \"better-auth/db\";\nimport { getPrismaVersion } from \"../utils/get-package-info\";\nimport type { SchemaGenerator } from \"./types\";\n\nexport const generatePrismaSchema: SchemaGenerator = async ({\n\tadapter,\n\toptions,\n\tfile,\n}) => {\n\tconst provider: \"sqlite\" | \"postgresql\" | \"mysql\" | \"mongodb\" =\n\t\tadapter.options?.provider || \"postgresql\";\n\tconst tables = getAuthTables(options);\n\tconst filePath = file || \"./prisma/schema.prisma\";\n\tconst schemaPrismaExist = existsSync(path.join(process.cwd(), filePath));\n\n\tconst getModelName = initGetModelName({\n\t\tschema: getAuthTables(options),\n\t\tusePlural: adapter.options?.adapterConfig?.usePlural,\n\t});\n\tconst getFieldName = initGetFieldName({\n\t\tschema: getAuthTables(options),\n\t\tusePlural: false,\n\t});\n\n\tlet schemaPrisma = \"\";\n\tif (schemaPrismaExist) {\n\t\tschemaPrisma = await fs.readFile(\n\t\t\tpath.join(process.cwd(), filePath),\n\t\t\t\"utf-8\",\n\t\t);\n\t} else {\n\t\tschemaPrisma = getNewPrisma(provider, process.cwd());\n\t}\n\n\t// Update generator and datasource blocks for Prisma v7+ in existing schemas\n\tconst prismaVersion = getPrismaVersion(process.cwd());\n\tif (prismaVersion && prismaVersion >= 7 && schemaPrismaExist) {\n\t\tschemaPrisma = produceSchema(schemaPrisma, (builder) => {\n\t\t\tconst generator: any = builder.findByType(\"generator\", {\n\t\t\t\tname: \"client\",\n\t\t\t});\n\t\t\tif (generator && generator.properties) {\n\t\t\t\tconst providerProp = generator.properties.find(\n\t\t\t\t\t(prop: any) => prop.type === \"assignment\" && prop.key === \"provider\",\n\t\t\t\t);\n\t\t\t\tif (providerProp && providerProp.value === '\"prisma-client-js\"') {\n\t\t\t\t\tproviderProp.value = '\"prisma-client\"';\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Remove url from datasource block (now configured in prisma.config.ts)\n\t\t\tconst datasource: any = builder.findByType(\"datasource\", {\n\t\t\t\tname: \"db\",\n\t\t\t});\n\t\t\tif (datasource && datasource.properties) {\n\t\t\t\tconst urlIndex = datasource.properties.findIndex(\n\t\t\t\t\t(prop: any) => prop.type === \"assignment\" && prop.key === \"url\",\n\t\t\t\t);\n\t\t\t\tif (urlIndex !== -1) {\n\t\t\t\t\tdatasource.properties.splice(urlIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tconst manyToManyRelations = new Map();\n\n\tfor (const table in tables) {\n\t\tconst fields = tables[table]?.fields;\n\t\tfor (const field in fields) {\n\t\t\tconst attr = fields[field]!;\n\t\t\tif (attr.references) {\n\t\t\t\tconst referencedOriginalModel = attr.references.model;\n\t\t\t\tconst referencedCustomModel =\n\t\t\t\t\ttables[referencedOriginalModel]?.modelName || referencedOriginalModel;\n\t\t\t\tconst referencedModelNameCap = capitalizeFirstLetter(\n\t\t\t\t\tgetModelName(referencedCustomModel),\n\t\t\t\t);\n\n\t\t\t\tif (!manyToManyRelations.has(referencedModelNameCap)) {\n\t\t\t\t\tmanyToManyRelations.set(referencedModelNameCap, new Set());\n\t\t\t\t}\n\n\t\t\t\tconst currentCustomModel = tables[table]?.modelName || table;\n\t\t\t\tconst currentModelNameCap = capitalizeFirstLetter(\n\t\t\t\t\tgetModelName(currentCustomModel),\n\t\t\t\t);\n\n\t\t\t\tmanyToManyRelations\n\t\t\t\t\t.get(referencedModelNameCap)\n\t\t\t\t\t.add(currentModelNameCap);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst indexedFields = new Map<string, string[]>();\n\tfor (const table in tables) {\n\t\tconst fields = tables[table]?.fields;\n\t\tconst customModelName = tables[table]?.modelName || table;\n\t\tconst modelName = capitalizeFirstLetter(getModelName(customModelName));\n\t\tindexedFields.set(modelName, []);\n\n\t\tfor (const field in fields) {\n\t\t\tconst attr = fields[field]!;\n\t\t\tif (attr.index && !attr.unique) {\n\t\t\t\tconst fieldName = attr.fieldName || field;\n\t\t\t\tindexedFields.get(modelName)!.push(fieldName);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst schema = produceSchema(schemaPrisma, (builder) => {\n\t\tfor (const table in tables) {\n\t\t\tconst originalTableName = table;\n\t\t\tconst customModelName = tables[table]?.modelName || table;\n\t\t\tconst modelName = capitalizeFirstLetter(getModelName(customModelName));\n\t\t\tconst fields = tables[table]?.fields;\n\t\t\tfunction getType({\n\t\t\t\tisBigint,\n\t\t\t\tisOptional,\n\t\t\t\ttype,\n\t\t\t}: {\n\t\t\t\ttype: DBFieldType;\n\t\t\t\tisOptional: boolean;\n\t\t\t\tisBigint: boolean;\n\t\t\t}) {\n\t\t\t\tif (type === \"string\") {\n\t\t\t\t\treturn isOptional ? \"String?\" : \"String\";\n\t\t\t\t}\n\t\t\t\tif (type === \"number\" && isBigint) {\n\t\t\t\t\treturn isOptional ? \"BigInt?\" : \"BigInt\";\n\t\t\t\t}\n\t\t\t\tif (type === \"number\") {\n\t\t\t\t\treturn isOptional ? \"Int?\" : \"Int\";\n\t\t\t\t}\n\t\t\t\tif (type === \"boolean\") {\n\t\t\t\t\treturn isOptional ? \"Boolean?\" : \"Boolean\";\n\t\t\t\t}\n\t\t\t\tif (type === \"date\") {\n\t\t\t\t\treturn isOptional ? \"DateTime?\" : \"DateTime\";\n\t\t\t\t}\n\t\t\t\tif (type === \"json\") {\n\t\t\t\t\tif (provider === \"sqlite\" || provider === \"mysql\") {\n\t\t\t\t\t\treturn isOptional ? \"String?\" : \"String\";\n\t\t\t\t\t}\n\t\t\t\t\treturn isOptional ? \"Json?\" : \"Json\";\n\t\t\t\t}\n\t\t\t\tif (type === \"string[]\") {\n\t\t\t\t\t// SQLite and MySQL don't support array of strings, so we use string instead\n\t\t\t\t\t// adapter should handle JSON.stringify and JSON.parse conversion for these fields\n\t\t\t\t\tif (provider === \"sqlite\" || provider === \"mysql\") {\n\t\t\t\t\t\treturn isOptional ? \"String?\" : \"String\";\n\t\t\t\t\t}\n\t\t\t\t\treturn \"String[]\";\n\t\t\t\t}\n\t\t\t\tif (type === \"number[]\") {\n\t\t\t\t\t// SQLite and MySQL don't support array of numbers, so we use int instead\n\t\t\t\t\t// adapter should handle JSON.stringify and JSON.parse conversion for these fields\n\t\t\t\t\tif (provider === \"sqlite\" || provider === \"mysql\") {\n\t\t\t\t\t\treturn \"String\";\n\t\t\t\t\t}\n\t\t\t\t\treturn \"Int[]\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst prismaModel = builder.findByType(\"model\", {\n\t\t\t\tname: modelName,\n\t\t\t});\n\n\t\t\tif (!prismaModel) {\n\t\t\t\tif (provider === \"mongodb\") {\n\t\t\t\t\t// Mongo DB doesn't support auto increment, so just use their normal _id.\n\t\t\t\t\tbuilder\n\t\t\t\t\t\t.model(modelName)\n\t\t\t\t\t\t.field(\"id\", \"String\")\n\t\t\t\t\t\t.attribute(\"id\")\n\t\t\t\t\t\t.attribute(`map(\"_id\")`);\n\t\t\t\t} else {\n\t\t\t\t\tconst useNumberId =\n\t\t\t\t\t\toptions.advanced?.database?.generateId === \"serial\";\n\t\t\t\t\tconst useUUIDs = options.advanced?.database?.generateId === \"uuid\";\n\t\t\t\t\tif (useNumberId) {\n\t\t\t\t\t\tbuilder\n\t\t\t\t\t\t\t.model(modelName)\n\t\t\t\t\t\t\t.field(\"id\", \"Int\")\n\t\t\t\t\t\t\t.attribute(\"id\")\n\t\t\t\t\t\t\t.attribute(\"default(autoincrement())\");\n\t\t\t\t\t} else if (useUUIDs && provider === \"postgresql\") {\n\t\t\t\t\t\tbuilder\n\t\t\t\t\t\t\t.model(modelName)\n\t\t\t\t\t\t\t.field(\"id\", \"String\")\n\t\t\t\t\t\t\t.attribute(\"id\")\n\t\t\t\t\t\t\t.attribute('default(dbgenerated(\"pg_catalog.gen_random_uuid()\"))')\n\t\t\t\t\t\t\t.attribute(\"db.Uuid\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbuilder.model(modelName).field(\"id\", \"String\").attribute(\"id\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const field in fields) {\n\t\t\t\tconst attr = fields[field]!;\n\t\t\t\tconst fieldName = attr.fieldName || field;\n\n\t\t\t\tif (prismaModel) {\n\t\t\t\t\tconst isAlreadyExist = builder.findByType(\"field\", {\n\t\t\t\t\t\tname: fieldName,\n\t\t\t\t\t\twithin: prismaModel.properties,\n\t\t\t\t\t});\n\t\t\t\t\tif (isAlreadyExist) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst useUUIDs = options.advanced?.database?.generateId === \"uuid\";\n\t\t\t\tconst useNumberId = options.advanced?.database?.generateId === \"serial\";\n\t\t\t\tconst fieldBuilder = builder.model(modelName).field(\n\t\t\t\t\tfieldName,\n\t\t\t\t\tfield === \"id\" && useNumberId\n\t\t\t\t\t\t? getType({\n\t\t\t\t\t\t\t\tisBigint: false,\n\t\t\t\t\t\t\t\tisOptional: false,\n\t\t\t\t\t\t\t\ttype: \"number\",\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: getType({\n\t\t\t\t\t\t\t\tisBigint: attr?.bigint || false,\n\t\t\t\t\t\t\t\tisOptional: attr?.required === false,\n\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\tattr.references?.field === \"id\"\n\t\t\t\t\t\t\t\t\t\t? useNumberId\n\t\t\t\t\t\t\t\t\t\t\t? \"number\"\n\t\t\t\t\t\t\t\t\t\t\t: \"string\"\n\t\t\t\t\t\t\t\t\t\t: attr.type,\n\t\t\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tif (field === \"id\") {\n\t\t\t\t\tfieldBuilder.attribute(\"id\");\n\t\t\t\t\tif (provider === \"mongodb\") {\n\t\t\t\t\t\tfieldBuilder.attribute(`map(\"_id\")`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (attr.unique) {\n\t\t\t\t\tbuilder.model(modelName).blockAttribute(`unique([${fieldName}])`);\n\t\t\t\t}\n\n\t\t\t\tif (attr.defaultValue !== undefined) {\n\t\t\t\t\tif (Array.isArray(attr.defaultValue)) {\n\t\t\t\t\t\t// for json objects and array of object\n\n\t\t\t\t\t\tif (attr.type === \"json\") {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tObject.prototype.toString.call(attr.defaultValue[0]) ===\n\t\t\t\t\t\t\t\t\"[object Object]\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tfieldBuilder.attribute(\n\t\t\t\t\t\t\t\t\t`default(\"${JSON.stringify(attr.defaultValue).replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')}\")`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst jsonArray = [];\n\t\t\t\t\t\t\tfor (const value of attr.defaultValue) jsonArray.push(value);\n\t\t\t\t\t\t\tfieldBuilder.attribute(\n\t\t\t\t\t\t\t\t`default(\"${JSON.stringify(jsonArray).replace(/\"/g, '\\\\\"')}\")`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (attr.defaultValue.length === 0) {\n\t\t\t\t\t\t\tfieldBuilder.attribute(`default([])`);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\ttypeof attr.defaultValue[0] === \"string\" &&\n\t\t\t\t\t\t\tattr.type === \"string[]\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst valueArray = [];\n\t\t\t\t\t\t\tfor (const value of attr.defaultValue)\n\t\t\t\t\t\t\t\tvalueArray.push(JSON.stringify(value));\n\t\t\t\t\t\t\tfieldBuilder.attribute(`default([${valueArray}])`);\n\t\t\t\t\t\t} else if (typeof attr.defaultValue[0] === \"number\") {\n\t\t\t\t\t\t\tconst valueArray = [];\n\t\t\t\t\t\t\tfor (const value of attr.defaultValue)\n\t\t\t\t\t\t\t\tvalueArray.push(`${value}`);\n\t\t\t\t\t\t\tfieldBuilder.attribute(`default([${valueArray}])`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// for json objects\n\t\t\t\t\telse if (\n\t\t\t\t\t\ttypeof attr.defaultValue === \"object\" &&\n\t\t\t\t\t\t!Array.isArray(attr.defaultValue) &&\n\t\t\t\t\t\tattr.defaultValue !== null\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tObject.entries(attr.defaultValue as Record<string, any>)\n\t\t\t\t\t\t\t\t.length === 0\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tfieldBuilder.attribute(`default(\"{}\")`);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfieldBuilder.attribute(\n\t\t\t\t\t\t\t`default(\"${JSON.stringify(attr.defaultValue).replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')}\")`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (field === \"createdAt\") {\n\t\t\t\t\t\tfieldBuilder.attribute(\"default(now())\");\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof attr.defaultValue === \"string\" &&\n\t\t\t\t\t\tprovider !== \"mysql\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tfieldBuilder.attribute(`default(\"${attr.defaultValue}\")`);\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof attr.defaultValue === \"boolean\" ||\n\t\t\t\t\t\ttypeof attr.defaultValue === \"number\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tfieldBuilder.attribute(`default(${attr.defaultValue})`);\n\t\t\t\t\t} else if (typeof attr.defaultValue === \"function\") {\n\t\t\t\t\t\t// we are intentionally not adding the default value here\n\t\t\t\t\t\t// this is because if the defaultValue is a function, it could have\n\t\t\t\t\t\t// custom logic within that function that might not work in prisma's context.\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// This is a special handling for updatedAt fields\n\t\t\t\tif (field === \"updatedAt\" && attr.onUpdate) {\n\t\t\t\t\tfieldBuilder.attribute(\"updatedAt\");\n\t\t\t\t} else if (attr.onUpdate) {\n\t\t\t\t\t// we are intentionally not adding the onUpdate value here\n\t\t\t\t\t// this is because if the onUpdate is a function, it could have\n\t\t\t\t\t// custom logic within that function that might not work in prisma's context.\n\t\t\t\t}\n\n\t\t\t\tif (attr.references) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tuseUUIDs &&\n\t\t\t\t\t\tprovider === \"postgresql\" &&\n\t\t\t\t\t\tattr.references?.field === \"id\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tbuilder.model(modelName).field(fieldName).attribute(`db.Uuid`);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst referencedOriginalModelName = getModelName(\n\t\t\t\t\t\tattr.references.model,\n\t\t\t\t\t);\n\t\t\t\t\tconst referencedCustomModelName =\n\t\t\t\t\t\ttables[referencedOriginalModelName]?.modelName ||\n\t\t\t\t\t\treferencedOriginalModelName;\n\t\t\t\t\tlet action = \"Cascade\";\n\t\t\t\t\tif (attr.references.onDelete === \"no action\") action = \"NoAction\";\n\t\t\t\t\telse if (attr.references.onDelete === \"set null\") action = \"SetNull\";\n\t\t\t\t\telse if (attr.references.onDelete === \"set default\")\n\t\t\t\t\t\taction = \"SetDefault\";\n\t\t\t\t\telse if (attr.references.onDelete === \"restrict\") action = \"Restrict\";\n\n\t\t\t\t\tconst relationField = `relation(fields: [${getFieldName({ model: originalTableName, field: fieldName })}], references: [${getFieldName({ model: attr.references.model, field: attr.references.field })}], onDelete: ${action})`;\n\t\t\t\t\tbuilder\n\t\t\t\t\t\t.model(modelName)\n\t\t\t\t\t\t.field(\n\t\t\t\t\t\t\treferencedCustomModelName.toLowerCase(),\n\t\t\t\t\t\t\t`${capitalizeFirstLetter(referencedCustomModelName)}${\n\t\t\t\t\t\t\t\tattr.required === false ? \"?\" : \"\"\n\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.attribute(relationField);\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!attr.unique &&\n\t\t\t\t\t!attr.references &&\n\t\t\t\t\tprovider === \"mysql\" &&\n\t\t\t\t\tattr.type === \"string\"\n\t\t\t\t) {\n\t\t\t\t\tbuilder.model(modelName).field(fieldName).attribute(\"db.Text\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add many-to-many fields\n\t\t\tif (manyToManyRelations.has(modelName)) {\n\t\t\t\tfor (const relatedModel of manyToManyRelations.get(modelName)) {\n\t\t\t\t\t// Find the FK field on the related model that points to this model\n\t\t\t\t\tconst relatedTableName = Object.keys(tables).find(\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t\tcapitalizeFirstLetter(tables[key]?.modelName || key) ===\n\t\t\t\t\t\t\trelatedModel,\n\t\t\t\t\t);\n\t\t\t\t\tconst relatedFields = relatedTableName\n\t\t\t\t\t\t? tables[relatedTableName]?.fields\n\t\t\t\t\t\t: {};\n\t\t\t\t\tconst fkField = Object.entries(relatedFields || {}).find(\n\t\t\t\t\t\t([_fieldName, fieldAttr]: any) =>\n\t\t\t\t\t\t\tfieldAttr.references &&\n\t\t\t\t\t\t\tgetModelName(fieldAttr.references.model) ===\n\t\t\t\t\t\t\t\tgetModelName(originalTableName),\n\t\t\t\t\t);\n\t\t\t\t\tconst [_fieldKey, fkFieldAttr] = fkField || [];\n\t\t\t\t\tconst isUnique = fkFieldAttr?.unique === true;\n\n\t\t\t\t\tconst fieldName =\n\t\t\t\t\t\tisUnique || adapter.options?.usePlural === true\n\t\t\t\t\t\t\t? `${relatedModel.toLowerCase()}`\n\t\t\t\t\t\t\t: `${relatedModel.toLowerCase()}s`;\n\t\t\t\t\tconst existingField = builder.findByType(\"field\", {\n\t\t\t\t\t\tname: fieldName,\n\t\t\t\t\t\twithin: prismaModel?.properties,\n\t\t\t\t\t});\n\t\t\t\t\tif (!existingField) {\n\t\t\t\t\t\tbuilder\n\t\t\t\t\t\t\t.model(modelName)\n\t\t\t\t\t\t\t.field(fieldName, `${relatedModel}${isUnique ? \"?\" : \"[]\"}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add indexes\n\t\t\tconst indexedFieldsForModel = indexedFields.get(modelName);\n\t\t\tif (indexedFieldsForModel && indexedFieldsForModel.length > 0) {\n\t\t\t\tfor (const fieldName of indexedFieldsForModel) {\n\t\t\t\t\tif (prismaModel) {\n\t\t\t\t\t\tconst indexExist = prismaModel.properties.some(\n\t\t\t\t\t\t\t(v) =>\n\t\t\t\t\t\t\t\tv.type === \"attribute\" &&\n\t\t\t\t\t\t\t\tv.name === \"index\" &&\n\t\t\t\t\t\t\t\tJSON.stringify(v.args[0]?.value).includes(fieldName),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (indexExist) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst field = Object.entries(fields!).find(\n\t\t\t\t\t\t([key, attr]) => (attr.fieldName || key) === fieldName,\n\t\t\t\t\t)?.[1];\n\n\t\t\t\t\tlet indexField = fieldName;\n\t\t\t\t\tif (provider === \"mysql\" && field && field.type === \"string\") {\n\t\t\t\t\t\tconst useNumberId =\n\t\t\t\t\t\t\toptions.advanced?.database?.generateId === \"serial\";\n\t\t\t\t\t\tconst useUUIDs = options.advanced?.database?.generateId === \"uuid\";\n\t\t\t\t\t\tif (field.references?.field === \"id\" && (useNumberId || useUUIDs)) {\n\t\t\t\t\t\t\tindexField = `${fieldName}`;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tindexField = `${fieldName}(length: 191)`; // length of 191 because String in Prisma is varchar(191)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbuilder.model(modelName).blockAttribute(`index([${indexField}])`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst hasAttribute = builder.findByType(\"attribute\", {\n\t\t\t\tname: \"map\",\n\t\t\t\twithin: prismaModel?.properties,\n\t\t\t});\n\t\t\tconst hasChanged = customModelName !== originalTableName;\n\t\t\tif (!hasAttribute) {\n\t\t\t\tbuilder\n\t\t\t\t\t.model(modelName)\n\t\t\t\t\t.blockAttribute(\n\t\t\t\t\t\t\"map\",\n\t\t\t\t\t\t`${getModelName(hasChanged ? customModelName : originalTableName)}`,\n\t\t\t\t\t);\n\t\t\t}\n\t\t}\n\t});\n\n\tconst schemaChanged = schema.trim() !== schemaPrisma.trim();\n\n\treturn {\n\t\tcode: schemaChanged ? schema : \"\",\n\t\tfileName: filePath,\n\t\toverwrite: schemaPrismaExist && schemaChanged,\n\t};\n};\n\nconst getNewPrisma = (provider: string, cwd?: string) => {\n\tconst prismaVersion = getPrismaVersion(cwd);\n\tconst isV7 = prismaVersion && prismaVersion >= 7;\n\t// Use \"prisma-client\" for Prisma v7+, otherwise use \"prisma-client-js\"\n\tconst clientProvider = isV7 ? \"prisma-client\" : \"prisma-client-js\";\n\n\t// In Prisma v7+, the url is configured in prisma.config.ts instead of the schema\n\tif (isV7) {\n\t\treturn `generator client {\n provider = \"${clientProvider}\"\n }\n\n datasource db {\n provider = \"${provider}\"\n }`;\n\t}\n\n\treturn `generator client {\n provider = \"${clientProvider}\"\n }\n\n datasource db {\n provider = \"${provider}\"\n url = ${\n\t\t\tprovider === \"sqlite\" ? `\"file:./dev.db\"` : `env(\"DATABASE_URL\")`\n\t\t}\n }`;\n};\n","import type { BetterAuthOptions } from \"@better-auth/core\";\nimport type { DBAdapter } from \"@better-auth/core/db/adapter\";\nimport { generateDrizzleSchema } from \"./drizzle\";\nimport { generateKyselySchema } from \"./kysely\";\nimport { generatePrismaSchema } from \"./prisma\";\n\nexport const adapters = {\n\tprisma: generatePrismaSchema,\n\tdrizzle: generateDrizzleSchema,\n\tkysely: generateKyselySchema,\n};\n\nexport const generateSchema = (opts: {\n\tadapter: DBAdapter;\n\tfile?: string;\n\toptions: BetterAuthOptions;\n}) => {\n\tconst adapter = opts.adapter;\n\tconst generator =\n\t\tadapter.id in adapters\n\t\t\t? adapters[adapter.id as keyof typeof adapters]\n\t\t\t: null;\n\tif (generator) {\n\t\t// generator from the built-in list above\n\t\treturn generator(opts);\n\t}\n\tif (adapter.createSchema) {\n\t\t// use the custom adapter's createSchema method\n\t\treturn adapter\n\t\t\t.createSchema(opts.options, opts.file)\n\t\t\t.then(({ code, path: fileName, overwrite }) => ({\n\t\t\t\tcode,\n\t\t\t\tfileName,\n\t\t\t\toverwrite,\n\t\t\t}));\n\t}\n\n\tthrow new Error(\n\t\t`${adapter.id} is not supported. If it is a custom adapter, please request the maintainer to implement createSchema`,\n\t);\n};\n"],"mappings":";;;;;;;;;;AAQA,SAAS,mBAAmB,KAAa,WAAqB;AAC7D,KAAI,UACH,QAAO;AAGR,QAAO,IACL,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,qBAAqB,QAAQ,CACrC,aAAa;;AAGhB,MAAa,wBAAyC,OAAO,EAC5D,SACA,MACA,cACK;CACL,MAAM,SAAS,cAAc,QAAQ;CACrC,MAAM,WAAW,QAAQ;CACzB,MAAM,eACL,QAAQ,SAAS;AAElB,KAAI,CAAC,aACJ,OAAM,IAAI,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