FIX: Ensure javascript caches are unique per theme/theme_field (#23126)

We were assuming that this was the case before, but not enforcing it.
This commit is contained in:
Daniel Waterworth 2023-08-17 13:57:04 -05:00 committed by GitHub
parent 54092833b9
commit 80a0d88e4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -46,8 +46,8 @@ end
# Indexes
#
# index_javascript_caches_on_digest (digest)
# index_javascript_caches_on_theme_field_id (theme_field_id)
# index_javascript_caches_on_theme_id (theme_id)
# index_javascript_caches_on_theme_field_id (theme_field_id) UNIQUE
# index_javascript_caches_on_theme_id (theme_id) UNIQUE
#
# Foreign Keys
#

View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
class EnsureJavascriptCacheIsUniquePerTheme < ActiveRecord::Migration[7.0]
def change
remove_index :javascript_caches, :theme_id
add_index :javascript_caches, :theme_id, unique: true
remove_index :javascript_caches, :theme_field_id
add_index :javascript_caches, :theme_field_id, unique: true
end
end