我们假设我使用pgloader将MySQL数据库迁移到PostgreSQL,使用official website上的默认样本:
load database
from mysql://root@localhost/sakila
into postgresql:///sakila
WITH include drop, create tables, no truncate,
create indexes, reset sequences, foreign keys
SET maintenance_work_mem to '128MB', work_mem to '12MB', search_path to 'sakila'
CAST type datetime to timestamptz
drop default drop not null using zero-dates-to-null,
type date drop not null drop default using zero-dates-to-null
MATERIALIZE VIEWS film_list, staff_list
-- INCLUDING ONLY TABLE NAMES MATCHING ~/film/, 'actor'
-- EXCLUDING TABLE NAMES MATCHING ~<ory>
BEFORE LOAD DO
$$ create schema if not exists sakila; $$;
我们还假设在表格中,我有一个专栏&#39; bar&#39;使用DATETIME类型,我想设置一个新的默认值&#39; 2015-01-01 00:00:00&#39;当我将它迁移到PostgreSQL时(MySQL中的旧默认值是&#39; 0000-00-00 00:00:00&#39;)
如何在pgloader迁移脚本中定义它?我在CAST关键字之后尝试了以下行,但它在这里抛出错误:
column foo.bar to timestamp set default "2015-01-01 00:00:00",
^ (Could not parse WHITESPACE)
我无法在reference docs中找到有关默认值的任何内容。