Class: Rpush200Updates
- Inherits:
-
ActiveRecord::Migration
- Object
- ActiveRecord::Migration
- Rpush200Updates
- Defined in:
- lib/generators/templates/rpush_2_0_0_updates.rb
Class Method Summary collapse
Class Method Details
.adapter_name ⇒ Object
35 36 37 38 |
# File 'lib/generators/templates/rpush_2_0_0_updates.rb', line 35 def self.adapter_name env = (defined?(Rails) && Rails.env) ? Rails.env : 'development' ActiveRecord::Base.configurations[env]['adapter'] end |
.down ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/templates/rpush_2_0_0_updates.rb', line 21 def self.down change_column :rpush_feedback, :app_id, :string rename_column :rpush_feedback, :app_id, :app if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi, true) remove_index :rpush_notifications, name: :index_rpush_notifications_multi end add_index :rpush_notifications, [:app_id, :delivered, :failed, :deliver_after], name: 'index_rpush_notifications_multi' remove_column :rpush_notifications, :priority remove_column :rpush_notifications, :processing end |
.postgresql? ⇒ Boolean
40 41 42 |
# File 'lib/generators/templates/rpush_2_0_0_updates.rb', line 40 def self.postgresql? adapter_name =~ /postgresql|postgis/ end |
.up ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/templates/rpush_2_0_0_updates.rb', line 2 def self.up add_column :rpush_notifications, :processing, :boolean, null: false, default: false add_column :rpush_notifications, :priority, :integer, null: true if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi, true) remove_index :rpush_notifications, name: :index_rpush_notifications_multi end add_index :rpush_notifications, [:delivered, :failed], name: 'index_rpush_notifications_multi', where: 'NOT delivered AND NOT failed' rename_column :rpush_feedback, :app, :app_id if postgresql? execute('ALTER TABLE rpush_feedback ALTER COLUMN app_id TYPE integer USING (trim(app_id)::integer)') else change_column :rpush_feedback, :app_id, :integer end end |