Skip to content

Commit e874d55

Browse files
committed
use turso
1 parent 095b965 commit e874d55

9 files changed

Lines changed: 151 additions & 72 deletions

File tree

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ A Next.js application for tracking student and client hours using Toggl Track in
2121
Create a `.env` file with:
2222

2323
```bash
24-
TOGGL_API_EMAIL=your-email@example.com
25-
TOGGL_API_PASSWORD=your-password
26-
# DATABASE_URL=file:sqlite.db
24+
cp .env.example .env.local
2725
```
2826

2927
### Installation

drizzle.config.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import { defineConfig } from "drizzle-kit";
22

33
export default defineConfig({
4-
dialect: "sqlite",
5-
// dialect: "turso",
6-
schema: "./lib/db/schema.ts",
4+
dialect: "turso",
5+
schema: "./src/app/lib/db/schema.ts",
76
dbCredentials: {
87
// url: ":memory:", // inmemory database
98
// or
109
// url: "sqlite.db",
1110
// or
12-
url: "file:sqlite.db", // file: prefix is required by libsql
13-
// url: process.env.TURSO_CONNECTION_URL!,
14-
// authToken: process.env.TURSO_AUTH_TOKEN!,
11+
// url: "file:sqlite.db", // file: prefix is required by libsql
12+
url: process.env.TURSO_DATABASE_URL!,
13+
authToken: process.env.TURSO_AUTH_TOKEN!,
1514
},
1615
});

package-lock.json

Lines changed: 126 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint",
10-
"seed": "tsx scripts/seed.ts",
10+
"seed": "dotenvx run -f .env.local -- tsx scripts/seed.ts",
1111
"generate": "npx drizzle-kit generate:sqlite --out ./drizzle/migrations --breakpoints --schema=./drizzle/schema.ts",
1212
"migrate": "tsx drizzle/migrate",
13+
"migrate:push": "dotenvx run -f .env.local -- drizzle-kit push",
1314
"test": "vitest",
1415
"build:worker": "opennextjs-cloudflare",
1516
"check": "npm run build:worker && tsc && wrangler deploy --dry-run",
@@ -19,7 +20,8 @@
1920
},
2021
"dependencies": {
2122
"@cloudflare/workers-types": "^4.20250317.0",
22-
"@libsql/client": "^0.10.0",
23+
"@dotenvx/dotenvx": "^1.39.0",
24+
"@libsql/client": "^0.15.0",
2325
"@next/swc-wasm-nodejs": "13.5.1",
2426
"@opennextjs/cloudflare": "^0.5.12",
2527
"@types/node": "20.6.2",

scripts/seed.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createClient } from "@libsql/client";
22
import { drizzle } from "drizzle-orm/libsql";
33
// import { sq } from 'drizzle-orm/better-sqlite3';
44
// import { db } from "@/lib/db";
5-
import { NewClient, clients } from "@/lib/db/schema";
5+
import { type NewClient, clients } from "@/lib/db/schema";
66

77
async function seed() {
88
try {
@@ -17,9 +17,9 @@ async function seed() {
1717
// `);
1818

1919
const client = createClient({
20-
url: "file:sqlite.db",
21-
// url: process.env.TURSO_DATABASE_URL!,
22-
// authToken: process.env.TURSO_AUTH_TOKEN!,
20+
// url: "file:sqlite.db",
21+
url: process.env.TURSO_DATABASE_URL!,
22+
authToken: process.env.TURSO_AUTH_TOKEN!,
2323
});
2424

2525
const db = drizzle(client);
@@ -31,7 +31,7 @@ async function seed() {
3131
// TODO - create shortui() - e.g. https://github.com/simplyhexagonal/short-unique-id
3232
togglTag: "daniel",
3333
totalHoursPaid: 40,
34-
lastPaidDate: new Date("2024-01-31").toISOString(),
34+
lastPaidDate: new Date("2025-01-01").toISOString(),
3535
} as NewClient);
3636

3737
console.log("✅ Database seeded successfully");

0 commit comments

Comments
 (0)