Skip to content

Commit

Permalink
drizzle schema
Browse files Browse the repository at this point in the history
  • Loading branch information
knhn1004 committed Oct 5, 2024
1 parent e0eb0ae commit a6d6370
Show file tree
Hide file tree
Showing 9 changed files with 1,549 additions and 9 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=acm_website
POSTGRES_HOST=db

PORT=5001
6 changes: 4 additions & 2 deletions db-scripts/createdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ create table if not exists equipment_rental_type(
id serial,
created_at timestamp not null default CURRENT_TIMESTAMP,
name text not null,
price money not null,
-- price money not null,
price numeric(10,2) not null,
description text,
PRIMARY KEY(id)
);
Expand All @@ -72,7 +73,8 @@ create table if not exists equipment_rentals(
user_id text,
date_borrowed date not null default current_date,
return_date date not null,
price money not null,
-- price money not null,
price numeric(10,2) not null,
condition equipment_condition_enum not null default 'ready',
PRIMARY KEY(user_id, item_id),
FOREIGN KEY(item_id) REFERENCES equipment_item(id) on update cascade,
Expand Down
Binary file modified server/bun.lockb
Binary file not shown.
19 changes: 19 additions & 0 deletions server/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from 'drizzle-kit';
import * as dotenv from 'dotenv';

dotenv.config();

export default defineConfig({
dialect: 'postgresql',
schema: './src/db/schema.ts',
out: './drizzle',
dbCredentials: {
host: process.env.POSTGRES_HOST || 'localhost',
port: Number(process.env.POSTGRES_PORT) || 5432,
user: process.env.POSTGRES_USER || 'postgres',
password: process.env.POSTGRES_PASSWORD || 'postgres',
database: process.env.POSTGRES_DB || 'acm_website',
ssl: 'allow',
},
verbose: true,
});
Loading

0 comments on commit a6d6370

Please sign in to comment.