20211213040746_update_account_summaries_to_version_2.rb 974 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. class UpdateAccountSummariesToVersion2 < ActiveRecord::Migration[6.1]
  3. def up
  4. reapplication_follow_recommendations_v2 do
  5. drop_view :account_summaries, materialized: true
  6. create_view :account_summaries, version: 2, materialized: { no_data: true }
  7. safety_assured { add_index :account_summaries, :account_id, unique: true }
  8. end
  9. end
  10. def down
  11. reapplication_follow_recommendations_v2 do
  12. drop_view :account_summaries, materialized: true
  13. create_view :account_summaries, version: 1, materialized: { no_data: true }
  14. safety_assured { add_index :account_summaries, :account_id, unique: true }
  15. end
  16. end
  17. def reapplication_follow_recommendations_v2
  18. drop_view :follow_recommendations, materialized: true
  19. yield
  20. create_view :follow_recommendations, version: 2, materialized: { no_data: true }
  21. safety_assured { add_index :follow_recommendations, :account_id, unique: true }
  22. end
  23. end