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

Flyway + Initial DryRunDTO #9

Merged
merged 4 commits into from
Jun 12, 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
38 changes: 32 additions & 6 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
previewFeatures = ["metrics"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
url = env("POSTGRESQL_URL")
}

model users {
id Decimal @id(map: "USER_PK") @default(dbgenerated("nextval('\"USER_SEQ\"'::regclass)")) @db.Decimal
name String @db.VarChar(200)
email String @db.VarChar(200)
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model submission_status_code {
submission_status_code String @id(map: "submission_status_code_pk") @db.VarChar(20)
description String @db.VarChar(250)
display_order Int
active_ind Boolean @default(true)
create_user_id String @db.VarChar(200)
create_utc_timestamp DateTime @db.Timestamp(6)
update_user_id String @db.VarChar(200)
update_utc_timestamp DateTime @db.Timestamp(6)
file_submissions_file_submissions_submission_status_codeTosubmission_status_code file_submissions[] @relation("file_submissions_submission_status_codeTosubmission_status_code")
}

model file_submissions {
submission_id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
file_name String @db.VarChar(200)
submission_date DateTime @db.Timestamp(6)
submitter_user_id String @db.VarChar(200)
submission_status_code String @db.VarChar(10)
submitter_agency_name String @db.VarChar(200)
sample_count Int?
results_count Int?
active_ind Boolean @default(true)
error_log String?
organization_guid String? @db.Uuid
create_user_id String @db.VarChar(200)
create_utc_timestamp DateTime @db.Timestamp(6)
update_user_id String @db.VarChar(200)
update_utc_timestamp DateTime @db.Timestamp(6)
submission_status_code_file_submissions_submission_status_codeTosubmission_status_code submission_status_code @relation("file_submissions_submission_status_codeTosubmission_status_code", fields: [submission_status_code], references: [submission_status_code], onDelete: NoAction, onUpdate: NoAction, map: "submission_status_code_fk")
}
4 changes: 2 additions & 2 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
import { HTTPLoggerMiddleware } from "./middleware/req.res.logger";
import { loggingMiddleware, PrismaModule } from "nestjs-prisma";
import { ConfigModule } from "@nestjs/config";
import { UsersModule } from "./users/users.module";
import { AppService } from "./app.service";
import { AppController } from "./app.controller";
import { MetricsController } from "./metrics.controller";
import { TerminusModule } from "@nestjs/terminus";
import { HealthController } from "./health.controller";
import { JWTAuthModule } from "./auth/jwtauth.module";
import { AdminModule } from "./admin/admin.module";
import { DryrunModule } from './dryrun/dryrun.module';

const DB_HOST = process.env.POSTGRES_HOST || "localhost";
const DB_USER = process.env.POSTGRES_USER || "postgres";
Expand Down Expand Up @@ -53,7 +53,7 @@ function getMiddlewares() {
middlewares: getMiddlewares(),
},
}),
UsersModule,
DryrunModule,
JWTAuthModule,
AdminModule,
],
Expand Down
20 changes: 20 additions & 0 deletions backend/src/dryrun/dryrun.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { DryrunController } from './dryrun.controller';
import { DryrunService } from './dryrun.service';

describe('DryrunController', () => {
let controller: DryrunController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [DryrunController],
providers: [DryrunService],
}).compile();

controller = module.get<DryrunController>(DryrunController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
39 changes: 39 additions & 0 deletions backend/src/dryrun/dryrun.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { DryrunService } from './dryrun.service';
import { CreateDryrunDto } from './dto/create-dryrun.dto';
import { UpdateDryrunDto } from './dto/update-dryrun.dto';
import { ApiTags } from '@nestjs/swagger';
import { DryrunDto } from './dto/dryrun.dto';

@ApiTags("dryrun")
@Controller({path: "dryrun", version: "1"})
export class DryrunController {
constructor(private readonly dryrunService: DryrunService) {}

@Post()
create(@Body() createDryrunDto: CreateDryrunDto) {
console.log("I AM HERE!!!");
return this.dryrunService.create(createDryrunDto);
}

@Get()
findAll() {
console.log('FIND ALL HERE!!!')
return this.dryrunService.findAll();
}

@Get(':id')
findOne(@Param('id') id: string) {
return this.dryrunService.findOne(+id);
}

@Patch(':id')
update(@Param('id') id: string, @Body() updateDryrunDto: UpdateDryrunDto) {
return this.dryrunService.update(+id, updateDryrunDto);
}

@Delete(':id')
remove(@Param('id') id: string) {
return this.dryrunService.remove(+id);
}
}
9 changes: 9 additions & 0 deletions backend/src/dryrun/dryrun.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { DryrunService } from './dryrun.service';
import { DryrunController } from './dryrun.controller';

@Module({
controllers: [DryrunController],
providers: [DryrunService],
})
export class DryrunModule {}
18 changes: 18 additions & 0 deletions backend/src/dryrun/dryrun.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { DryrunService } from './dryrun.service';

describe('DryrunService', () => {
let service: DryrunService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [DryrunService],
}).compile();

service = module.get<DryrunService>(DryrunService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
36 changes: 36 additions & 0 deletions backend/src/dryrun/dryrun.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Injectable } from '@nestjs/common';
import { CreateDryrunDto } from './dto/create-dryrun.dto';
import { UpdateDryrunDto } from './dto/update-dryrun.dto';
import { PrismaService } from 'nestjs-prisma';
import { Prisma } from "@prisma/client";
import { DryrunDto } from './dto/dryrun.dto';

@Injectable()
export class DryrunService {
constructor(
private prisma: PrismaService
) {
}

create(createDryrunDto: CreateDryrunDto) {
console.log("I WILL SEND THE POST FROM HERE!!!");
return 'This action adds a new dryrun';
}

async findAll() {
const files = await this.prisma.file_submissions.findMany();
console.log(files)
}

findOne(id: number) {
return `This action returns a #${id} dryrun`;
}

update(id: number, updateDryrunDto: UpdateDryrunDto) {
return `This action updates a #${id} dryrun`;
}

remove(id: number) {
return `This action removes a #${id} dryrun`;
}
}
13 changes: 13 additions & 0 deletions backend/src/dryrun/dto/create-dryrun.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { PickType } from "@nestjs/swagger";
import { DryrunDto } from "./dryrun.dto";

export class CreateDryrunDto extends PickType(DryrunDto, [
'submission_status_code',
'description',
'display_order',
'active_ind',
'create_user_id',
'create_utc_timestamp',
'update_user_id',
'update_utc_timestamp',
] as const) {}
46 changes: 46 additions & 0 deletions backend/src/dryrun/dto/dryrun.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ApiProperty } from '@nestjs/swagger';

export class DryrunDto {
@ApiProperty({
description: 'Unique identifies for the submitted file',
// default: '9999',
})
submission_status_code: string;

@ApiProperty({
description: 'Full name of the code',
// default: 'username',
})
description: string;

@ApiProperty({
description: 'Order in which the code appears',
})
display_order: number;

@ApiProperty({
description: 'True if active, false otherwise',
default: true,
})
active_ind: boolean

@ApiProperty({
description: 'The id of the user that created the record',
})
create_user_id: string;

@ApiProperty({
description: 'When the user created the record',
})
create_utc_timestamp: Date;

@ApiProperty({
description: 'The id of the user that last updated the record',
})
update_user_id: string;

@ApiProperty({
description: 'When the user last updated the record',
})
update_utc_timestamp: Date;
}
3 changes: 3 additions & 0 deletions backend/src/dryrun/dto/update-dryrun.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CreateDryrunDto } from './create-dryrun.dto';

export class UpdateDryrunDto extends CreateDryrunDto {}
1 change: 1 addition & 0 deletions backend/src/dryrun/entities/dryrun.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class Dryrun {}
7 changes: 0 additions & 7 deletions backend/src/users/dto/create-user.dto.ts

This file was deleted.

3 changes: 0 additions & 3 deletions backend/src/users/dto/update-user.dto.ts

This file was deleted.

21 changes: 0 additions & 21 deletions backend/src/users/dto/user.dto.ts

This file was deleted.

Loading
Loading