mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-06 21:30:25 +08:00
Ruby's compact module syntax (`module Migrations::Database::Schema::DSL`) breaks lexical constant lookup — `Module.nesting` only includes the innermost constant, so every cross-module reference must be fully qualified. In practice this means writing `Migrations::Database::Schema::Helpers` even when you're already inside `Migrations::Database::Schema`. Nested module definitions restore the full nesting chain, which brings several practical benefits: - **Less verbose code**: references like `Schema::Helpers`, `Database::IntermediateDB`, or `Converters::Base::ProgressStep` work without repeating the full path from root - **Easier to write new code**: contributors don't need to remember which prefixes are required — if you're inside the namespace, short names just work - **Fewer aliasing workarounds**: removes the need for constants like `MappingType = Migrations::Importer::MappingType` that existed solely to shorten references - **Standard Ruby style**: consistent with how most Ruby projects and gems structure their namespaces The diff is large but mechanical — no logic changes, just module wrapping and shortening references that the nesting now resolves. Generated code (intermediate_db models/enums) keeps fully qualified references like `Migrations::Database.format_*` since it must work regardless of the configured output namespace. - Convert 138 lib files from compact to nested module definitions - Remove now-redundant fully qualified prefixes and aliases - Update model and enum writers to generate nested modules with correct indentation - Regenerate all intermediate_db models and enums
221 lines
9 KiB
Ruby
221 lines
9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# This file is auto-generated from the IntermediateDB schema. To make changes,
|
|
# update the configuration files in "migrations/config/schema/" and then run
|
|
# `migrations/bin/cli schema generate` to regenerate this file.
|
|
|
|
module Migrations
|
|
module Database
|
|
module IntermediateDB
|
|
module Category
|
|
SQL = <<~SQL
|
|
INSERT INTO categories (
|
|
original_id,
|
|
about_topic_title,
|
|
all_topics_wiki,
|
|
allow_badges,
|
|
allow_global_tags,
|
|
allow_unlimited_owner_edits_on_first_post,
|
|
auto_close_based_on_last_post,
|
|
auto_close_hours,
|
|
color,
|
|
created_at,
|
|
default_list_filter,
|
|
default_slow_mode_seconds,
|
|
default_top_period,
|
|
default_view,
|
|
description,
|
|
email_in,
|
|
email_in_allow_strangers,
|
|
emoji,
|
|
existing_id,
|
|
icon,
|
|
locale,
|
|
mailinglist_mirror,
|
|
minimum_required_tags,
|
|
name,
|
|
navigate_to_first_post_after_read,
|
|
num_featured_topics,
|
|
parent_category_id,
|
|
position,
|
|
read_only_banner,
|
|
read_restricted,
|
|
search_priority,
|
|
show_subcategory_list,
|
|
slug,
|
|
sort_ascending,
|
|
sort_order,
|
|
style_type,
|
|
subcategory_list_style,
|
|
text_color,
|
|
topic_featured_link_allowed,
|
|
topic_id,
|
|
topic_template,
|
|
topic_title_placeholder,
|
|
uploaded_background_dark_id,
|
|
uploaded_background_id,
|
|
uploaded_logo_dark_id,
|
|
uploaded_logo_id,
|
|
user_id
|
|
)
|
|
VALUES (
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
)
|
|
SQL
|
|
private_constant :SQL
|
|
|
|
# Creates a new `categories` record in the IntermediateDB.
|
|
#
|
|
# @param original_id [Integer, String]
|
|
# @param about_topic_title [String, nil]
|
|
# @param all_topics_wiki [Boolean, nil]
|
|
# @param allow_badges [Boolean, nil]
|
|
# @param allow_global_tags [Boolean, nil]
|
|
# @param allow_unlimited_owner_edits_on_first_post [Boolean, nil]
|
|
# @param auto_close_based_on_last_post [Boolean, nil]
|
|
# @param auto_close_hours [Float, nil]
|
|
# @param color [String, nil]
|
|
# @param created_at [Time, nil]
|
|
# @param default_list_filter [String, nil]
|
|
# @param default_slow_mode_seconds [Integer, nil]
|
|
# @param default_top_period [String, nil]
|
|
# @param default_view [String, nil]
|
|
# @param description [String, nil]
|
|
# @param email_in [String, nil]
|
|
# @param email_in_allow_strangers [Boolean, nil]
|
|
# @param emoji [String, nil]
|
|
# @param existing_id [Integer, String, nil]
|
|
# @param icon [String, nil]
|
|
# @param locale [String, nil]
|
|
# @param mailinglist_mirror [Boolean, nil]
|
|
# @param minimum_required_tags [Integer, nil]
|
|
# @param name [String]
|
|
# @param navigate_to_first_post_after_read [Boolean, nil]
|
|
# @param num_featured_topics [Integer, nil]
|
|
# @param parent_category_id [Integer, String, nil]
|
|
# @param position [Integer, nil]
|
|
# @param read_only_banner [String, nil]
|
|
# @param read_restricted [Boolean, nil]
|
|
# @param search_priority [Integer, nil]
|
|
# @param show_subcategory_list [Boolean, nil]
|
|
# @param slug [String]
|
|
# @param sort_ascending [Boolean, nil]
|
|
# @param sort_order [String, nil]
|
|
# @param style_type [Integer, nil]
|
|
# @param subcategory_list_style [String, nil]
|
|
# @param text_color [String, nil]
|
|
# @param topic_featured_link_allowed [Boolean, nil]
|
|
# @param topic_id [Integer, String, nil]
|
|
# @param topic_template [String, nil]
|
|
# @param topic_title_placeholder [String, nil]
|
|
# @param uploaded_background_dark_id [String, nil]
|
|
# @param uploaded_background_id [String, nil]
|
|
# @param uploaded_logo_dark_id [String, nil]
|
|
# @param uploaded_logo_id [String, nil]
|
|
# @param user_id [Integer, String]
|
|
#
|
|
# @return [void]
|
|
def self.create(
|
|
original_id:,
|
|
about_topic_title: nil,
|
|
all_topics_wiki: nil,
|
|
allow_badges: nil,
|
|
allow_global_tags: nil,
|
|
allow_unlimited_owner_edits_on_first_post: nil,
|
|
auto_close_based_on_last_post: nil,
|
|
auto_close_hours: nil,
|
|
color: nil,
|
|
created_at: nil,
|
|
default_list_filter: nil,
|
|
default_slow_mode_seconds: nil,
|
|
default_top_period: nil,
|
|
default_view: nil,
|
|
description: nil,
|
|
email_in: nil,
|
|
email_in_allow_strangers: nil,
|
|
emoji: nil,
|
|
existing_id: nil,
|
|
icon: nil,
|
|
locale: nil,
|
|
mailinglist_mirror: nil,
|
|
minimum_required_tags: nil,
|
|
name:,
|
|
navigate_to_first_post_after_read: nil,
|
|
num_featured_topics: nil,
|
|
parent_category_id: nil,
|
|
position: nil,
|
|
read_only_banner: nil,
|
|
read_restricted: nil,
|
|
search_priority: nil,
|
|
show_subcategory_list: nil,
|
|
slug:,
|
|
sort_ascending: nil,
|
|
sort_order: nil,
|
|
style_type: nil,
|
|
subcategory_list_style: nil,
|
|
text_color: nil,
|
|
topic_featured_link_allowed: nil,
|
|
topic_id: nil,
|
|
topic_template: nil,
|
|
topic_title_placeholder: nil,
|
|
uploaded_background_dark_id: nil,
|
|
uploaded_background_id: nil,
|
|
uploaded_logo_dark_id: nil,
|
|
uploaded_logo_id: nil,
|
|
user_id:
|
|
)
|
|
Migrations::Database::IntermediateDB.insert(
|
|
SQL,
|
|
original_id,
|
|
about_topic_title,
|
|
Migrations::Database.format_boolean(all_topics_wiki),
|
|
Migrations::Database.format_boolean(allow_badges),
|
|
Migrations::Database.format_boolean(allow_global_tags),
|
|
Migrations::Database.format_boolean(allow_unlimited_owner_edits_on_first_post),
|
|
Migrations::Database.format_boolean(auto_close_based_on_last_post),
|
|
auto_close_hours,
|
|
color,
|
|
Migrations::Database.format_datetime(created_at),
|
|
default_list_filter,
|
|
default_slow_mode_seconds,
|
|
default_top_period,
|
|
default_view,
|
|
description,
|
|
email_in,
|
|
Migrations::Database.format_boolean(email_in_allow_strangers),
|
|
emoji,
|
|
existing_id,
|
|
icon,
|
|
locale,
|
|
Migrations::Database.format_boolean(mailinglist_mirror),
|
|
minimum_required_tags,
|
|
name,
|
|
Migrations::Database.format_boolean(navigate_to_first_post_after_read),
|
|
num_featured_topics,
|
|
parent_category_id,
|
|
position,
|
|
read_only_banner,
|
|
Migrations::Database.format_boolean(read_restricted),
|
|
search_priority,
|
|
Migrations::Database.format_boolean(show_subcategory_list),
|
|
slug,
|
|
Migrations::Database.format_boolean(sort_ascending),
|
|
sort_order,
|
|
style_type,
|
|
subcategory_list_style,
|
|
text_color,
|
|
Migrations::Database.format_boolean(topic_featured_link_allowed),
|
|
topic_id,
|
|
topic_template,
|
|
topic_title_placeholder,
|
|
uploaded_background_dark_id,
|
|
uploaded_background_id,
|
|
uploaded_logo_dark_id,
|
|
uploaded_logo_id,
|
|
user_id,
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|