https://github.com/kwakwaversal/test-postgresql-sqitch
Test PostgreSQL features to make sure they do what's expected - the http://sqitch.org/ way!
https://github.com/kwakwaversal/test-postgresql-sqitch
postgresql sqitch
Last synced: 25 days ago
JSON representation
Test PostgreSQL features to make sure they do what's expected - the http://sqitch.org/ way!
- Host: GitHub
- URL: https://github.com/kwakwaversal/test-postgresql-sqitch
- Owner: kwakwaversal
- Created: 2017-10-22T19:56:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-04T08:39:04.000Z (about 6 years ago)
- Last Synced: 2025-02-28T22:21:45.957Z (over 1 year ago)
- Topics: postgresql, sqitch
- Language: PLpgSQL
- Homepage:
- Size: 42 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
Awesome Lists containing this project
README
# test-postgresql-sqitch [](https://travis-ci.org/kwakwaversal/test-postgresql-sqitch)
Test PostgreSQL features to make sure they do what's expected
# Description
Over time there have been PostgreSQL-specific features I've wanted to check.
The first one was to make sure [citext] was doing what I expect it to do.
N.B., I am using [Sqitch] for testing.
# Tests
## [citext]
The [citext] module provides a case-insensitive character string type, `citext`.
Essentially, it internally calls `lower()` when comparing values. Otherwise, it
behaves almost exactly like `text`.
The tests make sure it does this, and that an index is used appropriately.
## [constraints]
Makes sure that constraints are doing what I expect them to do. This is not
complete, but I will expand on the tests as and when I need them.
# Using Sqitch
This repository is also an excuse for me to use [Sqitch]. Sqitch is a database
change management application. The `verify` feature makes it particularly useful
when combined with [Github] and [Travis].
N.B., It is *not* best practice to use [Sqitch] in this way because the `verify`
command should contain tests without any regard for data.
## Commands
Initialise a new project.
```
sqitch init testing --uri https://github.com/kwakwaversal/test-postgresql-sqitch --engine pg
```
Tell [Sqitch] who we are (used for the plan's audit trail). The `--user` flag
means that this particular config will be written to the executing user's
`~/.sqitch/sqitch.conf` file.
```
sqitch config --user user.name 'Paul Williams'
sqitch config --user user.email 'kwakwaversal@...'
```
Add a new database *change*.
```
sqitch add extensions -n 'Add Pg extensions (CITEXT)'
sqitch add citext --requires extensions -n 'Add CITEXT test'
```
### Deploy, Verify, Revert
These commands assume you're running them from within the vagrant VM which is
provisioned from the `Vagrantfile`.
```
sqitch deploy db:pg://super_sqitch_user:password@localhost/sqitch
sqitch verify db:pg://super_sqitch_user:password@localhost/sqitch
sqitch revert db:pg://super_sqitch_user:password@localhost/sqitch
```
# References
* [Sqitch turorial](https://metacpan.org/pod/distribution/App-Sqitch/lib/sqitchtutorial.pod)
* [Default Pg constraint names](https://stackoverflow.com/a/4108266/1182273)
* [Managing key/value pairs](https://justatheory.com/2010/08/postgres-key-value-pairs/)
[citext]: https://www.postgresql.org/docs/current/static/citext.html
[constraints]: https://www.postgresql.org/docs/current/static/ddl-constraints.html
[Github]: https://github.com/
[Sqitch]: http://sqitch.org/
[Travis]: https://travis-ci.org/