-
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: migrate from prisma to drizzle ORM (#180)
* build(deps): add Drizzle ORM and planetscale connector * build(deps): remove prisma as dependencies * feat(drizzle): add drizzle based schemas and middleware * build(deps-dev): add lodash-es and mysql2 and update nuxt * fix(schema): fix schema and relationships * feat(server): add db migrate, seed and crud ops * style(schema): apply biomejs * feat(crud): add crud operations It is complex, however drizzle gives us no other choice * fix(middleware): use nuxt runtime config for setting database URL * feat(prisma): remove unrequired files * style(db): apply biomejs * refactor(seed): apply biomejs and simplify code * feat(api/sections): change caching params and use crud ops * feat(api/question): validate router params and use crud ops * style(pages): add a space * refactor(components): use updated types for Answer * refactor(composables): do not use proxy url * feat(useSectionNav): remove not `undefined` assert * build(deps-dev): update deps and add type helper package * build(nuxt): do not generate shim * refactor: update type import path * fix(crud/question): fetch the correct related data * refactor(crud/answer): remove unused code
- Loading branch information
1 parent
4951929
commit 6f3e5ad
Showing
35 changed files
with
2,143 additions
and
420 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'dotenv/config' | ||
import { type Config } from 'drizzle-kit' | ||
|
||
export default { | ||
out: 'src/server/database/migrations', | ||
schema: 'src/server/database/schema/*', | ||
driver: 'mysql2', | ||
dbCredentials: { | ||
uri: process.env.DATABASE_URL!, | ||
database: process.env.DATABASE_NAME!, | ||
}, | ||
} 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'dotenv/config' | ||
import { migrate } from 'drizzle-orm/planetscale-serverless/migrator' | ||
import { getDb } from '~/server/database/db' | ||
|
||
// This will run migrations on the database, skipping the ones already applied | ||
await migrate(getDb(process.env.DATABASE_URL!), { | ||
migrationsFolder: './src/server/database/migrations', | ||
}) |
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.