mirror of
https://github.com/discourse/discourse.git
synced 2025-03-03 17:59:20 +00:00
You can now add javascript files under `/javascripts/*` in a theme, and they will be loaded as if they were included in core, or a plugin. If you give something the same name as a core/plugin file, it will be overridden. Support file extensions are `.js.es6`, `.hbs` and `.raw.hbs`.
27 lines
832 B
Ruby
27 lines
832 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddThemeIdToJavascriptCache < ActiveRecord::Migration[5.2]
|
|
def up
|
|
make_changes
|
|
execute "ALTER TABLE javascript_caches ADD CONSTRAINT enforce_theme_or_theme_field CHECK ((theme_id IS NOT NULL AND theme_field_id IS NULL) OR (theme_id IS NULL AND theme_field_id IS NOT NULL))"
|
|
end
|
|
def down
|
|
execute "ALTER TABLE javascript_caches DROP CONSTRAINT enforce_theme_or_theme_field"
|
|
revert { make_changes }
|
|
end
|
|
|
|
private
|
|
|
|
def make_changes
|
|
add_reference :javascript_caches, :theme, foreign_key: { on_delete: :cascade }
|
|
add_foreign_key :javascript_caches, :theme_fields, on_delete: :cascade
|
|
|
|
begin
|
|
Migration::SafeMigrate.disable!
|
|
change_column_null :javascript_caches, :theme_field_id, true
|
|
ensure
|
|
Migration::SafeMigrate.enable!
|
|
end
|
|
end
|
|
end
|