How to create postgresql serial type primary key when auto-migrate
This is my user model,
@model() export class User extends Entity { @property({ type: 'number', id: true, }) id?: number;
@property({ type: 'string', required: true, }) user_name: string; @property({ type: 'string', required: false, }) role: string;
@property({ type: 'string', required: true, }) password: string;
When i'm run "npm run migrate -- --rebuild" it creates primary key data type as "integer" in postgresql. Then primary key is not auto increment. Because "npm run migrate " create user table primary key data type as "integer". I want to make it as "SERIAL" type. Could you please tel me how do i resolve this problem.
Add the generated property.
@property({ id: true, index: true, generated: true, })
Try using the search function in future. It might be found quickly.
It works....!!! Thanks for your quick response.