Skip to content
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
3 changes: 1 addition & 2 deletions apps/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { TypeOrmModule } from '@nestjs/typeorm';

import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TaskModule } from './task/task.module';
import AppDataSource from './data-source';

@Module({
imports: [TypeOrmModule.forRoot(AppDataSource.options), TaskModule],
imports: [TypeOrmModule.forRoot(AppDataSource.options)],
controllers: [AppController],
providers: [AppService],
})
Expand Down
3 changes: 1 addition & 2 deletions apps/backend/src/data-source.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DataSource } from 'typeorm';
import { PluralNamingStrategy } from './strategies/plural-naming.strategy';
import { Task } from './task/types/task.entity';
import * as dotenv from 'dotenv';

dotenv.config();
Expand All @@ -12,7 +11,7 @@ const AppDataSource = new DataSource({
username: process.env.NX_DB_USERNAME,
password: process.env.NX_DB_PASSWORD,
database: process.env.NX_DB_DATABASE,
entities: [Task],
entities: [],
migrations: ['apps/backend/src/migrations/*.js'],
// Setting synchronize: true shouldn't be used in production - otherwise you can lose production data
synchronize: false,
Expand Down
19 changes: 0 additions & 19 deletions apps/backend/src/migrations/1754254886189-add_task.ts

This file was deleted.

92 changes: 92 additions & 0 deletions apps/backend/src/migrations/1754254886189-init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class Init1754254886189 implements MigrationInterface {
name = 'Init1754254886189';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TYPE "public"."commit_length_enum" AS ENUM('Semester', 'Month', 'Year')`,
);

await queryRunner.query(
`CREATE TYPE "public"."site_enum" AS ENUM('Downtown Campus', 'North Campus', 'West Campus', 'East Campus')`,
);

await queryRunner.query(
`CREATE TYPE "public"."app_status_enum" AS ENUM('App submitted', 'in review', 'forms sent', 'accepted', 'rejected')`,
);

await queryRunner.query(
`CREATE TYPE "public"."school_enum" AS ENUM('Harvard Medical School', 'Johns Hopkins', 'Stanford Medicine', 'Mayo Clinic', 'Other')`,
);

await queryRunner.query(
`CREATE TYPE "public"."experience_type_enum" AS ENUM('BS', 'MS', 'PhD', 'MD', 'MD PhD', 'RN', 'NP', 'PA', 'Other')`,
);

await queryRunner.query(
`CREATE TYPE "public"."interest_area_enum" AS ENUM('Nursing', 'HarmReduction', 'WomensHealth')`,
);

await queryRunner.query(
`CREATE TABLE "admin" (
"id" SERIAL NOT NULL,
"name" character varying NOT NULL,
"email" character varying NOT NULL UNIQUE,
CONSTRAINT "PK_admin_id" PRIMARY KEY ("id")
)`,
);

await queryRunner.query(
`CREATE TABLE "discipline" (
"id" SERIAL NOT NULL,
"name" character varying NOT NULL,
"admin_ids" integer[] NOT NULL DEFAULT '{}',
CONSTRAINT "PK_discipline_id" PRIMARY KEY ("id")
)`,
);

await queryRunner.query(
`CREATE TABLE "application" (
"appId" SERIAL NOT NULL,
"phone" character varying NOT NULL,
"school" "public"."school_enum" NOT NULL,
"daysAvailable" character varying NOT NULL,
"weeklyHours" integer NOT NULL,
"experienceType" "public"."experience_type_enum" NOT NULL,
"interest" "public"."interest_area_enum" NOT NULL,
"license" character varying,
"appStatus" "public"."app_status_enum" NOT NULL DEFAULT 'App submitted',
"isInternational" boolean NOT NULL DEFAULT false,
"isLearner" boolean NOT NULL DEFAULT false,
"referredEmail" character varying,
"referred" boolean NOT NULL DEFAULT false,
CONSTRAINT "PK_application_appId" PRIMARY KEY ("appId")
)`,
);

await queryRunner.query(
`CREATE TABLE "learner" (
"id" SERIAL NOT NULL,
"app_id" integer NOT NULL,
"name" character varying NOT NULL,
"startDate" DATE NOT NULL,
"endDate" DATE NOT NULL,
CONSTRAINT "PK_learner_id" PRIMARY KEY ("id"),
CONSTRAINT "FK_learner_app_id" FOREIGN KEY ("app_id") REFERENCES "application"("appId") ON DELETE CASCADE
)`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE "learner"`);
await queryRunner.query(`DROP TABLE "application"`);
await queryRunner.query(`DROP TABLE "discipline"`);
await queryRunner.query(`DROP TABLE "admin"`);
await queryRunner.query(`DROP TYPE "public"."interest_area_enum"`);
await queryRunner.query(`DROP TYPE "public"."experience_type_enum"`);
await queryRunner.query(`DROP TYPE "public"."school_enum"`);
await queryRunner.query(`DROP TYPE "public"."app_status_enum"`);
await queryRunner.query(`DROP TYPE "public"."site_enum"`);
await queryRunner.query(`DROP TYPE "public"."commit_length_enum"`);
}
}
10 changes: 5 additions & 5 deletions example.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NX_DB_HOST=localhost,
NX_DB_USERNAME=postgres,
NX_DB_PASSWORD=,
NX_DB_DATABASE=jumpstart,
NX_DB_PORT=5432,
NX_DB_HOST=localhost
NX_DB_PORT=5432
NX_DB_USERNAME=postgres
NX_DB_PASSWORD=
NX_DB_DATABASE=bhchp