Skip to content

Commit

Permalink
chore: upgrade drizzle to v0.35
Browse files Browse the repository at this point in the history
  • Loading branch information
w3cj committed Oct 24, 2024
1 parent 35a592d commit 92525ff
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 30 deletions.
4 changes: 2 additions & 2 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import env from "@/env";
export default defineConfig({
schema: "./src/db/schema.ts",
out: "./src/db/migrations",
dialect: "sqlite",
driver: "turso",
dialect: "turso",
casing: "snake_case",
dbCredentials: {
url: env.DATABASE_URL,
authToken: env.DATABASE_AUTH_TOKEN,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@scalar/hono-api-reference": "^0.5.156",
"dotenv": "^16.4.5",
"dotenv-expand": "^11.0.6",
"drizzle-orm": "^0.33.0",
"drizzle-orm": "^0.35.3",
"drizzle-zod": "^0.5.1",
"hono": "^4.6.6",
"hono-pino": "^0.4.0",
Expand All @@ -32,7 +32,7 @@
"@antfu/eslint-config": "^3.8.0",
"@types/node": "^22.7.9",
"cross-env": "^7.0.3",
"drizzle-kit": "^0.24.2",
"drizzle-kit": "^0.26.2",
"eslint": "^9.13.0",
"eslint-plugin-format": "^0.1.2",
"tsc-alias": "^1.8.10",
Expand Down
42 changes: 28 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions src/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { createClient } from "@libsql/client";
import { drizzle } from "drizzle-orm/libsql";

import env from "@/env";

import * as schema from "./schema";

const client = createClient({
url: env.DATABASE_URL,
authToken: env.DATABASE_AUTH_TOKEN,
});

const db = drizzle(client, {
const db = drizzle({
connection: {
url: env.DATABASE_URL,
authToken: env.DATABASE_AUTH_TOKEN,
},
casing: "snake_case",
schema,
});

Expand Down
10 changes: 5 additions & 5 deletions src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";

export const tasks = sqliteTable("tasks", {
id: integer("id", { mode: "number" })
id: integer({ mode: "number" })
.primaryKey({ autoIncrement: true }),
name: text("name")
name: text()
.notNull(),
done: integer("done", { mode: "boolean" })
done: integer({ mode: "boolean" })
.notNull()
.default(false),
createdAt: integer("created_at", { mode: "timestamp" })
createdAt: integer({ mode: "timestamp" })
.$defaultFn(() => new Date()),
updatedAt: integer("updated_at", { mode: "timestamp" })
updatedAt: integer({ mode: "timestamp" })
.$defaultFn(() => new Date())
.$onUpdate(() => new Date()),
});
Expand Down

0 comments on commit 92525ff

Please sign in to comment.