-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use internal package for Database
- Loading branch information
Showing
26 changed files
with
225 additions
and
76 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
This file was deleted.
Oops, something went wrong.
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
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,10 +1,10 @@ | ||
import { queryClient } from '~/server/database/db'; | ||
import * as schema from '~/server/database/schema'; | ||
|
||
export { sql, eq, and, or } from 'drizzle-orm'; | ||
import { queryClient } from '@getlicensed/db'; | ||
import * as schema from '@getlicensed/db'; | ||
|
||
export const tables = schema; | ||
|
||
export function useDB() { | ||
return queryClient; | ||
} | ||
|
||
export * from '@getlicensed/db'; |
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,6 +1,7 @@ | ||
import type { Config } from 'drizzle-kit'; | ||
|
||
export default { | ||
schema: './server/database/schema.ts', | ||
out: './server/database/migrations', | ||
verbose: true, | ||
schema: './src/schema.ts', | ||
out: './src/migrations', | ||
} 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,28 @@ | ||
{ | ||
"name": "@getlicensed/db", | ||
"version": "0.0.0", | ||
"description": "", | ||
"main": "./src/index.ts", | ||
"types": "./src/index.ts", | ||
"keywords": [], | ||
"author": "Maxence Maireaux", | ||
"license": "AGPL-3.0", | ||
"scripts": { | ||
"studio": "dotenv -e .env drizzle-kit studio ", | ||
"db:generate": "drizzle-kit generate:pg", | ||
"db:migrate": "tsx src/migrate.ts" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.12.7", | ||
"dotenv-cli": "^7.4.1", | ||
"drizzle-kit": "^0.20.17", | ||
"drizzle-orm": "^0.30.9", | ||
"pg": "^8.11.5", | ||
"ts-node": "^10.9.2", | ||
"tsx": "^4.7.2", | ||
"typescript": "^5.4.5" | ||
}, | ||
"dependencies": { | ||
"@neondatabase/serverless": "^0.9.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { runMigrate } from './index'; | ||
|
||
runMigrate() | ||
.then(() => { | ||
console.log('Database migrations fully done'); | ||
}) | ||
.catch((err) => { | ||
console.error('Database migrations failed', err); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,5 @@ | ||
import type { InferSelectModel } from 'drizzle-orm'; | ||
import type * as schema from './schema'; | ||
|
||
export type Users = InferSelectModel<typeof schema.users>; | ||
export type Tokens = InferSelectModel<typeof schema.tokens>; |
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 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/tsconfig", | ||
"exclude": ["dist"], | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
} | ||
} |
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.