mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 17:52:45 +08:00
FIX: recover from migration failure
If the migration somehow failed halfway then just run through, when ddl transactions are disabled stuff can get somewhat odd.
This commit is contained in:
parent
a7a5f90e20
commit
8f4527c1f1
@ -14,14 +14,23 @@ class AddFirstUnreadAtToUserStats < ActiveRecord::Migration[5.2]
|
||||
WHERE u.id = us.user_id
|
||||
SQL
|
||||
|
||||
# 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)"
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
|
Loading…
x
Reference in New Issue
Block a user