-
Notifications
You must be signed in to change notification settings - Fork 3
Repository moved to https://github.com/MakeYourLaws/mysql_big_table_migration
License
mmrwoods/mysql_big_table_migration
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
NOTICE: Repository moved to https://github.com/MakeYourLaws/mysql_big_table_migration MysqlBigTableMigration ====================== A Rails plugin that adds methods to ActiveRecord::Migration to allow columns and indexes to be added to and removed from large tables with millions of rows in MySQL, without leaving processes seemingly stalled in state "copy to tmp table". For each of the standard transformations that operate on columns or indexes, this plugin adds a "using_tmp_table" version. These methods create a temporary table with the same structure as the table to be altered, applies the transformation to the temp table, copies data from the source table to the temp table and then replaces the source table with the temporary one. While it does try to ensure that data is consistent at the end of the entire process by locking tables and looking for rows created or modified during copying, this is NOT TRANSACTION SAFE as it (a) relies on timestamp columns and (b) doesn't handle rows that have been deleted from the source table after being copied to the temporary table. Example ======= class AddIndexOnSomeColumnToSomeTable < ActiveRecord::Migration def self.up add_index_using_tmp_table :some_table, :some_column end def self.down remove_index_using_tmp_table :some_table, :some_column end end Copyright (c) 2010 Mark Woods, released under the MIT license Testing ======== You will need to bundle install dependencies for the project, as well as create a test database. To install dependencies run `bundle install`. To create the database run the following in a MySQL prompt as an admin user: ``` CREATE DATABASE mysql_big_table_migration_test; GRANT ALL PRIVILEGES ON *.* TO 'dev'@'localhost' IDENTIFIED BY 'password'; ``` After bundling dependencies, and setting up the test database, run the tests with `rake test`
About
Repository moved to https://github.com/MakeYourLaws/mysql_big_table_migration
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published