-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add drizzle * docs: update readme
- Loading branch information
Showing
11 changed files
with
1,189 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,5 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { drizzle } from "drizzle-orm/libsql"; | ||
import { createClient } from "@libsql/client"; | ||
|
||
import * as schema from "./schema"; | ||
|
||
const turso = createClient({ | ||
url: process.env.TURSO_DATABASE_URL!, | ||
authToken: process.env.TURSO_AUTH_TOKEN, | ||
}); | ||
|
||
export const db = drizzle(turso, { schema }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { text, integer, sqliteTable } from "drizzle-orm/sqlite-core"; | ||
|
||
export const todos = sqliteTable("todos", { | ||
id: integer("id", { | ||
mode: "number", | ||
}).primaryKey({ autoIncrement: true }), | ||
description: text("description").notNull(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import "dotenv/config"; | ||
import { defineConfig } from "drizzle-kit"; | ||
|
||
if (!process.env.TURSO_SCHEMA_DATABASE_NAME) { | ||
throw new Error("TURSO_SCHEMA_DATABASE_NAME is missing"); | ||
} | ||
|
||
if (!process.env.TURSO_ORG_NAME) { | ||
throw new Error("TURSO_ORG_NAME is missing"); | ||
} | ||
|
||
if (!process.env.TURSO_DATABASE_GROUP_AUTH_TOKEN) { | ||
throw new Error("TURSO_DATABASE_GROUP_AUTH_TOKEN is missing"); | ||
} | ||
|
||
const url = `libsql://${process.env.TURSO_SCHEMA_DATABASE_NAME}-${process.env.TURSO_ORG_NAME}.turso.io`; | ||
|
||
export default defineConfig({ | ||
schema: "./db/schema.ts", | ||
out: "./migrations", | ||
dialect: "sqlite", | ||
driver: "turso", | ||
dbCredentials: { | ||
url, | ||
authToken: process.env.TURSO_DATABASE_GROUP_AUTH_TOKEN, | ||
}, | ||
}); |
Oops, something went wrong.