Low commit activity in last 3 years
No release in over a year
A rails migration gem for slony using slonik_execute_script command
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 5.0
>= 0

Runtime

 Project Readme

SlonikMigration

A rails migration gem for slony using slonik_execute_script command.

Dependencies

  • ruby 2.4+
  • activerecord 5.0+
  • slony 2.2+

Installation

Add this line to your application's Gemfile:

gem 'slonik_migration'

Then execute:

$ bundle

Generate config file:

$ bundle exec rails g slonik_migration:config

Configuration

Edit config/slonik.yml.

default: &default
  # enable migration with slonik
  enabled: true

  # slonik command. $SQL is replaced with raw SQL.
  command: slonik_execute_script -c $SQL 1 | sed "s/set id = 1,//" | slonik

  # slonik command for remote server.
  # command: ssh -p 22 user@192.168.0.1 'slonik_execute_script -c $SQL 1 | sed "s/set id = 1,//" | slonik'

  # table/sequence owner.
  owner: owner

development:
  <<: *default

test:
  <<: *default

production:
  <<: *default

Usage

This gem enhances following rails commands:

  • db:migrate
  • db:migrate:up
  • db:migrate:down

You can use migration command as usual:

$ bundle exec rake db:migrate RAILS_ENV=production

If you want to specify config file:

$ bundle exec rake db:migrate RAILS_ENV=production CONFIG=/path/to/slonik.yml

Execution example

Migration command executes slonik_execute_command as the following example:

slonik_execute_script -c CREATE\ TABLE\ \"test_tables\"\ \(\"id\"\ bigserial\ primary\ key,\ \"title\"\ text\) 1 | sed "s/set id = 1,//" | slonik    

Contributing

Bug reports and pull requests are welcome at https://github.com/kanety/slonik_migration.

Reference

This gem is inspired by the discussions.

License

The gem is available as open source under the terms of the MIT License.