A platform for community discussion. Free, open, simple.
FIX: recover from migration failure
Sam Saffron8f4527c1f186
diff --git a/db/migrate/20190402024053_add_first_unread_at_to_user_stats.rb b/db/migrate/20190402024053_add_first_unread_at_to_user_stats.rbindex e89b93a4fe1..1d2eb432f12 100644--- a/db/migrate/20190402024053_add_first_unread_at_to_user_stats.rb+++ b/db/migrate/20190402024053_add_first_unread_at_to_user_stats.rb@@ -14,14 +14,23 @@ class AddFirstUnreadAtToUserStats < ActiveRecord::Migration[5.2]WHERE u.id = us.user_idSQL- # this is quite a big index to carry, but we need it to optimise home page initial load- # by covering all these columns we are able to quickly retrieve the set of topics that were- # updated in the last N days. We perform a ranged lookup and selectivity may vary a lot- add_index :topics,+ # since DDL transactions are disabled we got to check+ # this could potentially fail half way and we want it to recover+ if !index_exists?(+ :topics,+ # the big list of columns here is not really needed, but ... why not[:updated_at, :visible, :highest_staff_post_number, :highest_post_number, :category_id, :created_at, :id],- algorithm: :concurrently,- name: 'index_topics_on_updated_at_public',- where: "(topics.archetype <> 'private_message') AND (topics.deleted_at IS NULL)"+ name: 'index_topics_on_updated_at_public'+ )+ # this is quite a big index to carry, but we need it to optimise home page initial load+ # by covering all these columns we are able to quickly retrieve the set of topics that were+ # updated in the last N days. We perform a ranged lookup and selectivity may vary a lot+ add_index :topics,+ [:updated_at, :visible, :highest_staff_post_number, :highest_post_number, :category_id, :created_at, :id],+ algorithm: :concurrently,+ name: 'index_topics_on_updated_at_public',+ where: "(topics.archetype <> 'private_message') AND (topics.deleted_at IS NULL)"+ endenddef down