【发布时间】:2021-11-25 17:11:49
【问题描述】:
我正在尝试将我的 API(使用 ASP .NET Core)部署到 Heroku,但它在部署时返回此错误:“关系用户已存在”。 谁能告诉我我在哪里做错了? 提前致谢
这是我的迁移代码和我得到的错误:
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Username = table.Column<string>(type: "text", nullable: true),
Password = table.Column<string>(type: "text", nullable: true),
FirstName = table.Column<string>(type: "text", nullable: true),
LastName = table.Column<string>(type: "text", nullable: true),
BirthDay = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
Phone = table.Column<string>(type: "text", nullable: true),
Role = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_User", x => x.Id);
});
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "BirthDay", "FirstName", "LastName", "Password", "Phone", "Role", "Username" },
values: new object[] { new Guid("00000000-0000-0000-0000-000000000001"), new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Admin", "01", "d34b21af1ebb547742f2a78124c73764", null, 2, "admin" });
}
这里有错误:
创建表“用户”( 2021-11-25T17:00:20.844160+00:00 app[web.1]: "Id" uuid NOT NULL,
2021-11-25T17:00:20.844164+00:00 app[web.1]:“用户名”文本 NULL,
2021-11-25T17:00:20.844164+00:00 app[web.1]:“密码”文本 NULL,
2021-11-25T17:00:20.844164+00:00 app[web.1]: "FirstName" text NULL,
2021-11-25T17:00:20.844164+00:00 app[web.1]: "LastName" text NULL,
2021-11-25T17:00:20.844165+00:00 app[web.1]: 没有时区的“生日”时间戳不为空,
2021-11-25T17:00:20.844165+00:00 app[web.1]:“电话”文本 NULL,
2021-11-25T17:00:20.844165+00:00 app[web.1]:“角色”整数 NOT NULL,
2021-11-25T17:00:20.844165+00:00 app[web.1]:约束“PK_User”主键(“Id”)
2021-11-25T17:00:20.844166+00:00 app[web.1]:);
2021-11-25T17:00:20.857104+00:00 app[web.1]:未处理的异常。 Npgsql.PostgresException (0x80004005): 42P07: 关系“用户”已经存在
【问题讨论】:
标签: asp.net-core heroku relational-database web-deployment