Я пытаюсь обновить свою базу данных, используя сущности с отдельным определением сущности.
База данных не обновляется ни с помощью параметра synchronize = true, ни с помощью команды:
ts-node ./node_modules/typeorm/cli.js migration:generate -n CreateDatabase
который генерирует пустой файл миграции.
Что я забыл?
Шаги для воспроизведения или небольшой репозиторий, показывающий проблему:
ormconfig. json
{
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "postgres",
"password": "secret",
"database": "app",
"entities": ["src/**/entities/*.entity.ts"],
"migrations": ["src/database/migrations/*.ts"],
"cli": {
"migrationsDir": "src/database/migrations"
},
"synchronize": true
}
topi c .entity.ts
export class Topic {
title: string
}
topic.schema.ts
import { EntitySchema, EntitySchemaColumnOptions } from 'typeorm'
import { Topic} from '../topic.entity'
export const TopicSchema = new EntitySchema<Topic>({
name: 'topics',
target: Topic,
columns: {
title: {
name: 'title',
type: 'text',
nullable: true,
} as EntitySchemaColumnOptions,
},
})