Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Ensure javascript caches are unique per theme #23126

Merged
merged 1 commit into from Aug 17, 2023

Conversation

danielwaterworth
Copy link
Member

We were assuming that this was the case before, but not enforcing it.

@@ -47,7 +47,7 @@ def content_cannot_be_nil
#
# index_javascript_caches_on_digest (digest)
# index_javascript_caches_on_theme_field_id (theme_field_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be an UNIQUE index too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose I should do both.

class EnsureJavascriptCacheIsUniquePerTheme < ActiveRecord::Migration[7.0]
def change
remove_index :javascript_caches, :theme_id
add_index :javascript_caches, :theme_id, unique: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any chance this could break an existing site because we have more than a cache for a theme?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible, so I ran a script to check that this hadn't happened

We were assuming that this was the case before, but not enforcing it.
@danielwaterworth danielwaterworth force-pushed the ensure-unique-js-cache branch 3 times, most recently from e23ef70 to d3392d5 Compare August 17, 2023 18:52
@danielwaterworth danielwaterworth merged commit 80a0d88 into main Aug 17, 2023
25 checks passed
@danielwaterworth danielwaterworth deleted the ensure-unique-js-cache branch August 17, 2023 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants