Skip to content

Commit 80f9b96

Browse files
Initial setup with Drizzle and Postgres
1 parent 1504fad commit 80f9b96

9 files changed

Lines changed: 3223 additions & 1842 deletions

File tree

Makefile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ up:
2222
@docker compose up --detach
2323

2424
down:
25-
@docker compose down
25+
@docker compose --profile "*" down
2626

2727
shell: up
2828
@docker compose exec $(CONTAINER) bash
@@ -50,6 +50,17 @@ update-dependencies: up
5050
build:
5151
@docker compose build
5252

53+
serve-tools:
54+
@docker compose --profile tools up --detach
55+
@echo Running Adminer at http://localhost:8080/
56+
57+
db-push:
58+
@docker compose exec ${CONTAINER} sh -c "npx drizzle-kit push"
59+
60+
db-migrate:
61+
@docker compose exec ${CONTAINER} sh -c "npx drizzle-kit generate"
62+
@docker compose exec ${CONTAINER} sh -c "npx drizzle-kit migrate"
63+
5364
$(SOURCE_DIR)/node_modules:
5465
@echo Installing JS dependencies. This will take awhile.
5566
docker compose exec $(CONTAINER) sh -c "npm install"
@@ -63,6 +74,10 @@ clean-astro-content:
6374
@$(RemoveDirCmd) $(call FixPath,$(SOURCE_DIR)/.astro)
6475
@$(RemoveDirCmd) $(call FixPath,$(SOURCE_DIR)/node_modules/.astro-og-canvas)
6576

77+
clean-db:
78+
@echo Removing database volume
79+
@docker volume rm website_pg_data
80+
6681
clean-js-dist:
6782
@echo Removing the $(SOURCE_DIR)/dist directory.
6883
@$(RemoveDirCmd) $(call FixPath,$(SOURCE_DIR)/dist)
@@ -74,5 +89,6 @@ clean-js-modules:
7489
clean: clean-js-dist clean-js-modules
7590

7691
.PHONY: serve up down build shell dist version \
77-
clean clean-astro-content clean-js-dist clean-js-modules \
92+
prettier serve-tools upgrade-astro update-dependencies \
93+
clean clean-astro-content clean-db clean-js-dist clean-js-modules \
7894
.FORCE

astro/astro.config.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from "astro/config";
1+
import { defineConfig, envField } from "astro/config";
22
import styleGuide from "./style-guide/register.js";
33

44
import icon from "astro-icon";
@@ -49,6 +49,12 @@ export default defineConfig({
4949
},
5050
},
5151

52+
env: {
53+
schema: {
54+
DATABASE_URL: envField.string({ context: "server", access: "secret", optional: false }),
55+
}
56+
},
57+
5258
integrations: [
5359
mdx(),
5460
styleGuide(),

astro/drizzle.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'dotenv/config';
2+
import { defineConfig } from 'drizzle-kit';
3+
4+
export default defineConfig({
5+
out: './drizzle',
6+
schema: './src/db/schema.ts',
7+
dialect: 'postgresql',
8+
dbCredentials: {
9+
url: process.env.DATABASE_URL!,
10+
},
11+
});

0 commit comments

Comments
 (0)