Skip to content

Commit

Permalink
[sqitch_pg] Add the sqitch_pg core plan, which provides sqitch ready …
Browse files Browse the repository at this point in the history
…to use with PostgreSQL

Signed-off-by: Irving Popovetsky <irving@chef.io>
  • Loading branch information
Irving Popovetsky committed May 9, 2018
1 parent 4ad256a commit 5e9b470
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .bldr.toml
Expand Up @@ -1016,6 +1016,8 @@ plan_path = "socat"
plan_path = "spark"
[sqitch]
plan_path = "sqitch"
[sqitch_pg]
plan_path = "sqitch_pg"
[sqlite]
plan_path = "sqlite"
[sshpass]
Expand Down
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -154,6 +154,8 @@ protobuf-cpp @afiune
rabbitmqadmin @predominant
redis @irvingpop
shared-mime-info @rsertelon
sqitch @irvingpop
sqitch_pg @irvingpop
sqlserver @mwrock
sqlserver-ha-ag @mwrock
vault @defilan
Expand Down
24 changes: 24 additions & 0 deletions sqitch_pg/README.md
@@ -0,0 +1,24 @@
# sqitch_pg
This is a Habitat plan for [Sqitch](http://sqitch.org/) with [DBD-Pg](http://search.cpan.org/dist/DBD-Pg/) which is used to do database deploys to PostgreSQL.

## Maintainers
The Habitat Maintainers humans@habitat.sh

## Type of Package

This is a hybrid binary + library package, designed to make it easy to install Sqitch for PostgreSQL with a single package definition.

## Usage

Install this package by running:
```
hab pkg install -b core/sqitch_pg
```

Run this package like so:
```
cd your_schema_folder
hab pkg exec core/sqitch_pg sqitch --engine pg deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"
```

For a complete example, see [this db-migrations script](https://github.com/chef/chef-server/blob/master/src/bookshelf/habitat/config/database-migrations.sh)
36 changes: 36 additions & 0 deletions sqitch_pg/plan.sh
@@ -0,0 +1,36 @@
pkg_name=sqitch_pg
pkg_origin=core
pkg_version="3.7.4"
pkg_maintainer="The Habitat Maintainers humans@habitat.sh"
pkg_license=('Artistic-1.0-Perl' 'GPL-2.0')
pkg_deps=(
core/glibc
core/perl
core/postgresql-client
core/zlib
core/sqitch
)
pkg_build_deps=(
core/cpanminus
core/local-lib
core/gcc
core/make
)
pkg_description="Sqitch the database management application, bundled with the DBD::Pg Perl module for PostgreSQL"
pkg_upstream_url="http://sqitch.org/" # Note: also http://search.cpan.org/dist/DBD-Pg/
pkg_bin_dirs=(bin)

do_setup_environment() {
push_runtime_env PERL5LIB "${pkg_prefix}/lib/perl5/x86_64-linux-thread-multi"
}

do_build() {
return 0
}

do_install() {
source <(perl -I"$(pkg_path_for core/local-lib)/lib/perl5" -Mlocal::lib="$(pkg_path_for core/local-lib)")
source <(perl -I"$(pkg_path_for core/cpanminus)/lib/perl5" -Mlocal::lib="$(pkg_path_for core/cpanminus)")
source <(perl -Mlocal::lib="$pkg_prefix")
cpanm "DBD::Pg@$pkg_version" --local-lib "$pkg_prefix"
}

0 comments on commit 5e9b470

Please sign in to comment.