Add classes to simplify table migration and manipulation for upgrades

This commit is contained in:
Eric 2020-05-04 16:27:07 -05:00
parent 30c489a5a1
commit fd6888938f
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,15 @@
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
module HoudiniUpgrade
class ColumnToMigrate
attr_reader :name
def initialize(original_column_name)
@name = original_column_name.to_s
end
def migrated_name
@name + "_temp"
end
end
end

View file

@ -0,0 +1,25 @@
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
require_relative "./column_to_migrate"
module HoudiniUpgrade
class TableToMigrate
attr_reader :fields, :name
def initialize(original_table_name, original_field_names)
@name = original_table_name.to_s
@fields = original_field_names.map{|i| ColumnToMigrate.new(i)}
end
def class_name
@name.classify
end
def backup_table
@name + "_uploader_backups"
end
def foreign_key
@name + "_id"
end
end
end