两个postgresSQL数据库对象比对
2015-12-08 22:50
411 查看
1.环境
数据库dev:开发数据库
数据库prod:生成数据库
2.背景
最近在dev上做了大量模型改造,需要把修改的地方同步到生产数据库prod中,但是每一步改动并没有详细的记录,且新增加的对象不能同步上去。
3.实现
pg_dump -h localhost -U dev -T tab1 -T tab2 -s -f dev.dump
pg_dump -h localhost -U prod -T tab1 -T tab2 -s -f prod.dump
利用apgdiff-2.4.jar工具进行两个文件的比对:
java -jar apgdiff-2.4.jar --ignore-start-with prod.dump dev.dump > diff.sql
最后在prod数据库上执行diff.sql文件就可以了。
4.注意
apgdiff-2.4.jar在apgdiff官网可以下载
在导出dump文件的时候使用-T参数是排除表,为什么不用-t指定导出那些表呢?使用-t参数生产的dump文件在进行比对时会报错:
Exception in thread "main" java.lang.NullPointerException
at cz.startnet.utils.pgdiff.parsers.CommentParser.parseColumn(CommentParser.java:272)
at cz.startnet.utils.pgdiff.parsers.CommentParser.parse(CommentParser.java:46)
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:202)
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:239)
at cz.startnet.utils.pgdiff.PgDiff.createDiff(PgDiff.java:36)
at cz.startnet.utils.pgdiff.Main.main(Main.java:45)
这可能是一个bug。Google一下解释是:
as the new bug summary states now, apgdiff currently does not support setting comments on columns that are inherited from other tables, which means in your case that apgdiff fails when it cannot find column xxxx in table main, though it should take it from
main_parent where the column is defined.
数据库dev:开发数据库
数据库prod:生成数据库
2.背景
最近在dev上做了大量模型改造,需要把修改的地方同步到生产数据库prod中,但是每一步改动并没有详细的记录,且新增加的对象不能同步上去。
3.实现
pg_dump -h localhost -U dev -T tab1 -T tab2 -s -f dev.dump
pg_dump -h localhost -U prod -T tab1 -T tab2 -s -f prod.dump
利用apgdiff-2.4.jar工具进行两个文件的比对:
java -jar apgdiff-2.4.jar --ignore-start-with prod.dump dev.dump > diff.sql
最后在prod数据库上执行diff.sql文件就可以了。
4.注意
apgdiff-2.4.jar在apgdiff官网可以下载
在导出dump文件的时候使用-T参数是排除表,为什么不用-t指定导出那些表呢?使用-t参数生产的dump文件在进行比对时会报错:
Exception in thread "main" java.lang.NullPointerException
at cz.startnet.utils.pgdiff.parsers.CommentParser.parseColumn(CommentParser.java:272)
at cz.startnet.utils.pgdiff.parsers.CommentParser.parse(CommentParser.java:46)
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:202)
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:239)
at cz.startnet.utils.pgdiff.PgDiff.createDiff(PgDiff.java:36)
at cz.startnet.utils.pgdiff.Main.main(Main.java:45)
这可能是一个bug。Google一下解释是:
as the new bug summary states now, apgdiff currently does not support setting comments on columns that are inherited from other tables, which means in your case that apgdiff fails when it cannot find column xxxx in table main, though it should take it from
main_parent where the column is defined.
相关文章推荐
- postgreSQL角色权限控制
- 设置外键约束的SQL语句:
- ORACLE预定义角色
- ORACLE角色(通过DBA创建)
- ORACLE权限
- ORACLE用户管理
- MySQL5.6 GTID新特性实践
- ORACLE表空间的创建修改删除
- 数据库连接操作
- MySQL5.6新特性之GTID、多线程复制 - 不知为何
- redis(6)、redis复制
- 连接本地Oracle 11g时 ORA-12514:TNS:监听程序当前无法识别连接描述符中请求的服务
- ORACLE初次安装自动安装软件包
- Linux-MongoDB安装说明
- 经典排序SQL
- 数据库简单查询
- 第一次使用redis看的文章(转)
- mysql瓶颈等
- mysql-5.6.17编译安装和常见问题
- 计算器软件的代码实现 (windowform窗体+SQL+策略模式)