【问题标题】:Relation already exists while deploying to Heroku部署到 Heroku 时已存在关系
【发布时间】: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


    【解决方案1】:

    最后我解决了这个问题。此错误是由自动迁移数据库引起的。只需放下表格并在 heroku 上重新部署应用程序。

    【讨论】:

      猜你喜欢
      • 2018-10-11
      • 2020-10-02
      • 2015-10-05
      • 1970-01-01
      • 2020-11-02
      • 2021-01-03
      • 2015-08-10
      • 1970-01-01
      • 2013-04-07
      相关资源
      最近更新 更多