Socket
Book a DemoInstallSign in
Socket

legacy_migrations

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

legacy_migrations

0.3.7
bundlerRubygems
Version published
Maintainers
1
Created
Source

=LegacyMigrations

This plugin implements a simple, expressive syntax for migrating data from one data structure to another. Here's a simple example:

require 'legacy_migrations'

transfer_from Person, :to => Animal do from :name, :to => :pet_name end

This transfers data from the people table to the animals table, mapping the people's name column to animals' pet_name column.

But that's just the beginning. This plugin also:

  • Reports invalid data by using your application's own validation errors for easy data cleanup (just use ActiveRecord validations and after running the script from the command line, the output will give you helpful details about validation errors.)
  • Maps foreign keys between the databases (currently not implemented)
  • Gives you a bunch of options for mapping fields between tables.

== Example

In some file in your rails app (perhaps db/seeds.rb?)

require 'legacy_migrations'

transfer_from Person, :to => Animal do from :name, :to => :pet_name from :sex, :to => :gender do |sex| sex == 'm' ? 'male' : 'female' end end

OR, copy all columns with the same name

transfer_from Person, :to => Animal do match_same_name_attributes end

Here's a slightly more thorough blog post about it:

http://frontended.com/?p=89

Copyright (c) 2010 Bernie Telles, released under the MIT license

FAQs

Package last updated on 25 Aug 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.