Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanety/slonik_migration
A rails migration gem for slony using slonik_execute_script command
https://github.com/kanety/slonik_migration
activerecord migration rails slony
Last synced: 2 months ago
JSON representation
A rails migration gem for slony using slonik_execute_script command
- Host: GitHub
- URL: https://github.com/kanety/slonik_migration
- Owner: kanety
- License: mit
- Created: 2017-11-07T10:40:06.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-21T00:43:23.000Z (3 months ago)
- Last Synced: 2024-10-21T04:07:37.285Z (3 months ago)
- Topics: activerecord, migration, rails, slony
- Language: Ruby
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this 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:
```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 [email protected] 'slonik_execute_script -c $SQL 1 | sed "s/set id = 1,//" | slonik'# table/sequence owner.
owner: ownerdevelopment:
<<: *defaulttest:
<<: *defaultproduction:
<<: *default
```## Usage
This gem enhances following rails commands:
* db:migrate
* db:migrate:up
* db:migrate:downYou 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).