-
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
1 parent
d6c8d49
commit 712baa4
Showing
16 changed files
with
1,101 additions
and
153 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,13 @@ | ||
{ | ||
"scripts": { | ||
"migrate": "pnpm -C packages/db migrate", | ||
"test": "pnpm -C packages/test start" | ||
}, | ||
"devDependencies": { | ||
"prettier": "^3.3.3" | ||
}, | ||
"dependencies": { | ||
"tsx": "^4.16.2" | ||
} | ||
"esrun": "^3.2.26" | ||
}, | ||
"packageManager": "[email protected]+sha512.77b89e9be77a2b06ad8f403a19cae5e22976f61023f98ad323d5c30194958ebc02ee0a6ae5d13ee454f6134e4e8caf29a05f0b1a0e1d2b17bca6b6a1f1159f86" | ||
} |
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 @@ | ||
config.ts |
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 @@ | ||
import CONFIG from "./config.ts"; | ||
|
||
export type Configuration = { | ||
DATABASE: { | ||
HOST: string; | ||
PORT: number; | ||
USERNAME: string; | ||
PASSWORD: string; | ||
NAME: string; | ||
}; | ||
}; | ||
|
||
export default CONFIG as Configuration; |
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,4 @@ | ||
{ | ||
"name": "@transgg/config", | ||
"type": "module" | ||
} |
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,15 @@ | ||
import { defineConfig } from "drizzle-kit"; | ||
import CONFIG from "../config/index.ts"; | ||
|
||
export default defineConfig({ | ||
schema: "./src/schema.ts", | ||
out: "./drizzle", | ||
dialect: "mysql", | ||
dbCredentials: { | ||
host: CONFIG.DATABASE.HOST, | ||
port: CONFIG.DATABASE.PORT, | ||
user: CONFIG.DATABASE.USERNAME, | ||
password: CONFIG.DATABASE.PASSWORD, | ||
database: CONFIG.DATABASE.NAME, | ||
}, | ||
}); |
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,4 @@ | ||
CREATE TABLE `test` ( | ||
`id` int AUTO_INCREMENT NOT NULL, | ||
CONSTRAINT `test_id` PRIMARY KEY(`id`) | ||
); |
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,40 @@ | ||
{ | ||
"version": "5", | ||
"dialect": "mysql", | ||
"id": "28145d42-50b2-42f4-bda1-61e94e2064e7", | ||
"prevId": "00000000-0000-0000-0000-000000000000", | ||
"tables": { | ||
"test": { | ||
"name": "test", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "int", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": true | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": { | ||
"test_id": { | ||
"name": "test_id", | ||
"columns": [ | ||
"id" | ||
] | ||
} | ||
}, | ||
"uniqueConstraints": {} | ||
} | ||
}, | ||
"_meta": { | ||
"schemas": {}, | ||
"tables": {}, | ||
"columns": {} | ||
}, | ||
"internal": { | ||
"tables": {}, | ||
"indexes": {} | ||
} | ||
} |
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": "7", | ||
"dialect": "mysql", | ||
"entries": [ | ||
{ | ||
"idx": 0, | ||
"version": "5", | ||
"when": 1721312426379, | ||
"tag": "0000_gorgeous_azazel", | ||
"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,3 @@ | ||
import * as tables from "./src/schema.ts"; | ||
export { db } from "./src/db.ts"; | ||
export { tables }; |
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,16 @@ | ||
{ | ||
"name": "@transgg/db", | ||
"type": "module", | ||
"scripts": { | ||
"migrate:generate": "pnpm drizzle-kit generate", | ||
"migrate:run": "pnpm esrun ./src/migrate.ts", | ||
"migrate": "pnpm migrate:generate && pnpm migrate:run" | ||
}, | ||
"dependencies": { | ||
"drizzle-orm": "^0.32.0", | ||
"mysql2": "^3.10.3" | ||
}, | ||
"devDependencies": { | ||
"drizzle-kit": "^0.23.0" | ||
} | ||
} |
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 { drizzle } from "drizzle-orm/mysql2"; | ||
import mysql from "mysql2/promise"; | ||
import CONFIG from "../../config/index.ts"; | ||
import * as schema from "./schema.ts"; | ||
|
||
export const connection = await mysql.createConnection({ | ||
host: CONFIG.DATABASE.HOST, | ||
port: CONFIG.DATABASE.PORT, | ||
user: CONFIG.DATABASE.USERNAME, | ||
password: CONFIG.DATABASE.PASSWORD, | ||
database: CONFIG.DATABASE.NAME, | ||
}); | ||
|
||
export const db = drizzle(connection, { schema, mode: "default" }); |
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 { migrate } from "drizzle-orm/mysql2/migrator" | ||
import { connection, db } from "./db.ts" | ||
|
||
await migrate(db, { migrationsFolder: "./drizzle" }); | ||
await connection.end(); |
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 { int, mysqlTable } from "drizzle-orm/mysql-core"; | ||
|
||
export const test = mysqlTable("test", { | ||
id: int("id").notNull().primaryKey().autoincrement(), | ||
}); |
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 +1,3 @@ | ||
console.log("Hello, World!"); | ||
import { db } from "../db/index.ts"; | ||
|
||
console.log((await db.query.test.findMany()).map((entry) => entry.id)); |
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,5 +1,9 @@ | ||
{ | ||
"name": "@transgg/test", | ||
"scripts": { | ||
"start": "pnpm tsx index.ts" | ||
"start": "pnpm esrun index.ts" | ||
}, | ||
"dependencies": { | ||
"@transgg/config": "workspace:^" | ||
} | ||
} |
Oops, something went wrong.