-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,298 additions
and
165 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# .gitignore and... | ||
|
||
package*.json | ||
**/*.typegen.ts | ||
app/db.server/meta/*.json |
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,14 @@ | ||
-- Migrating from Prisma | ||
DROP TABLE IF EXISTS `_prisma_migrations`; | ||
--> statement-breakpoint | ||
DROP TABLE IF EXISTS `CacheEntry`; | ||
--> statement-breakpoint | ||
CREATE TABLE `cacheEntry` ( | ||
`id` integer PRIMARY KEY NOT NULL, | ||
`createdAt` text DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
`updatedAt` text NOT NULL, | ||
`key` text NOT NULL, | ||
`value` text NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE UNIQUE INDEX `cacheEntry_key_unique` ON `cacheEntry` (`key`); |
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,14 @@ | ||
import { resolve } from 'pathe'; | ||
import { drizzle } from 'drizzle-orm/better-sqlite3'; | ||
import Database from 'better-sqlite3'; | ||
import { getEnvVars } from '~/utils/env.server'; | ||
import * as schema from './schema'; | ||
|
||
const { DATABASE_FILE_PATH } = getEnvVars(); | ||
|
||
export const betterSqlite = new Database(resolve(DATABASE_FILE_PATH)); | ||
betterSqlite.pragma('journal_mode = WAL'); | ||
|
||
export const db = drizzle(betterSqlite, { schema }); | ||
|
||
export * from './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,67 @@ | ||
{ | ||
"version": "5", | ||
"dialect": "sqlite", | ||
"id": "0433b681-285e-4166-8dde-28c23948ca32", | ||
"prevId": "00000000-0000-0000-0000-000000000000", | ||
"tables": { | ||
"cacheEntry": { | ||
"name": "cacheEntry", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "integer", | ||
"primaryKey": true, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"createdAt": { | ||
"name": "createdAt", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "CURRENT_TIMESTAMP" | ||
}, | ||
"updatedAt": { | ||
"name": "updatedAt", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"key": { | ||
"name": "key", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"value": { | ||
"name": "value", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
} | ||
}, | ||
"indexes": { | ||
"cacheEntry_key_unique": { | ||
"name": "cacheEntry_key_unique", | ||
"columns": [ | ||
"key" | ||
], | ||
"isUnique": true | ||
} | ||
}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
} | ||
}, | ||
"enums": {}, | ||
"_meta": { | ||
"schemas": {}, | ||
"tables": {}, | ||
"columns": {} | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"version": "5", | ||
"dialect": "sqlite", | ||
"entries": [ | ||
{ | ||
"idx": 0, | ||
"version": "5", | ||
"when": 1709622306297, | ||
"tag": "0000_thick_korvac", | ||
"breakpoints": true | ||
} | ||
] | ||
} |
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,7 @@ | ||
import 'dotenv/config'; | ||
import { migrate } from 'drizzle-orm/better-sqlite3/migrator'; | ||
import { betterSqlite, db } from './drizzle'; | ||
|
||
migrate(db, { migrationsFolder: './app/db.server' }); | ||
|
||
betterSqlite.close(); |
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,14 @@ | ||
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'; | ||
import { sql } from 'drizzle-orm'; | ||
|
||
// Note: CURRENT_TIMESTAMP will be in GMT. | ||
|
||
export const cacheEntry = sqliteTable('cacheEntry', { | ||
id: integer('id').primaryKey(), | ||
createdAt: text('createdAt') | ||
.default(sql`CURRENT_TIMESTAMP`) | ||
.notNull(), | ||
updatedAt: text('updatedAt').notNull(), | ||
key: text('key').unique().notNull(), | ||
value: text('value').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
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 was deleted.
Oops, something went wrong.
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,18 @@ | ||
// This config file is only used for drizzle-kit commands, AFAIK. | ||
import 'dotenv/config'; | ||
import { resolve } from 'pathe'; | ||
import type { Config } from 'drizzle-kit'; | ||
import { getEnvVars } from '~/utils/env.server'; | ||
|
||
const { DATABASE_FILE_PATH } = getEnvVars(); | ||
|
||
export default { | ||
driver: 'better-sqlite', | ||
out: './app/db.server', | ||
schema: [resolve('./app/db.server/schema.ts')], | ||
dbCredentials: { url: DATABASE_FILE_PATH }, | ||
// Print all statements | ||
verbose: true, | ||
// Always ask for confirmation | ||
strict: true, | ||
} satisfies Config; |
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
Oops, something went wrong.