So I am using typeorm with ormconfig.json.
Since synchronize cannot be used in production, how can I run the migrations based on entities?
my ormconfig.json file
{
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "",
"password": "",
"database": "backend-api",
"synchronize": false,
"logging": true,
"migrationsRun": true,
"entities": ["dist/entity/**/*.js"],
"migrations": ["dist/migration/**/*.js"],
"subscribers": ["dist/subscriber/**/*.js"],
"cli": {
"entitiesDir": "src/entity",
"migrationsDir": "src/migration",
"subscribersDir": "src/subscriber"
}
}
Also here is my only Todo.ts entity file
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
@Entity()
export class Todo extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column('text')
text: string;
@Column('boolean', { default: false })
completed: boolean;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
}