2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-10-03 17:21:20 +08:00
discourse/db/migrate/20250715094001_update_javascript_cache.rb
David Taylor f4b70c746d
DEV: Extract theme script tags into their own JS files (#33647)
Previously, all script tags in a theme field would be combined into a
single `.js` bundle along with the `text/discourse-plugin` modules. This
led to some unexpected run order, and also makes it hard to implement
the `type=module` change being developed in #33103.

This commit refactors things so that each raw script gets extracted into
its own `.js` bundle, which is then placed in exactly the same place in
the HTML.
2025-07-16 17:17:36 +01:00

15 lines
529 B
Ruby

# frozen_string_literal: true
class UpdateJavascriptCache < ActiveRecord::Migration[7.2]
def change
remove_index :javascript_caches,
column: :theme_field_id,
name: :index_javascript_caches_on_theme_field_id,
unique: true
add_column :javascript_caches, :name, :string
add_index :javascript_caches,
%i[theme_field_id name],
unique: true,
nulls_not_distinct: true,
where: "theme_field_id IS NOT NULL"
end
end