DEV: Plugin API to add directory columns (#13440)

This commit is contained in:
Mark VanLandingham
2021-06-22 13:00:04 -05:00
committed by GitHub
parent fe5923da06
commit 7fc3d7bdde
33 changed files with 452 additions and 195 deletions

View File

@@ -0,0 +1,22 @@
# frozen_string_literal: true
class ReintroduceTypeToDirectoryColumns < ActiveRecord::Migration[6.1]
def up
if !ActiveRecord::Base.connection.column_exists?(:directory_columns, :type)
# A migration that added this column was previously merged and reverted.
# Some sites have this column and some do not, so only add if missing.
add_column :directory_columns, :type, :integer, default: 0, null: false
end
DB.exec(
<<~SQL
UPDATE directory_columns
SET type = CASE WHEN automatic THEN 0 ELSE 1 END;
SQL
)
end
def down
remove_column :directory_columns, :type
end
end