Blueshift
The Amazon Redshift adapter for Sequel
Installation
Add this line to your application's Gemfile:
gem 'blue-shift'
And then execute:
$ bundle
Or install it yourself as:
$ gem install blue-shift
Usage
create_table Options:
:distkey=> column nameThe Distribution Key. When specified, the :diststyle is set to :key unless otherwise specified
:diststyle=>:even(implicit default),:key, or:allThe Distribution Style. When
:distkeyis also specified, only:keyDISTSTYLE is supported by Redshift.:sortkeys=> a list of column namesThe Sort Keys. Depending on your
:sortstyle, there is a maximum number of sortkeys that you can specify: Compound: up to 400 sortkeys Interleaved: up to 8 sortkeys:sortstyle=>:compound(default) or:interleavedThe Sort Style. This option has no effect unless
:sortkeysis also specified
For example:
create_table :chocolates, distkey: :region, diststyle: :all, sortkeys: [:richness, :organic], sortstyle: :interleaved do
String :region
Integer :richness
boolean :organic
String :description
end
Migrations (coming soon)
Blueshift unifies migrations for your Postgres and Redshift databases into one file. Postgres migrations and Redshift migrations use Sequel.
Blueshift.migration do
up do
# applies to Postgres only
end
down do
# applies to Postgres only
end
redup do
# applies to Redshift only
end
reddown do
# applies to Redshift only
end
end
If you want your migration to only run on Postgres, you can specify an empty block:
Blueshift.migration do
up do
# applies to Postgres only
end
down do
# applies to Postgres only
end
redup {}
reddown {}
end
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/influitive/blueshift.