Haskell 持久不同步 [英] Haskell Persistent out of sync
问题描述
我正在使用 Yesod 和 Persistent 制作博客(真的很原创,嗯?).
I'm using Yesod and Persistent to make a blog (really original, eh?).
在某个时候,我改变了我的模型,Persistent 说我尝试做的事情不安全,我必须手动完成.它说:
At some point, I changed my model, and Persistent said that what I was trying to do is unsafe, and that I would have to do it manually. It said:
Database migration: manual intervention required.
The following actions are considered unsafe:
ALTER TABLE "article" DROP COLUMN "date";
所以我继续在 Postgres 中运行它.事实上,我已经继续删除表文章",我得到了错误:
So I went ahead and ran that in Postgres. In fact, I have gone ahead and dropped the table "article", and I get the error:
Migrating: CREATe TABLE "article"
( "id" SERIAL PRIMARY KEY UNIQUE,
"title" VARCHAR NOT NULL,
"author" VARCHAR NOT NULL,
"day" DATE NOT NULL DEFAULT DATE,
"content" VARCHAR NOT NULL)
devel.hs: SqlError { sqlState = "42703"
, sqlExecStatus = FatalError
, sqlErrorMsg = "column \"date\" does not exist"
, sqlErrorDetail = ""
, sqlErrorHint = ""
}
以下是架构当前的外观(使用 Persistent 定义):
Here is how the schema currently looks (as defined using Persistent):
-- Blog Article
Article
title Text
author Text
day Day default=DATE
content MathJax
这里发生了什么?我该怎么做才能让 Postgres 和 Persistent 重新同步?
What is going on here? What do I have to do to get Postgres and Persistent back in sync?
推荐答案
请将您的创建表代码更改为:
please change your create table code to :
digoal=# CREATE TABLE "article"
( "id" SERIAL PRIMARY KEY UNIQUE,
"title" VARCHAR NOT NULL,
"author" VARCHAR NOT NULL,
"day" DATE NOT NULL DEFAULT current_date,
"content" VARCHAR NOT NULL);
CREATE TABLE
PostgreSQL 没有 DATA 函数,所以你可以用 current_date 代替.
PostgreSQL no DATA function, so you can use current_date instead.
这篇关于Haskell 持久不同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!