joshnabbott-desert 0.3.5.2 → 0.3.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,35 @@
1
+ module Desert #:nodoc:
2
+ module PluginMigrations
3
+ class Migrator < ActiveRecord::Migrator
4
+ class << self
5
+ def current_version #:nodoc:
6
+ result = ActiveRecord::Base.connection.select_one("SELECT version FROM #{schema_migrations_table_name} WHERE plugin_name = '#{current_plugin.name}' order by version desc")
7
+ if result
8
+ result['version'].to_i
9
+ else
10
+ # There probably isn't an entry for this plugin in the migration info table.
11
+ 0
12
+ end
13
+ end
14
+
15
+ def get_all_versions
16
+ ActiveRecord::Base.connection.select_values("SELECT version FROM #{schema_migrations_table_name} where plugin_name='#{current_plugin.name}'").map(&:to_i).sort
17
+ end
18
+ end
19
+
20
+ def record_version_state_after_migrating(version)
21
+ sm_table = self.class.schema_migrations_table_name
22
+
23
+ if down?
24
+ ActiveRecord::Base.connection.update("DELETE FROM #{sm_table} WHERE version = '#{version}' WHERE plugin_name = '#{current_plugin.name}'")
25
+ else
26
+ ActiveRecord::Base.connection.insert("INSERT INTO #{sm_table} (plugin_name, version) VALUES ('#{current_plugin.name}', '#{version}')")
27
+ end
28
+ end
29
+
30
+ def migrated
31
+ self.class.get_all_versions
32
+ end
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: joshnabbott-desert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5.2
4
+ version: 0.3.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal Labs
@@ -31,6 +31,7 @@ files:
31
31
  - lib/desert/manager.rb
32
32
  - lib/desert/plugin.rb
33
33
  - lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb
34
+ - lib/desert/plugin_migrations/2.1/migrator.rb
34
35
  - lib/desert/plugin_migrations/1.2/extensions/schema_statements.rb
35
36
  - lib/desert/plugin_migrations/migrator.rb
36
37
  - lib/desert/plugin_migrations.rb