postgresql - 为什么重新生成的 Postgres 表会在 Vapor 中引发错误?
问题描述
生产环境中的表是这样创建的:
-- DDL generated by Postico 1.5.10
-- Not all database features are supported. Do not use for backup.
-- Table Definition ----------------------------------------------
CREATE TABLE "TempUser" (
id bigint PRIMARY KEY,
"Uuid" text NOT NULL,
"dateCreated" timestamp without time zone NOT NULL,
"lastRequestDate" timestamp without time zone NOT NULL,
"lastRequestLocation" text,
"numOfRequest" bigint NOT NULL,
comment text NOT NULL,
"lastRequestDescription" text NOT NULL,
"bookedSeats" text NOT NULL,
"bookUntil" timestamp without time zone,
"lastEventVisited" text
);
-- Indices -------------------------------------------------------
CREATE UNIQUE INDEX "pk:TempUser.id" ON "TempUser"(id int8_ops);
为什么我在dev
环境中删除表并在 Postgres 控制台中创建这样的表,尝试以编程方式编写后出现以下错误:
[ ERROR ] PostgreSQLError.server.error.ExecConstraints: POST /registerTempUser null value in column "id" violates not-null constraint (ErrorMiddleware.swift:26)
[ DEBUG ] Possible causes for PostgreSQLError.server.error.ExecConstraints: Failing row contains (null, 015574220836500, 2020-07-09 19:42:36.803846, 2020-07-09 19:42:36.803846, null, 1, , POST /registerTempUser HTTP/1.1
Host: localhost:8080
Content-Typ..., [], null, null). (ErrorMiddleware.swift:26)
为什么,怎么了?
尝试设置序列的东西:
select setval(pg_get_serial_sequence('"TempUser"', 'id'), 1);
select currval(pg_get_serial_sequence('"TempUser"', 'id'));
没有改变。
解决方案
推荐阅读
- tableau-api - 在 Tableau 中计算两个日期的两个百分比之间的百分比差异
- assembly - 我需要对一个字符串(AZ)进行桶排序并在汇编中打印它
- java - 如何在服务上获取 websocket 会话?
- google-sheets - 总和在 arrayformula 旁边的列中不起作用
- javascript - 尝试使用 JS 将 JSON 发布到 PHP 时出现错误 404
- python - 创建一个列,该列是从另一列中提取的特定日期之后的一组列中的日期数的总和
- swift - 在路径 SwiftLint 中找不到可删除的文件
- zsh - zsh条件表达式中的-a和-e有什么区别?
- javascript - 在我的谷歌地图上获得菱形水印
- javascript - 如何使用editMode,单击编辑按钮时信息消失