mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-18 19:31:16 +08:00
Previously, `20210527131318_create_directory_columns.rb` both created the table and inserted the seven default automatic columns, mixing schema and data in a single migration. This change moves the rows to `db/fixtures/008_directory_columns.rb`, gated by a hidden `directory_columns_seeded` site setting so admin customizations (renamed, reordered, or disabled columns) survive subsequent `db:seed` runs. A companion `20260513101242_mark_existing_sites_directory_columns_seeded.rb` flips the flag on existing sites so the seed bails immediately on the upgrade deploy. Extracted from https://github.com/discourse/discourse/pull/39788.
24 lines
764 B
Ruby
Vendored
24 lines
764 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
return if SiteSetting.directory_columns_seeded
|
|
|
|
[
|
|
{ name: "likes_received", position: 1, icon: "heart" },
|
|
{ name: "likes_given", position: 2, icon: "heart" },
|
|
{ name: "topic_count", position: 3, icon: nil },
|
|
{ name: "post_count", position: 4, icon: nil },
|
|
{ name: "topics_entered", position: 5, icon: nil },
|
|
{ name: "posts_read", position: 6, icon: nil },
|
|
{ name: "days_visited", position: 7, icon: nil },
|
|
].each do |column|
|
|
DirectoryColumn.seed(:name) do |c|
|
|
c.name = column[:name]
|
|
c.automatic_position = column[:position]
|
|
c.position = column[:position]
|
|
c.icon = column[:icon]
|
|
c.enabled = true
|
|
c.type = DirectoryColumn.types[:automatic]
|
|
end
|
|
end
|
|
|
|
SiteSetting.directory_columns_seeded = true
|