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

Add unique id to record table #92

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
22,077 changes: 0 additions & 22,077 deletions package-lock.json

This file was deleted.

2 changes: 2 additions & 0 deletions packages/client/src/graphql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ export type RecordInsertOrUpdateModel = {
date: Scalars['DateTime'];
employeeId: Scalars['ID'];
hours: Scalars['Float'];
id?: Maybe<Scalars['String']>;
projectId: Scalars['ID'];
};

Expand All @@ -547,6 +548,7 @@ export type RecordModel = {
employee: EmployeeModel;
employeeId: Scalars['ID'];
hours: Scalars['Float'];
id?: Maybe<Scalars['String']>;
project: ProjectModel;
projectId: Scalars['ID'];
};
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/graphql/record/record.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mutation deleteRecord($input: RecordDeleteInput!) {

query getRecordsByDateRange($input: DateRangeInput!) {
getRecordsByDateRange(input: $input) {
id
date
hours
employee {
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/graphql/record/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type GetRecordsByDateRangeQuery = {
__typename?: 'Query';
getRecordsByDateRange: Array<{
__typename?: 'RecordModel';
id?: string | null;
date: any;
hours: number;
employee: { __typename?: 'EmployeeModel'; name: string };
Expand Down Expand Up @@ -107,6 +108,7 @@ export type DeleteRecordMutationOptions = Apollo.BaseMutationOptions<DeleteRecor
export const GetRecordsByDateRangeDocument = gql`
query getRecordsByDateRange($input: DateRangeInput!) {
getRecordsByDateRange(input: $input) {
id
date
hours
employee {
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/pages/Report/components/MoreOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ export const MenuOptions: FC<MenuOptionsProps> = ({ startDate, endDate }) => {
setAnchorEl(null);
};

console.log(data?.getRecordsByDateRange);

const formattedData =
data?.getRecordsByDateRange.map((record) => {
return {
id: record.id,
date: record.date,
employee: record.employee.name,
project: record.project.name,
Expand All @@ -47,6 +46,7 @@ export const MenuOptions: FC<MenuOptionsProps> = ({ startDate, endDate }) => {
}) ?? [];

const headers = [
{ label: 'ID', key: 'id' },
{ label: 'Date', key: 'date' },
{ label: 'Employee', key: 'employee' },
{ label: 'Project', key: 'project' },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Record" ADD COLUMN "id" TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:

- A unique constraint covering the columns `[id]` on the table `Record` will be added. If there are existing duplicate values, this will fail.

*/
-- CreateIndex
CREATE UNIQUE INDEX "Record_id_key" ON "Record"("id");
1 change: 1 addition & 0 deletions packages/server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ model Project {
}

model Record {
id String? @default(uuid()) @unique()
date DateTime @db.Date
employeeId String
employee Employee @relation(fields: [employeeId], references: [id])
Expand Down
3 changes: 3 additions & 0 deletions packages/server/src/record/model/record.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { ProjectModel } from '../../project/model/project.model';

@ObjectType()
export class RecordInsertOrUpdateModel {
@Field(() => String, { nullable: true })
id: string | null;

@Field(() => ID)
employeeId: string;

Expand Down
2 changes: 2 additions & 0 deletions packages/server/src/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type ProjectDeleteReturnModel {
}

type RecordInsertOrUpdateModel {
id: String
employeeId: ID!
projectId: ID!
date: DateTime!
Expand All @@ -123,6 +124,7 @@ type GroupedRecordWithFavoriteProjectModel {
}

type RecordModel {
id: String
employeeId: ID!
projectId: ID!
date: DateTime!
Expand Down
Loading