diff --git a/README.md b/README.md index 60e45bd..c446a9c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/drizzle.config.ts b/drizzle.config.ts new file mode 100644 index 0000000..6aefb42 --- /dev/null +++ b/drizzle.config.ts @@ -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}`, + }, +}); diff --git a/src/db/drizzle.ts b/src/db/drizzle.ts new file mode 100644 index 0000000..7e33b0d --- /dev/null +++ b/src/db/drizzle.ts @@ -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}`, +);