Skip to content

A platform for community discussion. Free, open, simple.

FIX: Correct migration schema defaults and missing user option (#43945)

Alan Guo Xiang Tand549d645c1f8
diff --git a/migrations/converters/lib/migrations/converters/discourse/steps/user_options.rb b/migrations/converters/lib/migrations/converters/discourse/steps/user_options.rb
index 4dd718381f8..d577016df60 100644
--- a/migrations/converters/lib/migrations/converters/discourse/steps/user_options.rb
+++ b/migrations/converters/lib/migrations/converters/discourse/steps/user_options.rb
@@ -34,6 +34,7 @@ module Migrations
enable_upcoming_change_available_notifications:
item[:enable_upcoming_change_available_notifications],
external_links_in_new_tab: item[:external_links_in_new_tab],
+ hidden_composer_toolbar_buttons: item[:hidden_composer_toolbar_buttons],
hide_presence: item[:hide_presence],
hide_profile: item[:hide_profile],
hide_profile_and_presence: item[:hide_profile_and_presence],
diff --git a/migrations/core/db/intermediate_db_schema/100-base-schema.sql b/migrations/core/db/intermediate_db_schema/100-base-schema.sql
index 5970d4f5d0a..3e4f85a6e7d 100644
--- a/migrations/core/db/intermediate_db_schema/100-base-schema.sql
+++ b/migrations/core/db/intermediate_db_schema/100-base-schema.sql
@@ -583,6 +583,7 @@ CREATE TABLE user_options
enable_smart_lists BOOLEAN,
enable_upcoming_change_available_notifications BOOLEAN,
external_links_in_new_tab BOOLEAN,
+ hidden_composer_toolbar_buttons TEXT,
hide_presence BOOLEAN,
hide_profile BOOLEAN,
hide_profile_and_presence BOOLEAN,
diff --git a/migrations/core/lib/migrations/database/intermediate_db/user_option.rb b/migrations/core/lib/migrations/database/intermediate_db/user_option.rb
index 54de3de11ca..1d0931d63d3 100644
--- a/migrations/core/lib/migrations/database/intermediate_db/user_option.rb
+++ b/migrations/core/lib/migrations/database/intermediate_db/user_option.rb
@@ -34,6 +34,7 @@ module Migrations
enable_smart_lists,
enable_upcoming_change_available_notifications,
external_links_in_new_tab,
+ hidden_composer_toolbar_buttons,
hide_presence,
hide_profile,
hide_profile_and_presence,
@@ -65,7 +66,7 @@ module Migrations
watched_precedence_over_muted
)
VALUES (
- ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
+ ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)
SQL
private_constant :SQL
@@ -96,6 +97,7 @@ module Migrations
# @param enable_smart_lists [Boolean, nil]
# @param enable_upcoming_change_available_notifications [Boolean, nil]
# @param external_links_in_new_tab [Boolean, nil]
+ # @param hidden_composer_toolbar_buttons [String, nil]
# @param hide_presence [Boolean, nil]
# @param hide_profile [Boolean, nil]
# @param hide_profile_and_presence [Boolean, nil]
@@ -152,6 +154,7 @@ module Migrations
enable_smart_lists: nil,
enable_upcoming_change_available_notifications: nil,
external_links_in_new_tab: nil,
+ hidden_composer_toolbar_buttons: nil,
hide_presence: nil,
hide_profile: nil,
hide_profile_and_presence: nil,
@@ -208,6 +211,7 @@ module Migrations
Migrations::Database.format_boolean(enable_smart_lists),
Migrations::Database.format_boolean(enable_upcoming_change_available_notifications),
Migrations::Database.format_boolean(external_links_in_new_tab),
+ hidden_composer_toolbar_buttons,
Migrations::Database.format_boolean(hide_presence),
Migrations::Database.format_boolean(hide_profile),
Migrations::Database.format_boolean(hide_profile_and_presence),
diff --git a/migrations/tooling/lib/migrations/tooling/schema/dsl/schema_resolver.rb b/migrations/tooling/lib/migrations/tooling/schema/dsl/schema_resolver.rb
index 9b977a8d90f..e3fcbda1968 100644
--- a/migrations/tooling/lib/migrations/tooling/schema/dsl/schema_resolver.rb
+++ b/migrations/tooling/lib/migrations/tooling/schema/dsl/schema_resolver.rb
@@ -127,7 +127,7 @@ module Migrations
# Columns with defaults are treated as nullable because converters
# don't need to supply a value — the DB default will apply.
- nullable = required.nil? ? db_col.null || db_col.default.present? : !required
+ nullable = required.nil? ? db_col.null || db_col.default.to_s.present? : !required
max_length = (max_length_override || db_col.limit if datatype == :text)