@better-auth/cli 1.4.0-beta.5 → 1.4.0-beta.6

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.
Files changed (2) hide show
  1. package/dist/index.mjs +9 -13
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -2277,9 +2277,9 @@ const generateDrizzleSchema = async ({
2277
2277
  mysql: field.bigint ? `bigint('${name}', { mode: 'number' })` : `int('${name}')`
2278
2278
  },
2279
2279
  date: {
2280
- sqlite: `integer('${name}', { mode: 'timestamp' })`,
2280
+ sqlite: `integer('${name}', { mode: 'timestamp_ms' })`,
2281
2281
  pg: `timestamp('${name}')`,
2282
- mysql: `timestamp('${name}')`
2282
+ mysql: `timestamp('${name}', { fsp: 3 })`
2283
2283
  },
2284
2284
  "number[]": {
2285
2285
  sqlite: `integer('${name}').array()`,
@@ -2307,7 +2307,7 @@ const generateDrizzleSchema = async ({
2307
2307
  if (databaseType === "pg") {
2308
2308
  id = `serial("id").primaryKey()`;
2309
2309
  } else if (databaseType === "sqlite") {
2310
- id = `int("id").primaryKey()`;
2310
+ id = `integer("id", { mode: "number" }).primaryKey({ autoIncrement: true })`;
2311
2311
  } else {
2312
2312
  id = `int("id").autoincrement().primaryKey()`;
2313
2313
  }
@@ -2327,12 +2327,13 @@ const generateDrizzleSchema = async ({
2327
2327
  id: ${id},
2328
2328
  ${Object.keys(fields).map((field) => {
2329
2329
  const attr = fields[field];
2330
- let type = getType(field, attr);
2330
+ const fieldName = attr.fieldName || field;
2331
+ let type = getType(fieldName, attr);
2331
2332
  if (attr.defaultValue !== null && typeof attr.defaultValue !== "undefined") {
2332
2333
  if (typeof attr.defaultValue === "function") {
2333
2334
  if (attr.type === "date" && attr.defaultValue.toString().includes("new Date()")) {
2334
2335
  if (databaseType === "sqlite") {
2335
- type += `.default(sql\`(current_timestamp)\`)`;
2336
+ type += `.default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`)`;
2336
2337
  } else {
2337
2338
  type += `.defaultNow()`;
2338
2339
  }
@@ -2350,10 +2351,10 @@ const generateDrizzleSchema = async ({
2350
2351
  type += `.$onUpdate(${attr.onUpdate})`;
2351
2352
  }
2352
2353
  }
2353
- return `${field}: ${type}${attr.required ? ".notNull()" : ""}${attr.unique ? ".unique()" : ""}${attr.references ? `.references(()=> ${getModelName(
2354
+ return `${fieldName}: ${type}${attr.required ? ".notNull()" : ""}${attr.unique ? ".unique()" : ""}${attr.references ? `.references(()=> ${getModelName(
2354
2355
  tables[attr.references.model]?.modelName || attr.references.model,
2355
2356
  adapter.options
2356
- )}.${attr.references.field}, { onDelete: '${attr.references.onDelete || "cascade"}' })` : ""}`;
2357
+ )}.${fields[attr.references.field]?.fieldName || attr.references.field}, { onDelete: '${attr.references.onDelete || "cascade"}' })` : ""}`;
2357
2358
  }).join(",\n ")}
2358
2359
  });`;
2359
2360
  code += `
@@ -2525,10 +2526,7 @@ const generatePrismaSchema = async ({
2525
2526
  builder.model(modelName).field("id", "String").attribute("id").attribute(`map("_id")`);
2526
2527
  } else {
2527
2528
  if (options.advanced?.database?.useNumberId) {
2528
- const col = builder.model(modelName).field("id", "Int").attribute("id");
2529
- if (provider !== "sqlite") {
2530
- col.attribute("default(autoincrement())");
2531
- }
2529
+ builder.model(modelName).field("id", "Int").attribute("id").attribute("default(autoincrement())");
2532
2530
  } else {
2533
2531
  builder.model(modelName).field("id", "String").attribute("id");
2534
2532
  }
@@ -2563,8 +2561,6 @@ const generatePrismaSchema = async ({
2563
2561
  if (provider === "mongodb") {
2564
2562
  fieldBuilder.attribute(`map("_id")`);
2565
2563
  }
2566
- } else if (fieldName !== field) {
2567
- fieldBuilder.attribute(`map("${field}")`);
2568
2564
  }
2569
2565
  if (attr.unique) {
2570
2566
  builder.model(modelName).blockAttribute(`unique([${fieldName}])`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/cli",
3
- "version": "1.4.0-beta.5",
3
+ "version": "1.4.0-beta.6",
4
4
  "description": "The CLI for Better Auth",
5
5
  "module": "dist/index.mjs",
6
6
  "repository": {
@@ -56,7 +56,7 @@
56
56
  "tinyexec": "^0.3.2",
57
57
  "yocto-spinner": "^0.2.3",
58
58
  "zod": "^4.1.5",
59
- "better-auth": "1.4.0-beta.5"
59
+ "better-auth": "1.4.0-beta.6"
60
60
  },
61
61
  "files": [
62
62
  "dist"