使用 postgres 数据库,我能够连接到数据库,但是即使按照教程一步一步,在创建 user.entity.ts 文件(下面的代码)后,数据库中没有任何变化。
据我所知,最新版本的 postgres/typeorm 已正确安装。
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
@Entity()
export class Users {
@PrimaryGeneratedColumn('uuid')
id: number
@Column({
length: 50
})
firstName: string;
}
Run Code Online (Sandbox Code Playgroud)
这是 ormconfig.json
{
"type": "postgres",
"host": "localhost",
"port": "5432",
"username": "postgres",
"password": "pw",
"database": "metabook",
"synchronise": true,
"logging": true,
"entities": ["./dist/**/*.entity{.ts,.js}"]
}
Run Code Online (Sandbox Code Playgroud)
它应该添加带有 2 列(id 和 firstName)的“用户”表。在控制台中,日志记录(在 ormconfig.json 中设置为 true)应该显示正在运行的 sql 查询以创建表,但除了成功运行应用程序(下面的输出)之外没有任何其他反应。
有谁知道我是否遗漏了什么?