~repos /edge-city
git clone https://pyrossh.dev/repos/edge-city.git
edge-city is a next level meta-framework for react that runs only on edge runtimes
81e59750
—
Peter John 2 years ago
fix db
- packages/example/bun.lockb +0 -0
- packages/example/db/index.js +10 -5
- packages/example/db/migrations/0000_empty_shatterstar.sql +7 -0
- packages/example/db/migrations/0000_legal_natasha_romanoff.sql +0 -4
- packages/example/db/migrations/meta/0000_snapshot.json +19 -1
- packages/example/db/migrations/meta/_journal.json +12 -1
- packages/example/package.json +3 -3
- packages/example/routes/api/todos/index.js +1 -1
packages/example/bun.lockb
CHANGED
|
Binary file
|
packages/example/db/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pgTable, serial, text } from 'drizzle-orm/pg-core';
|
|
1
|
+
import { boolean, date, pgTable, serial, text } from 'drizzle-orm/pg-core';
|
|
2
2
|
import { drizzle } from 'drizzle-orm/neon-serverless';
|
|
3
3
|
import { Pool } from '@neondatabase/serverless';
|
|
4
4
|
import { migrate } from 'drizzle-orm/neon-serverless/migrator';
|
|
@@ -8,15 +8,20 @@ export const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
|
|
8
8
|
export const db = drizzle(pool, {
|
|
9
9
|
logger: {
|
|
10
10
|
logQuery: (query, params) => {
|
|
11
|
-
|
|
11
|
+
const sqlString = params.reduce((acc, v, i) => acc.replaceAll("$" + (i + 1), v), query);
|
|
12
|
-
console.log(
|
|
12
|
+
console.log(highlight(sqlString));
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
+
export const migrateAll = async () => {
|
|
17
|
-
|
|
18
|
+
await migrate(db, { migrationsFolder: './db/migrations' });
|
|
19
|
+
}
|
|
18
20
|
|
|
19
21
|
export const todos = pgTable('todos', {
|
|
20
22
|
id: serial('id').primaryKey(),
|
|
21
23
|
text: text('text').notNull(),
|
|
24
|
+
completed: boolean('completed').notNull(),
|
|
25
|
+
createdAt: date('createdAt').notNull(),
|
|
26
|
+
updatedAt: date('updatedAt'),
|
|
22
|
-
});
|
|
27
|
+
});
|
packages/example/db/migrations/0000_empty_shatterstar.sql
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS "todos" (
|
|
2
|
+
"id" serial PRIMARY KEY NOT NULL,
|
|
3
|
+
"text" text NOT NULL,
|
|
4
|
+
"completed" boolean NOT NULL,
|
|
5
|
+
"createdAt" date NOT NULL,
|
|
6
|
+
"updatedAt" date
|
|
7
|
+
);
|
packages/example/db/migrations/0000_legal_natasha_romanoff.sql
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
CREATE TABLE IF NOT EXISTS "todos" (
|
|
2
|
-
"id" serial PRIMARY KEY NOT NULL,
|
|
3
|
-
"text" text
|
|
4
|
-
);
|
packages/example/db/migrations/meta/0000_snapshot.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "5",
|
|
3
3
|
"dialect": "pg",
|
|
4
|
-
"id": "
|
|
4
|
+
"id": "7b876e3f-3db0-4282-b1c9-a5961b930b99",
|
|
5
5
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
6
6
|
"tables": {
|
|
7
7
|
"todos": {
|
|
@@ -18,6 +18,24 @@
|
|
|
18
18
|
"name": "text",
|
|
19
19
|
"type": "text",
|
|
20
20
|
"primaryKey": false,
|
|
21
|
+
"notNull": true
|
|
22
|
+
},
|
|
23
|
+
"completed": {
|
|
24
|
+
"name": "completed",
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"primaryKey": false,
|
|
27
|
+
"notNull": true
|
|
28
|
+
},
|
|
29
|
+
"createdAt": {
|
|
30
|
+
"name": "createdAt",
|
|
31
|
+
"type": "date",
|
|
32
|
+
"primaryKey": false,
|
|
33
|
+
"notNull": true
|
|
34
|
+
},
|
|
35
|
+
"updatedAt": {
|
|
36
|
+
"name": "updatedAt",
|
|
37
|
+
"type": "date",
|
|
38
|
+
"primaryKey": false,
|
|
21
39
|
"notNull": false
|
|
22
40
|
}
|
|
23
41
|
},
|
packages/example/db/migrations/meta/_journal.json
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "5",
|
|
3
|
+
"dialect": "pg",
|
|
4
|
+
"entries": [
|
|
5
|
+
{
|
|
6
|
+
"idx": 0,
|
|
7
|
+
"version": "5",
|
|
8
|
+
"when": 1683227001598,
|
|
1
|
-
|
|
9
|
+
"tag": "0000_empty_shatterstar"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
packages/example/package.json
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@neondatabase/serverless": "^0.2.9",
|
|
14
|
-
"@planetscale/database": "^1.6.0",
|
|
15
|
-
"drizzle-orm": "
|
|
14
|
+
"drizzle-orm": "0.25.4",
|
|
15
|
+
"next-auth": "^4.22.1",
|
|
16
16
|
"react": "18.2.0",
|
|
17
17
|
"react-dom": "^18.2.0",
|
|
18
18
|
"sql-highlight": "^4.3.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"drizzle-kit": "
|
|
21
|
+
"drizzle-kit": "0.17.6",
|
|
22
22
|
"@playwright/test": "^1.31.2",
|
|
23
23
|
"eslint": "^8.35.0",
|
|
24
24
|
"eslint-config-react-app": "^7.0.1",
|
packages/example/routes/api/todos/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { gt, eq } from 'drizzle-orm
|
|
1
|
+
import { gt, eq } from 'drizzle-orm';
|
|
2
2
|
import { db, todos } from "@/db";
|
|
3
3
|
|
|
4
4
|
export const onGet = async (req) => {
|