README.md in lhm-1.0.0.rc2 vs README.md in lhm-1.0.0.rc3
- old
+ new
@@ -14,11 +14,11 @@
> Side effects may include black holes and universe implosion.
There are few things that can be done at the server or engine level. It is
possible to change default values in an `ALTER TABLE` without locking the
-table. The InnoDB Plugin provides facilities for online index creation, which
+table. The InnoDB Plugin provides facilities for online index creation, which
is great if you are using this engine, but only solves half the problem.
At SoundCloud we started having migration pains quite a while ago, and after
looking around for third party solutions [0] [1] [2], we decided to create our
own. We called it Large Hadron Migrator, and it is a gem for online
@@ -40,42 +40,46 @@
twitter solution [1], it does not require the presence of an indexed
`updated_at` column.
## Usage
-After extending Lhm, `hadron_change_table` becomes available
-with the following methods:
+You can invoke Lhm directly from a plain ruby file after connecting active
+record to your mysql instance:
- class MigrateArbitrary < ActiveRecord::Migration
- extend Lhm
+ require 'lhm'
+ ActiveRecord::Base.establish_connection(
+ :adapter => 'mysql',
+ :host => '127.0.0.1',
+ :database => 'lhm'
+ )
+
+ Lhm.change_table(:users) do |m|
+ m.add_column(:arbitrary, "INT(12)")
+ m.add_index([:arbitrary, :created_at])
+ m.ddl("alter table %s add column flag tinyint(1)" % m.name)
+ end
+
+To use Lhm from an ActiveRecord::Migration in a Rails project, add it to your
+Gemfile, then invoke as follows:
+
+ class MigrateUsers < ActiveRecord::Migration
+
def self.up
- hadron_change_table(:users) do |t|
- t.add_column(:arbitrary, "INT(12)")
- t.add_index([:arbitrary, :created_at])
- t.ddl("alter table %s add column flag tinyint(1)" % t.name)
+ Lhm.change_table(:users) do |m|
+ m.add_column(:arbitrary, "INT(12)")
+ m.add_index([:arbitrary, :created_at])
+ m.ddl("alter table %s add column flag tinyint(1)" % m.name)
end
end
def self.down
- hadron_change_table(:users) do |t|
- t.remove_index([:arbitrary, :created_at])
- t.remove_column(:arbitrary)
+ Lhm.change_table(:users) do |m|
+ m.remove_index([:arbitrary, :created_at])
+ m.remove_column(:arbitrary)
end
end
end
-
-## Migration phases
-
-_TODO_
-
-### When adding a column
-
-_TODO_
-
-### When removing a column
-
-_TODO_
## Contributing
We'll check out your contribution if you: