fix: wrong data type

This commit is contained in:
Methapon2001 2024-06-07 13:54:02 +07:00
parent 2c134aa68a
commit 23f52b137d
4 changed files with 30 additions and 15 deletions

View file

@ -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;

View file

@ -349,7 +349,7 @@ model Customer {
model CustomerBranch { model CustomerBranch {
id String @id @default(uuid()) id String @id @default(uuid())
branchNo String branchNo Int
legalPersonNo String legalPersonNo String
name String name String
@ -387,8 +387,8 @@ model CustomerBranch {
jobPositionEN String jobPositionEN String
jobDescription String jobDescription String
saleEmployee String saleEmployee String
payDate String payDate DateTime
wageDate String wageDate DateTime
status Status @default(CREATED) status Status @default(CREATED)

View file

@ -60,8 +60,8 @@ export type CustomerBranchCreate = {
jobPositionEN: string; jobPositionEN: string;
jobDescription: string; jobDescription: string;
saleEmployee: string; saleEmployee: string;
payDate: string; payDate: Date;
wageDate: string; wageDate: Date;
subDistrictId?: string | null; subDistrictId?: string | null;
districtId?: string | null; districtId?: string | null;
@ -95,8 +95,8 @@ export type CustomerBranchUpdate = {
jobPositionEN?: string; jobPositionEN?: string;
jobDescription?: string; jobDescription?: string;
saleEmployee?: string; saleEmployee?: string;
payDate?: string; payDate?: Date;
wageDate?: string; wageDate?: Date;
subDistrictId?: string | null; subDistrictId?: string | null;
districtId?: string | null; districtId?: string | null;
@ -262,7 +262,7 @@ export class CustomerBranchController extends Controller {
}, },
data: { data: {
...rest, ...rest,
branchNo: `${count + 1}`, branchNo: count + 1,
customer: { connect: { id: customerId } }, customer: { connect: { id: customerId } },
province: { connect: provinceId ? { id: provinceId } : undefined }, province: { connect: provinceId ? { id: provinceId } : undefined },
district: { connect: districtId ? { id: districtId } : undefined }, district: { connect: districtId ? { id: districtId } : undefined },

View file

@ -56,8 +56,8 @@ export type CustomerCreate = {
jobPositionEN: string; jobPositionEN: string;
jobDescription: string; jobDescription: string;
saleEmployee: string; saleEmployee: string;
payDate: string; payDate: Date;
wageDate: string; wageDate: Date;
subDistrictId?: string | null; subDistrictId?: string | null;
districtId?: string | null; districtId?: string | null;
@ -98,8 +98,8 @@ export type CustomerUpdate = {
jobPositionEN: string; jobPositionEN: string;
jobDescription: string; jobDescription: string;
saleEmployee: string; saleEmployee: string;
payDate: string; payDate: Date;
wageDate: string; wageDate: Date;
subDistrictId?: string | null; subDistrictId?: string | null;
districtId?: string | null; districtId?: string | null;
@ -281,7 +281,7 @@ export class CustomerController extends Controller {
data: data:
customerBranch?.map((v, i) => ({ customerBranch?.map((v, i) => ({
...v, ...v,
branchNo: `${i + 1}`, branchNo: i + 1,
createdBy: req.user.name, createdBy: req.user.name,
updateBy: req.user.name, updateBy: req.user.name,
})) || [], })) || [],
@ -396,14 +396,14 @@ export class CustomerController extends Controller {
where: { id: v.id || "" }, where: { id: v.id || "" },
create: { create: {
...v, ...v,
branchNo: `${i + 1}`, branchNo: i + 1,
createdBy: req.user.name, createdBy: req.user.name,
updateBy: req.user.name, updateBy: req.user.name,
id: undefined, id: undefined,
}, },
update: { update: {
...v, ...v,
branchNo: `${i + 1}`, branchNo: i + 1,
updateBy: req.user.name, updateBy: req.user.name,
}, },
})), })),