diff --git a/prisma/migrations/20240607065019_update_data_type/migration.sql b/prisma/migrations/20240607065019_update_data_type/migration.sql new file mode 100644 index 0000000..b72dc89 --- /dev/null +++ b/prisma/migrations/20240607065019_update_data_type/migration.sql @@ -0,0 +1,15 @@ +/* + Warnings: + + - Changed the type of `branchNo` on the `CustomerBranch` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. + - Changed the type of `payDate` on the `CustomerBranch` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. + - Changed the type of `wageDate` on the `CustomerBranch` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. + +*/ +-- AlterTable +ALTER TABLE "CustomerBranch" DROP COLUMN "branchNo", +ADD COLUMN "branchNo" INTEGER NOT NULL, +DROP COLUMN "payDate", +ADD COLUMN "payDate" TIMESTAMP(3) NOT NULL, +DROP COLUMN "wageDate", +ADD COLUMN "wageDate" TIMESTAMP(3) NOT NULL; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 9d562fa..d00c514 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -349,7 +349,7 @@ model Customer { model CustomerBranch { id String @id @default(uuid()) - branchNo String + branchNo Int legalPersonNo String name String @@ -387,8 +387,8 @@ model CustomerBranch { jobPositionEN String jobDescription String saleEmployee String - payDate String - wageDate String + payDate DateTime + wageDate DateTime status Status @default(CREATED) diff --git a/src/controllers/customer-branch-controller.ts b/src/controllers/customer-branch-controller.ts index 6e90c2e..d9feddc 100644 --- a/src/controllers/customer-branch-controller.ts +++ b/src/controllers/customer-branch-controller.ts @@ -60,8 +60,8 @@ export type CustomerBranchCreate = { jobPositionEN: string; jobDescription: string; saleEmployee: string; - payDate: string; - wageDate: string; + payDate: Date; + wageDate: Date; subDistrictId?: string | null; districtId?: string | null; @@ -95,8 +95,8 @@ export type CustomerBranchUpdate = { jobPositionEN?: string; jobDescription?: string; saleEmployee?: string; - payDate?: string; - wageDate?: string; + payDate?: Date; + wageDate?: Date; subDistrictId?: string | null; districtId?: string | null; @@ -262,7 +262,7 @@ export class CustomerBranchController extends Controller { }, data: { ...rest, - branchNo: `${count + 1}`, + branchNo: count + 1, customer: { connect: { id: customerId } }, province: { connect: provinceId ? { id: provinceId } : undefined }, district: { connect: districtId ? { id: districtId } : undefined }, diff --git a/src/controllers/customer-controller.ts b/src/controllers/customer-controller.ts index 9dbf98d..d227583 100644 --- a/src/controllers/customer-controller.ts +++ b/src/controllers/customer-controller.ts @@ -56,8 +56,8 @@ export type CustomerCreate = { jobPositionEN: string; jobDescription: string; saleEmployee: string; - payDate: string; - wageDate: string; + payDate: Date; + wageDate: Date; subDistrictId?: string | null; districtId?: string | null; @@ -98,8 +98,8 @@ export type CustomerUpdate = { jobPositionEN: string; jobDescription: string; saleEmployee: string; - payDate: string; - wageDate: string; + payDate: Date; + wageDate: Date; subDistrictId?: string | null; districtId?: string | null; @@ -281,7 +281,7 @@ export class CustomerController extends Controller { data: customerBranch?.map((v, i) => ({ ...v, - branchNo: `${i + 1}`, + branchNo: i + 1, createdBy: req.user.name, updateBy: req.user.name, })) || [], @@ -396,14 +396,14 @@ export class CustomerController extends Controller { where: { id: v.id || "" }, create: { ...v, - branchNo: `${i + 1}`, + branchNo: i + 1, createdBy: req.user.name, updateBy: req.user.name, id: undefined, }, update: { ...v, - branchNo: `${i + 1}`, + branchNo: i + 1, updateBy: req.user.name, }, })),