public
Description: The automatic way to migrate
Homepage: http://errtheblog.com/posts/65-automatically
Clone URL: git://github.com/pjhyett/auto_migrations.git
Search Repo:
updated schema_info table with current version from schema.rb ... plays 
nicer with migrations
bwyrosdick (author)
Tue May 06 21:10:04 -0700 2008
commit  ff63b5c4973878a71fc7c5850e3fe35d12bd9142
tree    a0217679b04f6d5c1bdce980b4e7e79d98fb4323
parent  8e08b2cd02be17bc5e3b18a5fed91b7b6f48547e
...
4
5
6
7
 
 
8
9
10
11
12
 
13
14
15
...
130
131
132
 
 
 
 
133
134
135
...
4
5
6
 
7
8
9
10
11
12
13
14
15
16
17
...
132
133
134
135
136
137
138
139
140
141
0
@@ -4,12 +4,14 @@ module AutoMigrations
0
     # Turn off schema_info code for auto-migration
0
     class << ActiveRecord::Schema
0
       alias :old_define :define
0
- def define(info={}, &block) instance_eval(&block) end
0
+ attr_accessor :version
0
+ def define(info={}, &block) @version=info[:version]; instance_eval(&block) end
0
     end
0
   
0
     load(File.join(RAILS_ROOT, 'db', 'schema.rb'))
0
     ActiveRecord::Migration.drop_unused_tables
0
     ActiveRecord::Migration.drop_unused_indexes
0
+ ActiveRecord::Migration.update_schema_version(ActiveRecord::Schema.version) if ActiveRecord::Schema.version
0
   
0
     class << ActiveRecord::Schema
0
       alias :define :old_define
0
@@ -130,6 +132,10 @@ module AutoMigrations
0
         end
0
       end
0
     end
0
+
0
+ def update_schema_version(version)
0
+ ActiveRecord::Base.connection.update("UPDATE #{ActiveRecord::Migrator.schema_info_table_name} SET version = #{version}")
0
+ end
0
   
0
   end
0
 

Comments

    No one has commented yet.