add drizzle schema and removed astrodb stuff
This commit is contained in:
20
db/config.ts
20
db/config.ts
@@ -1,20 +0,0 @@
|
|||||||
import { defineDb, column, defineTable, NOW } from 'astro:db';
|
|
||||||
|
|
||||||
const Entry = defineTable({
|
|
||||||
columns: {
|
|
||||||
id: column.number({ primaryKey: true }),
|
|
||||||
date: column.date({ default: NOW }),
|
|
||||||
location: column.json(),
|
|
||||||
content: column.json({ default: {} })
|
|
||||||
},
|
|
||||||
indexes: [
|
|
||||||
{ on: ['date', 'content'] }
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
// https://astro.build/db/config
|
|
||||||
export default defineDb({
|
|
||||||
tables: {
|
|
||||||
Entry
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
import { db } from 'astro:db';
|
|
||||||
|
|
||||||
// https://astro.build/db/seed
|
|
||||||
export default async function seed() {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
volumes:
|
volumes:
|
||||||
- ./pg:/var/lib/postgresql/data
|
- ~/tmp/pg:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_PASSWORD: test
|
POSTGRES_PASSWORD: test
|
||||||
POSTGRES_USER: memento
|
POSTGRES_USER: memento
|
||||||
|
|||||||
@@ -13,7 +13,15 @@
|
|||||||
"@astrojs/node": "^9.5.1",
|
"@astrojs/node": "^9.5.1",
|
||||||
"@tailwindcss/vite": "^4.1.18",
|
"@tailwindcss/vite": "^4.1.18",
|
||||||
"astro": "^5.16.8",
|
"astro": "^5.16.8",
|
||||||
|
"dotenv": "^17.2.3",
|
||||||
|
"drizzle-orm": "^0.45.1",
|
||||||
|
"pg": "^8.16.3",
|
||||||
"quill": "2.0.3",
|
"quill": "2.0.3",
|
||||||
"tailwindcss": "^4.1.18"
|
"tailwindcss": "^4.1.18"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/pg": "^8.16.0",
|
||||||
|
"drizzle-kit": "^0.31.8",
|
||||||
|
"tsx": "^4.21.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
863
pnpm-lock.yaml
generated
863
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
8
src/db/schema.ts
Normal file
8
src/db/schema.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { integer, pgTable, varchar, date, json } from "drizzle-orm/pg-core";
|
||||||
|
|
||||||
|
export const usersTable = pgTable("users", {
|
||||||
|
id: integer().primaryKey().generatedAlwaysAsIdentity(),
|
||||||
|
data: date().defaultNow(),
|
||||||
|
location: json(),
|
||||||
|
content: json(),
|
||||||
|
});
|
||||||
4
src/utils/db.ts
Normal file
4
src/utils/db.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import 'dotenv/config';
|
||||||
|
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||||
|
|
||||||
|
const db = drizzle(process.env.DATABASE_URL!);
|
||||||
Reference in New Issue
Block a user