set up drizzle

This commit is contained in:
Nayan Sawyer
2026-03-13 18:05:56 -04:00
parent 532e333c3e
commit 95e68037f0
3 changed files with 27 additions and 0 deletions

View File

@@ -46,6 +46,12 @@ I'm not sure about auth yet, but probably NextAuth.
The project is meant to be self hosted, with a single docker compose file to deploy the application and the database.
It's still in the early stages of development, so it's not yet ready for production.
I can't get file watching to work with the docker compose file, so I'm running the dev server natively, with postgres in a container.
## License
This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.
### db command
docker compose exec db psql -U socialdb -d socialdb-db

13
drizzle.config.ts Normal file
View File

@@ -0,0 +1,13 @@
import { config } from "dotenv";
import { defineConfig } from "drizzle-kit";
config({ path: ".env" });
export default defineConfig({
schema: "./src/db/schema.ts",
out: "./src/db/migrations",
dialect: "postgresql",
dbCredentials: {
url: `postgresql://${process.env.POSTGRES_USER}:${process.env.POSTGRES_PASSWORD}@localhost:5432/${process.env.POSTGRES_DB}`,
},
});

8
src/db/drizzle.ts Normal file
View File

@@ -0,0 +1,8 @@
import { config } from "dotenv";
import { drizzle } from "drizzle-orm/node-postgres";
config({ path: ".env" });
export const db = drizzle(
`postgresql://${process.env.POSTGRES_USER}:${process.env.POSTGRES_PASSWORD}@localhost:5432/${process.env.POSTGRES_DB}`,
);