'Typeorm - Disable default creation of columns id, createdAt, updatedAt when entity is synced
I am using typeorm with nest.js and I have a session entity like the below
import { Column, Entity, PrimaryColumn } from 'typeorm';
@Entity('session')
export class Session {
@PrimaryColumn('varchar', { length: 255 })
sid: string;
@Column('jsonb')
sess: JSON;
@Column('timestamptz', { nullable: true })
expire: string;
}
Whenever I start the server I have enabled synchronize: true in the configuration.
This is creating a table like the below, with id, createdAt, updatedAt being created by default even though not mentioned in the entity schema.
How to disable this default creation of (id, createdAt, updatedAt)columns and restrict the table to be created with only the columns I have mentioned in the entity?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

