Reputation: 2666
My Mysql schema for a database table is given below, which is generated by using the following command
npx ampx generate schema-from-database --connection-uri-secret SQL_CONNECTION_STRING --out amplify/data/schema.sql.ts
schema({
"user_profiles": a.model({
id: a.integer().required(),
email: a.string(),
profile_owner: a.string(),
user_type: a.string(),
}).identifier([
"id"
])
});
My requirement is to add details to user_profiles table in mysql table inside PreSignUpTriggerHandler of cognito registration flow. The problem is that , I need to get the primary key as autoincremented, But I couldn'nt make that, It is asking that the id field should be mandatory My handler code is given below, Can someone help me out to figure out this issue
export const handler: PreSignUpTriggerHandler = async (event) => {
await client.models.UserProfile.create({
id: 1, //This should be auto incremented
email: event.request.userAttributes.email,
user_type: event.request.userAttributes['custom:user_type'],
profile_owner: `${event.userName}`,
});
}
Upvotes: 0
Views: 18