Skip to content

Commit

Permalink
Added makefile and updated whether a column could be null
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathankim345 committed Jun 30, 2024
1 parent b2e4db9 commit 1d8fdf9
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Makefile for Oakville and Milton Humane Society Project
.PHONY: lint format migration generate-migration start-docker stop-docker clean-db seed-db read-tables read-table help

# Linting & Formatting
lint:
docker exec -it humane_society_backend /bin/bash -c "yarn lint"
docker exec -it humane_society_frontend /bin/bash -c "yarn lint"

format:
docker exec -it humane_society_backend /bin/bash -c "yarn fix"
docker exec -it humane_society_frontend /bin/bash -c "yarn fix"

# Database Migrations
migration:
docker exec -it humane_society_backend /bin/bash -c "node migrate up"

generate-migration:
docker exec -it humane_society_backend /bin/bash -c "node migrate create --name $(name).ts"

# Docker Commands
start-docker:
docker-compose up --build

stop-docker:
docker-compose down

# Database Operations
clean-db:
docker exec -it humane_society_backend /bin/bash -c "node migrate down && node migrate up"

# Seeding script has not been created yet
seed-db:
# docker exec -it humane_society_backend /bin/bash -c "node seed"

# Acessing Postgres DB
read-tables:
docker exec -it humane_society_db /bin/bash -c "\
psql -U postgres -d humane_society_dev -c '\dt';"

read-table:
docker exec -it humane_society_db /bin/bash -c "\
psql -U postgres -d humane_society_dev -c '\dt'; \
psql -U postgres -d humane_society_dev -c 'SELECT * FROM $(TABLE);'"

# Help
help:
@echo Available targets or actions:
@echo lint Lint the code
@echo format Format the code
@echo migration Run database migrations
@echo generate-migration Generate a new migration
@echo start-docker Start Docker containers
@echo stop-docker Stop Docker containers
@echo read-tables See all database tables
@echo read-table See a single table
@echo clean-db Clean the database and rerun migrations
@echo seed-db The database seeding script has yet to be implemented
@echo help Show this help message
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Migration } from "../umzug";
export const up: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().addColumn("users", "email", {
type: DataType.STRING,
allowNull: false,
allowNull: true,
});

await sequelize.getQueryInterface().addColumn("users", "skill_level", {
Expand Down

0 comments on commit 1d8fdf9

Please sign in to comment.