-
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.
* feat(db): migrate to sqlite codebase * build(deps-dev): update dependencies * fix(migrations): update migrations * fix(crud): ignore bogus type errors * build: use new turso based config * refactor: provide detailed error info
- Loading branch information
1 parent
5cabd11
commit 1809e9c
Showing
20 changed files
with
960 additions
and
956 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 |
---|---|---|
@@ -1,11 +1,20 @@ | ||
import 'dotenv/config' | ||
import type { Config } from 'drizzle-kit' | ||
|
||
const databaseUrl = process.env.DATABASE_URL | ||
const authToken = process.env.TURSO_AUTH_TOKEN | ||
if (!databaseUrl || !authToken) { | ||
throw new Error( | ||
'Either DATABASE_URL or TURSO_AUTH_TOKEN not set in the environment variables.', | ||
) | ||
} | ||
|
||
export default { | ||
out: 'src/server/database/migrations', | ||
schema: 'src/server/database/schema/*', | ||
driver: 'mysql2', | ||
driver: 'turso', | ||
dbCredentials: { | ||
uri: process.env.DATABASE_URL as NonNullable<string>, | ||
url: databaseUrl, | ||
authToken, | ||
}, | ||
} 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import 'dotenv/config' | ||
import { migrate } from 'drizzle-orm/planetscale-serverless/migrator' | ||
import { migrate } from 'drizzle-orm/libsql/migrator' | ||
import { getDb } from '~/server/database/db' | ||
|
||
const databaseUrl = process.env.DATABASE_URL | ||
const authToken = process.env.TURSO_AUTH_TOKEN | ||
|
||
if (!databaseUrl) { | ||
throw Error('Database URL not configured in environment variable') | ||
if (!databaseUrl || !authToken) { | ||
throw Error( | ||
'Either database URL (DATABASE_URL) or Turso Auth token (TURSO_AUTH_TOKEN) not set in environment variable', | ||
) | ||
} | ||
// This will run migrations on the database, skipping the ones already applied | ||
await migrate(getDb(databaseUrl), { | ||
migrate(getDb({ url: databaseUrl, authToken }), { | ||
migrationsFolder: './src/server/database/migrations', | ||
}).catch((err) => { | ||
console.error(err) | ||
process.exit(1) | ||
}) |
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
Oops, something went wrong.