【发布时间】:2020-10-23 20:56:51
【问题描述】:
当尝试使用 prisma CLI 的 prisma import --data export.<DATE>.zip 将数据导入到 postgres 数据库时,它会失败并显示 postgresql 数据库中所有关系的错误:
我必须先运行prisma deploy 以确保架构已更新,但当它导入数据时,它会尝试两次导入关系,这违反了某种重复约束。
"Failure inserting into relationtable _ExampleForOtherExample with ids StringIdGCValue(ckamscvpi0eo00702ep0c7log) and StringIdGCValue(cka2n025p03ri0766hnoyxf8s). Cause: insert or update on table \"_ExampleForOtherExample\" violates foreign key econstraint \"_ExampleForOtherExample_A_fkey\"\n Detail: Key (A)=(cjvba054700dz07236tafuscj) is not present in table \"Example\".",
"Failure inserting into relationtable _ThingToOtherThing with ids StringIdGCValue(ckbgyi96h0kl1079500z24pwu) and StringIdGCValue(ckbkvgde606s50855g62uhqsb). Cause: duplicate key value violates unique constraint \"_ThingToOtherThing_AB_unique\"\n Detail: Key (\"A\", \"B\")=(ck3kbmjgl036x0788furaqxkg, ck6uvgy7o09p40723rw34tna1) already exists.",
我不确定为什么它会导入除关系之外的所有内容。
(棱镜版本 1.30.5)
【问题讨论】:
-
作为一种解决方法,我能够使用 pg_dump 和 pg_restore 代替 prisma 导出和 prisma 导入。但 prisma 导入每次都失败。
标签: postgresql import database-migration prisma prisma-graphql