【发布时间】:2018-05-01 10:17:10
【问题描述】:
我正在尝试为我的应用创建一些集成测试,
其中一部分我想每次都播种我的应用程序
测试运行。然而,数据库需要保持连接,
所以dropdb / createdb 不是一个选项。
我目前正在做:
pg_dump -F custom -O -x -d test-db > ./tests/test-db
测试前,并且:
pg_restore --clean -d test-db ./tests/test-db
在每次测试运行后恢复数据库。
这似乎不起作用,因为pg_restore 命令会引发很多错误:
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 3771; 2618 175960 RULE skilled_outcome_group _RETURN dan
pg_restore: [archiver (db)] could not execute query: ERROR: cannot drop rule _RETURN on view public.skilled_outcome_group because view public.skilled_outcome_group requires it
pg_restore: [archiver (db)] Error from TOC entry 184; 1259 174070 TABLE outcome_group_skill dan
pg_restore: [archiver (db)] could not execute query: ERROR: cannot drop table public.outcome_group_skill because other objects depend on it
它就这样继续下去......我以为--clean 是为了彻底放弃一切,
但是pg_restore 抱怨它不能删除表/视图?我在 pg_dump / pg_restore 中的标志组合有问题吗?
【问题讨论】:
标签: postgresql testing database-restore