最近在有JS写一个Web Application,于是就用到了这个数据库。记录一下,Travis与Postgres的配置
首先,我们需要将postgresql的addons添加到.travis.yml
addons:
postgresql: "9.3"
接着我们创建一个before_script,也就是我们在测试之前会跑的命令
before_script:
- psql -c 'create database travis_ci_test;' -U postgres
于是,我们就需要导入数据库
before_script:
- psql -c 'create database travis_ci_test;' -U postgres
- psql -U postgres -q -d travis_ci_test -f db/init.sql
由于原来的数据库是migrations完成的,所以在那之前我们需要导出数据
pg_dump -U postgres -f db/init.sql
我们就可以在CI上看到
0.25s$ psql -c "create database travis_ci_test" -U postgres
CREATE DATABASE
before_script.2
0.07s$ psql -U postgres -q -d travis_ci_test -f db/init.sql
围观我的Github Idea墙, 也许,你会遇到心仪的项目