I made a migration from string to string[] for the academicProgram field
model Users {
userId Float @unique //since those are big integers, use float to not be limited in size!
userEmail String
userName String
userLabels String?
country String
academicProgram String[] //it returns null sometimes, make it @default("")??
//relations (to another model):
answers Answers[]
}
This is my userservice. Everything is fine in dev mode. I can create users in db normally. The issue comes in deployment mode.
async create(createUserInput: CreateUserInput) {
try {
//the create command it does return the user created as compare to the createMany command
const newUser = await this.prismaClient.users.create({
data: createUserInput,
});
return newUser;
} catch (error) {
console.log(error);
throw Error(error);
}
}
Basically render throws this error: Type ‘string[]’ is not assignable to type ‘string’.
src/modules/users/users.service.ts:27:9 - error TS2322: Type '{ country: string; userEmail: string; userId: number; userName: string; academicProgram: string[]; userLabels: string; }[]' is not assignable to type 'UsersCreateManyInput | UsersCreateManyInput[]'.
Type '{ country: string; userEmail: string; userId: number; userName: string; academicProgram: string[]; userLabels: string; }[]' is not assignable to type 'UsersCreateManyInput[]'.
Type '{ country: string; userEmail: string; userId: number; userName: string; academicProgram: string[]; userLabels: string; }' is not assignable to type 'UsersCreateManyInput'.
Types of property 'academicProgram' are incompatible.
Type 'string[]' is not assignable to type 'string'.
27 data: createManyUsersInput.manyUsersInput.map((x) => ({
~~~~
node_modules/.prisma/client/index.d.ts:4041:5
4041 data: UsersCreateManyInput | UsersCreateManyInput[]
~~~~
The expected type comes from property 'data' which is declared here on type '{ select?: UsersSelectCreateManyAndReturn<DefaultArgs>; data: UsersCreateManyInput | UsersCreateManyInput[]; skipDuplicates?: boolean; }'
It looks like it still working with the string field from previous migration.
But everything seems to be updated in the node_modules/prisma/client/index.d.ts file:
/**
* Users create
*/
export type UsersCreateArgs<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the Users
*/
select?: UsersSelect<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: UsersInclude<ExtArgs> | null
/**
* The data needed to create a Users.
*/
data: XOR<UsersCreateInput, UsersUncheckedCreateInput>
}
export type UsersCreateManyInput = {
userId: number
userEmail: string
userName: string
userLabels?: string | null
country: string
academicProgram?: UsersCreateacademicProgramInput | string[]
}
export type UsersCreateacademicProgramInput = {
set: string[]
}
Here is my migration file:
-- AlterTable
ALTER TABLE "Users" DROP COLUMN "academicProgram",
ADD COLUMN "academicProgram" TEXT[];