• Stars
    star
    124
  • Rank 288,207 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 8 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Run your data migration scripts like a master

Rails Data Migrations

Build Rubocop Gem Version

Why?

Have you ever run into a problem when alongside with DB schema migrations (managed by rake db:migrate in Rails) you have to often change your DB content, as well? If you read this, you probably tried to use schema migrations do change your data after schema changes, but this is not a recommended way and sometimes data changes could take a long time, so they will block your app at the deploy time. Another approach is to use rake tasks to run your changes after db:migrate or even independently. But this could also become a mess after some time if you have multiple developers in your project, and you need to change your data often.

This is our solution we came up with in our company - run data migration tasks in a db:migrate-like manner

Usage

To create a data migration you need to run:

rails generate data_migration migration_name

and this will create a migration_name.rb file in db/data_migrations folder with a following content:

class MigrationName < DataMigration
  def up
    # put your code here
  end
end

so all we need to do is to put some ruby code inside the up method.

Finally, at the release time, you need to run

rake data:migrate

This will run all pending data migrations and store migration history in data_migrations table. You're all set.

Rails Support

Rails 4.0 and higher

Installation

Add this line to your application's Gemfile:

gem 'rails-data-migrations'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails-data-migrations

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Run tests (appraisal install && appraisal rake)
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

License

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

More Repositories

1

android-inapp-billing-v3

A lightweight implementation of Android In-app Billing Version 3
Java
2,193
star
2

bootstrap-rails

Twitter Bootstrap CSS (with Sass flavour) and JS toolkits for Rails 3 projects
CSS
729
star
3

android-sms-gateway

Simple SMS gateway running on Android
Java
115
star
4

sat3

Reference Implementation of Romanov's Polynomial Algorithm for Boolean 3-SAT Problem
Java
87
star
5

rubyfish

RubyFish is a ruby port of python library jellyfish (http://github.com/sunlightlabs/jellyfish) for doing approximate and phonetic matching of strings
Ruby
66
star
6

anjlab-widgets

UI Widgets on top of anjlab-bootstrap-rails
CoffeeScript
54
star
7

inputs

HTML form inputs with pure CSS and a little bit JS magic.
CSS
48
star
8

yandex-disk

Ruby client for Yandex.Disk with backup gem support
Ruby
33
star
9

pushapp

pushapp
Ruby
32
star
10

sublime-text-git-autocommit

Enables auto-commit for selected Git repos (install Git plugin first)
Python
28
star
11

paranoid2

paranoid models for rails 4
Ruby
24
star
12

graphql_authorize

Authorization helpers for ruby-graphql fields
Ruby
24
star
13

bootstrap-glyphicons

bootstrap glyphicons
Ruby
22
star
14

eclipse-tapestry5-plugin

Eclipse Plugin for Tapestry5
Java
21
star
15

db-switch

Simple database connection switcher for Rails 5
Ruby
17
star
16

triggerable

Trigger/automation engine for ActiveRecord models
Ruby
17
star
17

uploads

simple uploads for rails
CoffeeScript
14
star
18

redmine_inline_note_images_plugin

Redmine plugin for inline note images display
Ruby
12
star
19

elk_rails_sample

A sample app demonstrating a usage of ELK logging stack for Rails apps
Ruby
12
star
20

jquery-infinite-scroll

JQuery plugin for ajax-enabled infinite page scroll
JavaScript
12
star
21

anjlab-tapestry-commons

Java
11
star
22

excel2csv-ruby

Wrapper around anjlab/excel2csv-java POI CLI
Ruby
10
star
23

logback-hipchat-appender

Logback Appender for HipChat
Java
9
star
24

ping-service

AnjLab Ping Service
Java
8
star
25

JJ

Super simple json parser for Swift
Swift
6
star
26

csv2db

csv2db command line tool
Java
6
star
27

excel2csv-java

Excel 2 CSV Command Line Tool
Java
6
star
28

techtalks

Jupyter Notebook
6
star
29

SafeURL

Swift safe NSURL Builder
Swift
6
star
30

gradle-sysdeo-tomcat-plugin

Gradle plugin for generating ".tomcatplugin" artifact for Sysdeo Eclipse Tomcat Launcher Plugin
Groovy
5
star
31

pusher.io

Socket.io for Rails
Ruby
4
star
32

devise_oauth

The OAuth 2.0 Authorization Framework draft-ietf-oauth-v2-28 implementation on top of devise.
Ruby
4
star
33

db2excel-java

Java
3
star
34

sunspot_offline

Offline extension for your Solr + Sidekiq setup
Ruby
3
star
35

mechanize_clip

mechanize url fetcher for paperclip
Ruby
3
star
36

bookmarklets

AnjLab Bookmarklets
JavaScript
3
star
37

cubics

anjlab cubics
Java
2
star
38

ssf4j

Simple Sorting Facade for Java (SSF4J)
1
star
39

msword-ruby

Ruby
1
star
40

smpp_encoding

GSM and UNICODE encoders for smpp-ruby gem
Ruby
1
star
41

db2excel-ruby

Ruby
1
star
42

SwiftlyNotice

Swift
1
star