Skip to content

Commit

Permalink
chore: update drizzle-kit
Browse files Browse the repository at this point in the history
  • Loading branch information
ikxin committed May 24, 2024
1 parent 1660d81 commit c83e52a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
.DS_Store
node_modules
dist
dev.db*
migrations
sqlite.db
Binary file modified bun.lockb
Binary file not shown.
14 changes: 7 additions & 7 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Config } from "drizzle-kit";
import { defineConfig } from 'drizzle-kit'

export default {
out: "./service/db/migrations",
schema: "./service/db/schema.ts",
driver: "better-sqlite",
export default defineConfig({
dialect: 'sqlite',
out: './service/migrations',
schema: './service/schema.ts',
dbCredentials: {
url: "sqlite.db",
url: 'sqlite.db',
},
} satisfies Config;
})
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
"author": "一纸忘忧 <i@ikxin.com>",
"type": "module",
"scripts": {
"web-dev": "bun --watch service",
"build": "vite build",
"dev": "vite",
"service": "bun --watch service/index.ts",
"generate": "prisma generate",
"service": "bun --watch service",
"tsc": "vue-tsc",
"init-prisma": "prisma init --datasource-provider sqlite",
"migrate": "prisma migrate dev --name init",
"kill-vlmcsd": "pkill -f vlmcsd",
"db-studio": "drizzle-kit studio",
"init-db": "drizzle-kit generate:sqlite && bun service/scripts/migrate.ts"
"db:init": "drizzle-kit generate --name init_db",
"db:migrate": "drizzle-kit migrate",
"db:studio": "drizzle-kit studio --verbose",
"db:clear": "rm -rf service/migrations sqlite.db",
"kill-vlmcsd": "pkill -f vlmcsd"
},
"dependencies": {
"@arco-design/web-vue": "^2.55.1",
Expand All @@ -42,7 +40,7 @@
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@vitejs/plugin-vue": "^5.0.4",
"drizzle-kit": "^0.20.18",
"drizzle-kit": "^0.21.4",
"drizzle-orm": "^0.30.10",
"eslint": "^9.2.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
4 changes: 2 additions & 2 deletions service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { arch, platform } from 'os'
import { $ } from 'bun'
import { drizzle } from 'drizzle-orm/bun-sqlite'
import { Database } from 'bun:sqlite'
import * as schema from './db/schema'
import * as schema from './schema'

const sqlite = new Database('sqlite.db')
const db = drizzle(sqlite, { schema })
Expand All @@ -21,7 +21,7 @@ app.use(
app.get('/*', () => Bun.file('dist/index.html'))

app.get('/api/record', async () => {
return await db.query.record.findMany()
return await db.query.logs.findMany()
})

app.listen(3000)
Expand Down
3 changes: 1 addition & 2 deletions service/db/schema.ts → service/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";

export const record = sqliteTable("record", {
export const logs = sqliteTable("logs", {
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
name: text("name").notNull(),
createdAt: integer("created_at").notNull(),
});

0 comments on commit c83e52a

Please sign in to comment.