Skip to content

Commit

Permalink
FIX: Ensure javascript caches are unique per theme/theme_field
Browse files Browse the repository at this point in the history
We were assuming that this was the case before, but not enforcing it.
  • Loading branch information
danielwaterworth committed Aug 17, 2023
1 parent af30f99 commit d3392d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/javascript_cache.rb
Expand Up @@ -46,8 +46,8 @@ def content_cannot_be_nil
# 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
#
Expand Down
@@ -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

0 comments on commit d3392d5

Please sign in to comment.