[GH-ISSUE #4796] defaultNow is generated in schema for Drizzle with SQLite #27396

Closed
opened 2026-04-17 18:24:05 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @dninomiya on GitHub (Sep 21, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4796

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

In Drizzle x SQLite, defaultNow is marked as deprecated. However, even when SQLite is selected, running the generate command from Better Auth still produces a schema that includes defaultNow.

https://orm.drizzle.team/docs/guides/timestamp-default-value?utm_source=chatgpt.com#sqlite

export const users = sqliteTable("users", {
  id: text("id").primaryKey(),
  name: text("name").notNull(),
  email: text("email").notNull().unique(),
  emailVerified: integer("email_verified", { mode: "boolean" })
    .default(false)
    .notNull(),
  image: text("image"),
  createdAt: integer("created_at", { mode: "timestamp" })
    .defaultNow() <- editor warning
    .notNull(),
  updatedAt: integer("updated_at", { mode: "timestamp" })
    .defaultNow() <- editor warning
    .$onUpdate(() => /* @__PURE__ */ new Date())
    .notNull(),
});

Current vs. Expected behavior

Image

What version of Better Auth are you using?

1.3.13

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.0.0: Mon Aug 25 21:17:45 PDT 2025; root:xnu-12377.1.9~3/RELEASE_ARM64_T8103",
    "release": "25.0.0",
    "cpuCount": 8,
    "cpuModel": "Apple M1",
    "totalMemory": "16.00 GB",
    "freeMemory": "0.09 GB"
  },
  "node": {
    "version": "v22.19.0",
    "env": "development"
  },
  "packageManager": {
    "name": "pnpm",
    "version": "10.14.0"
  },
  "frameworks": [
    {
      "name": "next",
      "version": "15.5.0"
    },
    {
      "name": "react",
      "version": "19.1.0"
    }
  ],
  "databases": [
    {
      "name": "@libsql/client",
      "version": "^0.15.15"
    },
    {
      "name": "drizzle",
      "version": "^0.44.5"
    }
  ],
  "betterAuth": {
    "version": "^1.3.13",
    "config": {
      "baseURL": "http://localhost:3000",
      "advanced": {
        "database": {}
      },
      "plugins": [
        {
          "name": "next-cookies",
          "config": {
            "id": "next-cookies",
            "hooks": {
              "after": [
                {}
              ]
            }
          }
        }
      ]
    }
  }
}

Which area(s) are affected? (Select all that apply)

Package

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @dninomiya on GitHub (Sep 21, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4796 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce In Drizzle x SQLite, defaultNow is marked as deprecated. However, even when SQLite is selected, running the generate command from Better Auth still produces a schema that includes defaultNow. https://orm.drizzle.team/docs/guides/timestamp-default-value?utm_source=chatgpt.com#sqlite ```ts export const users = sqliteTable("users", { id: text("id").primaryKey(), name: text("name").notNull(), email: text("email").notNull().unique(), emailVerified: integer("email_verified", { mode: "boolean" }) .default(false) .notNull(), image: text("image"), createdAt: integer("created_at", { mode: "timestamp" }) .defaultNow() <- editor warning .notNull(), updatedAt: integer("updated_at", { mode: "timestamp" }) .defaultNow() <- editor warning .$onUpdate(() => /* @__PURE__ */ new Date()) .notNull(), }); ``` ### Current vs. Expected behavior <img width="438" height="309" alt="Image" src="https://github.com/user-attachments/assets/e104282d-f19f-4298-98bd-64644d43937f" /> ### What version of Better Auth are you using? 1.3.13 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.0.0: Mon Aug 25 21:17:45 PDT 2025; root:xnu-12377.1.9~3/RELEASE_ARM64_T8103", "release": "25.0.0", "cpuCount": 8, "cpuModel": "Apple M1", "totalMemory": "16.00 GB", "freeMemory": "0.09 GB" }, "node": { "version": "v22.19.0", "env": "development" }, "packageManager": { "name": "pnpm", "version": "10.14.0" }, "frameworks": [ { "name": "next", "version": "15.5.0" }, { "name": "react", "version": "19.1.0" } ], "databases": [ { "name": "@libsql/client", "version": "^0.15.15" }, { "name": "drizzle", "version": "^0.44.5" } ], "betterAuth": { "version": "^1.3.13", "config": { "baseURL": "http://localhost:3000", "advanced": { "database": {} }, "plugins": [ { "name": "next-cookies", "config": { "id": "next-cookies", "hooks": { "after": [ {} ] } } } ] } } } ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 18:24:05 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 21, 2025):

This is a known issue: Better Auth's schema generator currently uses .defaultNow() for timestamp fields in Drizzle schemas for all databases, including SQLite, even though Drizzle marks .defaultNow() as deprecated for SQLite. There is no conditional logic in the generator to avoid this, so you get deprecation warnings in editors and code (source, source).

The maintainers are aware and have discussed improvements, but as of v1.3.13, there is no built-in workaround or config option to change this behavior (source, source).

The recommended workaround is to manually edit the generated schema and replace .defaultNow() with .$defaultFn(() => new Date()) for SQLite timestamp fields, as suggested in the Drizzle docs and confirmed by community threads (source).

Keep an eye on release notes and GitHub issues for updates on a fix. If you need help with manual schema edits or migration strategies, let me know!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3315639757 --> @dosubot[bot] commented on GitHub (Sep 21, 2025): <!-- Answer --> This is a known issue: Better Auth's schema generator currently uses `.defaultNow()` for timestamp fields in Drizzle schemas for all databases, including SQLite, even though Drizzle marks `.defaultNow()` as deprecated for SQLite. There is no conditional logic in the generator to avoid this, so you get deprecation warnings in editors and code ([source](https://github.com/better-auth/better-auth/pull/3873), [source](https://github.com/better-auth/better-auth/issues/4434)). The maintainers are aware and have discussed improvements, but as of v1.3.13, there is no built-in workaround or config option to change this behavior ([source](https://github.com/better-auth/better-auth/issues/2786), [source](https://github.com/better-auth/better-auth/issues/2739)). The recommended workaround is to manually edit the generated schema and replace `.defaultNow()` with `.$defaultFn(() => new Date())` for SQLite timestamp fields, as suggested in the Drizzle docs and confirmed by community threads ([source](https://github.com/better-auth/better-auth/issues/4434)). Keep an eye on release notes and GitHub issues for updates on a fix. If you need help with manual schema edits or migration strategies, let me know! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/bef3019d-7c64-43a8-b5fb-a746333f9703?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/bef3019d-7c64-43a8-b5fb-a746333f9703?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/bef3019d-7c64-43a8-b5fb-a746333f9703?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/bef3019d-7c64-43a8-b5fb-a746333f9703?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bef3019d-7c64-43a8-b5fb-a746333f9703?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/bef3019d-7c64-43a8-b5fb-a746333f9703?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bef3019d-7c64-43a8-b5fb-a746333f9703?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4796)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27396