I'm migrating from MySQL to Postgres using mysqldump and psql and getting this error:
ERROR: date/time field value out of range: "0000-00-00 00:00:00" at character 52 STATEMENT: INSERT INTO "cron" VALUES (1,'2015-07-11 05:21:40','0000-00-00 00:00:00',2,58,'updateBid','plus',NULL,NULL),(2,'2015-07-11 05:21:40','0000-00-00
The MySQL table looks like
CREATE TABLE "cron" (
"id" int(11) NOT NULL,
"execute_after" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"executed_at" timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
The Postgres table looks like this:
CREATE TABLE "cron" (
"id" int NOT NULL,
"execute_after" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"executed_at" timestamp,
How can I automatically import this field?
executed_atis nullable in Postgres, but not in MySQL) that you wish for such zero values to becomeNULLin Postgres? If so, you could either search/replace in the.sqlfile; or first update the data in MySQL before exporting (perhaps by copying the data into a temporary table if you don't wish to alter the original).