From 1d8fdf988a66bfccc821628a1f04c42761f1a035 Mon Sep 17 00:00:00 2001 From: jonathankim345 <40842083+jonathankim345@users.noreply.github.com> Date: Sun, 30 Jun 2024 00:35:07 -0400 Subject: [PATCH] Added makefile and updated whether a column could be null --- Makefile | 58 +++++++++++++++++++ .../2024.06.15T17.13.39.add-user-columns.ts | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0b0cbe0 --- /dev/null +++ b/Makefile @@ -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 \ No newline at end of file diff --git a/backend/typescript/migrations/2024.06.15T17.13.39.add-user-columns.ts b/backend/typescript/migrations/2024.06.15T17.13.39.add-user-columns.ts index 581fbae..0d00feb 100644 --- a/backend/typescript/migrations/2024.06.15T17.13.39.add-user-columns.ts +++ b/backend/typescript/migrations/2024.06.15T17.13.39.add-user-columns.ts @@ -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", {