0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 03:25:17 +08:00
discourse/db/migrate/20210527131318_create_directory_columns.rb
David Taylor e01d1e9763
DEV: Move automatic directory_columns rows from migration to seed fixture (#39970)
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.
2026-05-13 12:12:56 +01:00

21 lines
654 B
Ruby
Vendored

# frozen_string_literal: true
class CreateDirectoryColumns < ActiveRecord::Migration[6.1]
def up
create_table :directory_columns do |t|
t.string :name, null: true
t.integer :automatic_position, null: true
t.string :icon, null: true
t.integer :user_field_id, null: true
t.boolean :automatic, null: false
t.boolean :enabled, null: false
t.integer :position, null: false
t.datetime :created_at, default: -> { "CURRENT_TIMESTAMP" }
end
add_index :directory_columns, %i[enabled position user_field_id], name: "directory_column_index"
end
def down
drop_table :directory_columns
end
end