Sha256: d1355f6aabdedc431e6e4b8349ddca5c9b43da2a08cb99332a512b0caf983440

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

# SlonikMigration

A rails migration gem for slony using `slonik_execute_script` command.

## Dependencies

* ruby 2.3+
* activerecord 5.0+
* slony 2.2+

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'slonik_migration'
```

Then execute:

    $ bundle

Generate config file:

    $ bundle exec rails g slonik_migration:config

## Configuration

Edit `config/slonik.yml`.

```yaml
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](http://justatheory.com/computers/databases/postgresql/rails_and_slony.html).

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
slonik_migration-1.1.3 README.md
slonik_migration-1.1.2 README.md
slonik_migration-1.1.1 README.md
slonik_migration-1.1.0 README.md