Skip to content

Commit f9bd544

Browse files
committed
Clean up database stuff
1 parent 54fe3af commit f9bd544

File tree

13 files changed

+133
-187
lines changed

13 files changed

+133
-187
lines changed

.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DATABASE_URL=postgres://postgres:password@localhost:5432/roo_code_development

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DATABASE_URL=postgres://postgres:password@localhost:5432/roo_code_test

.husky/pre-commit

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
#!/bin/sh
2-
# Disable concurent to run `check-types` after ESLint in lint-staged
3-
cd "$(dirname "$0")/.." && npx --no lint-staged --concurrent false
1+
pnpx lint-staged

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ You can now install the required packages with:
2828
pnpm install
2929
```
3030

31+
Make sure your database is migrated:
32+
33+
```sh
34+
pnpm db:migrate
35+
```
36+
3137
If everything is working as expected you should be able to run any of the following without errors:
3238

3339
```sh

drizzle.config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import { defineConfig } from 'drizzle-kit';
22

33
export default defineConfig({
44
out: './migrations',
5-
schema: './src/models/Schema.ts',
5+
schema: './src/db/schema.ts',
66
dialect: 'postgresql',
7-
dbCredentials: {
8-
url: process.env.DATABASE_URL ?? '',
9-
},
7+
dbCredentials: { url: process.env.DATABASE_URL! },
108
verbose: true,
119
strict: true,
1210
});

migrations/0000_init-db.sql

Lines changed: 0 additions & 21 deletions
This file was deleted.

migrations/0000_misty_leo.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE TABLE "organization" (
2+
"id" text PRIMARY KEY NOT NULL,
3+
"stripe_customer_id" text,
4+
"stripe_subscription_id" text,
5+
"stripe_subscription_price_id" text,
6+
"stripe_subscription_status" text,
7+
"stripe_subscription_current_period_end" bigint,
8+
"updated_at" timestamp DEFAULT now() NOT NULL,
9+
"created_at" timestamp DEFAULT now() NOT NULL
10+
);
11+
--> statement-breakpoint
12+
CREATE UNIQUE INDEX "stripe_customer_id_idx" ON "organization" USING btree ("stripe_customer_id");

migrations/meta/0000_snapshot.json

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "400db9e7-780a-44b8-b0be-2db504f59104",
2+
"id": "013accf9-070a-47cd-9b49-1318a1c8a237",
33
"prevId": "00000000-0000-0000-0000-000000000000",
44
"version": "7",
55
"dialect": "postgresql",
@@ -78,60 +78,18 @@
7878
},
7979
"foreignKeys": {},
8080
"compositePrimaryKeys": {},
81-
"uniqueConstraints": {}
82-
},
83-
"public.todo": {
84-
"name": "todo",
85-
"schema": "",
86-
"columns": {
87-
"id": {
88-
"name": "id",
89-
"type": "serial",
90-
"primaryKey": true,
91-
"notNull": true
92-
},
93-
"owner_id": {
94-
"name": "owner_id",
95-
"type": "text",
96-
"primaryKey": false,
97-
"notNull": true
98-
},
99-
"title": {
100-
"name": "title",
101-
"type": "text",
102-
"primaryKey": false,
103-
"notNull": true
104-
},
105-
"message": {
106-
"name": "message",
107-
"type": "text",
108-
"primaryKey": false,
109-
"notNull": true
110-
},
111-
"updated_at": {
112-
"name": "updated_at",
113-
"type": "timestamp",
114-
"primaryKey": false,
115-
"notNull": true,
116-
"default": "now()"
117-
},
118-
"created_at": {
119-
"name": "created_at",
120-
"type": "timestamp",
121-
"primaryKey": false,
122-
"notNull": true,
123-
"default": "now()"
124-
}
125-
},
126-
"indexes": {},
127-
"foreignKeys": {},
128-
"compositePrimaryKeys": {},
129-
"uniqueConstraints": {}
81+
"uniqueConstraints": {},
82+
"policies": {},
83+
"checkConstraints": {},
84+
"isRLSEnabled": false
13085
}
13186
},
13287
"enums": {},
13388
"schemas": {},
13489
"sequences": {},
90+
"roles": {},
91+
"policies": {},
92+
"views": {},
13593
"_meta": {
13694
"columns": {},
13795
"schemas": {},

migrations/meta/_journal.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
{
66
"idx": 0,
77
"version": "7",
8-
"when": 1726784321202,
9-
"tag": "0000_init-db",
8+
"when": 1747031111132,
9+
"tag": "0000_misty_leo",
1010
"breakpoints": true
1111
}
1212
]

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"start": "next start",
1414
"build-stats": "cross-env ANALYZE=true pnpm run build",
1515
"clean": "rimraf .next out coverage",
16-
"db:generate": "drizzle-kit generate",
17-
"db:migrate": "dotenv -c production -- drizzle-kit migrate",
18-
"db:studio": "dotenv -c production -- drizzle-kit studio",
16+
"db:generate": "dotenvx run -f .env.development -- drizzle-kit generate",
17+
"db:migrate": "dotenvx run -f .env.development -- drizzle-kit migrate",
18+
"db:studio": "dotenvx run -f .env.development -- drizzle-kit studio",
1919
"storybook": "storybook dev -p 6006",
2020
"storybook:build": "storybook build",
2121
"storybook:serve": "http-server storybook-static --port 6006 --silent",
@@ -27,7 +27,6 @@
2727
"@clerk/localizations": "^3.14.2",
2828
"@clerk/nextjs": "^6.18.3",
2929
"@clerk/themes": "^2.1.36",
30-
"@electric-sql/pglite": "^0.3.0",
3130
"@logtail/pino": "^0.5.2",
3231
"@radix-ui/react-dropdown-menu": "^2.1.14",
3332
"@radix-ui/react-icons": "^1.3.2",
@@ -57,6 +56,7 @@
5756
},
5857
"devDependencies": {
5958
"@clerk/testing": "^1.3.11",
59+
"@dotenvx/dotenvx": "^1.43.0",
6060
"@eslint/js": "^9.26.0",
6161
"@next/bundle-analyzer": "^15.3.2",
6262
"@next/eslint-plugin-next": "^15.3.2",
@@ -83,7 +83,6 @@
8383
"@vitest/expect": "^3.1.3",
8484
"autoprefixer": "^10.4.20",
8585
"cross-env": "^7.0.3",
86-
"dotenv-cli": "^8.0.0",
8786
"drizzle-kit": "^0.31.1",
8887
"eslint": "^9.26.0",
8988
"eslint-config-prettier": "^10.1.5",

0 commit comments

Comments
 (0)