Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/drizzle #13

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 8 additions & 5 deletions db-scripts/createdb.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
create database acm_website if not exists;
SELECT 'CREATE DATABASE acm_website'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'acm_website')\gexec

\c acm_website;

Expand Down Expand Up @@ -35,8 +36,8 @@ create table if not exists session(
id text not null,
user_id text not null,
created_at timestamp not null,
active_expires number not null,
idle_expires number not null,
active_expires BIGINT not null,
idle_expires BIGINT not null,
PRIMARY KEY(id),
FOREIGN KEY(user_id) REFERENCES users(id) on update cascade on delete cascade
);
Expand All @@ -53,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 @@ -71,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