public
Fork of lazyatom/engines
Description: The Rails Engines plugin
Homepage: http://rails-engines.org
Clone URL: git://github.com/tekkub/engines.git
Fixed migration to integrate with time-stamped migrations in edge rails 
(http://dev.rubyonrails.org/changeset/9244). The new behaviour in rails 
includes a helper which can replace the wrapped_table_name extension, so 
we don't need that anymore.

git-svn-id: http://svn.rails-engines.org/engines/trunk@681 
61cc408d-6c04-0410-aff7-b3608aa29ce9
lazyatom (author)
Sun Apr 13 06:27:48 -0700 2008
commit  905b03b14e13a4ed41591893947a7f3545ece5a3
tree    dfb01160c35fbe741a25237a824924c6bb0a054f
parent  58f412a960028854becd9630e82d01df4c5cc57a
...
43
44
45
46
 
47
48
49
...
43
44
45
 
46
47
48
49
0
@@ -43,7 +43,7 @@ module Engines
0
   
0
   # List of extensions to load, can be changed in init.rb before calling Engines.init
0
   mattr_accessor :rails_extensions
0
- self.rails_extensions = %w(active_record action_mailer asset_helpers routing migrations dependencies)
0
+ self.rails_extensions = %w(action_mailer asset_helpers routing migrations dependencies)
0
   
0
   # The name of the public directory to mirror public engine assets into.
0
   # Defaults to <tt>RAILS_ROOT/public/plugin_assets</tt>.
...
15
16
17
 
 
 
 
 
18
19
20
...
23
24
25
26
 
27
28
29
...
46
47
48
49
 
 
 
 
 
 
 
 
 
50
51
52
 
53
54
55
...
15
16
17
18
19
20
21
22
23
24
25
...
28
29
30
 
31
32
33
34
...
51
52
53
 
54
55
56
57
58
59
60
61
62
63
64
 
65
66
67
68
0
@@ -15,6 +15,11 @@ class Engines::Plugin::Migrator < ActiveRecord::Migrator
0
   # Runs the migrations from a plugin, up (or down) to the version given
0
   def self.migrate_plugin(plugin, version)
0
     self.current_plugin = plugin
0
+ # There seems to be a bug in Rails' own migrations, where migrating
0
+ # to the existing version causes all migrations to be run where that
0
+ # migration number doesn't exist (i.e. zero). We could fix this by
0
+ # removing the line if the version hits zero...?
0
+ return if current_version(plugin) == version
0
     migrate(plugin.migration_directory, version)
0
   end
0
   
0
@@ -23,7 +28,7 @@ class Engines::Plugin::Migrator < ActiveRecord::Migrator
0
   #
0
   # See Engines.schema_info_table for more details.
0
   def self.schema_info_table_name
0
- ActiveRecord::Base.wrapped_table_name Engines.schema_info_table
0
+ proper_table_name Engines.schema_info_table
0
   end
0
 
0
   # Returns the current version of the given plugin
0
@@ -46,10 +51,18 @@ class Engines::Plugin::Migrator < ActiveRecord::Migrator
0
       0
0
     end
0
   end
0
-
0
+
0
+ def migrated(plugin=current_plugin)
0
+ ActiveRecord::Base.connection.select_values(<<-ESQL
0
+ SELECT version FROM #{self.class.schema_info_table_name}
0
+ WHERE plugin_name = '#{plugin.name}'
0
+ ESQL
0
+ ).map(&:to_i).sort - [0]
0
+ end
0
+
0
   # Sets the version of the plugin in Engines::Plugin::Migrator.current_plugin to
0
   # the given version.
0
- def set_schema_version(version)
0
+ def record_version_state_after_migrating(version)
0
     ActiveRecord::Base.connection.update(<<-ESQL
0
       UPDATE #{self.class.schema_info_table_name}
0
       SET version = #{down? ? version.to_i - 1 : version.to_i}

Comments

    No one has commented yet.