Halfway through table redesign, saving to revert to working version

This commit is contained in:
Jason Jordan
2026-03-05 11:30:24 -05:00
parent ea07afb751
commit b5a1517330
86 changed files with 1286 additions and 884 deletions
@@ -1,57 +0,0 @@
# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
def change
# Use Active Record's configured type for primary and foreign keys
primary_key_type, foreign_key_type = primary_and_foreign_key_types
create_table :active_storage_blobs, id: primary_key_type do |t|
t.string :key, null: false
t.string :filename, null: false
t.string :content_type
t.text :metadata
t.string :service_name, null: false
t.bigint :byte_size, null: false
t.string :checksum
if connection.supports_datetime_with_precision?
t.datetime :created_at, precision: 6, null: false
else
t.datetime :created_at, null: false
end
t.index [ :key ], unique: true
end
create_table :active_storage_attachments, id: primary_key_type do |t|
t.string :name, null: false
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
t.references :blob, null: false, type: foreign_key_type
if connection.supports_datetime_with_precision?
t.datetime :created_at, precision: 6, null: false
else
t.datetime :created_at, null: false
end
t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
create_table :active_storage_variant_records, id: primary_key_type do |t|
t.belongs_to :blob, null: false, index: false, type: foreign_key_type
t.string :variation_digest, null: false
t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end
private
def primary_and_foreign_key_types
config = Rails.configuration.generators
setting = config.options[config.orm][:primary_key_type]
primary_key_type = setting || :primary_key
foreign_key_type = setting || :bigint
[ primary_key_type, foreign_key_type ]
end
end
@@ -1,26 +0,0 @@
# This migration comes from action_text (originally 20180528164100)
class CreateActionTextTables < ActiveRecord::Migration[6.0]
def change
# Use Active Record's configured type for primary and foreign keys
primary_key_type, foreign_key_type = primary_and_foreign_key_types
create_table :action_text_rich_texts, id: primary_key_type do |t|
t.string :name, null: false
t.text :body, size: :long
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
t.timestamps
t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
end
end
private
def primary_and_foreign_key_types
config = Rails.configuration.generators
setting = config.options[config.orm][:primary_key_type]
primary_key_type = setting || :primary_key
foreign_key_type = setting || :bigint
[ primary_key_type, foreign_key_type ]
end
end
@@ -1,22 +0,0 @@
# This migration comes from active_storage (originally 20190112182829)
class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
def up
return unless table_exists?(:active_storage_blobs)
unless column_exists?(:active_storage_blobs, :service_name)
add_column :active_storage_blobs, :service_name, :string
if configured_service = ActiveStorage::Blob.service.name
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
end
change_column :active_storage_blobs, :service_name, :string, null: false
end
end
def down
return unless table_exists?(:active_storage_blobs)
remove_column :active_storage_blobs, :service_name
end
end
@@ -1,27 +0,0 @@
# This migration comes from active_storage (originally 20191206030411)
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
def change
return unless table_exists?(:active_storage_blobs)
# Use Active Record's configured type for primary key
create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t|
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
t.string :variation_digest, null: false
t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end
private
def primary_key_type
config = Rails.configuration.generators
config.options[config.orm][:primary_key_type] || :primary_key
end
def blobs_primary_key_type
pkey_name = connection.primary_key(:active_storage_blobs)
pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
pkey_column.bigint? ? :bigint : pkey_column.type
end
end
@@ -1,8 +0,0 @@
# This migration comes from active_storage (originally 20211119233751)
class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
def change
return unless table_exists?(:active_storage_blobs)
change_column_null(:active_storage_blobs, :checksum, true)
end
end
@@ -1,9 +0,0 @@
class CreateIdCardBenefitsTemplates < ActiveRecord::Migration[7.2]
def change
create_table :id_card_benefits_templates do |t|
t.string :title
t.timestamps
end
end
end
@@ -1,12 +0,0 @@
class CreateIdCardBenefits < ActiveRecord::Migration[7.2]
def change
create_table :id_card_benefits do |t|
t.string :benefit_desc
t.string :benefit
t.integer :sequence
t.references :id_card_benefits_template, null: false, foreign_key: true
t.timestamps
end
end
end
@@ -2,24 +2,14 @@ class CreateEmployers < ActiveRecord::Migration[7.2]
def change
create_table :employers do |t|
t.string :name
t.string :id_card_display_name
t.string :slug
t.string :pl_plan_key
t.integer :company_pb_entity_key
t.integer :plan_id
t.string :group_number
t.string :rx_group_number
t.string :effective_date
t.string :employer_logo_filename
t.string :network_provider
t.string :default_network_logo
t.string :single_card_template
t.string :multiple_card_template
t.boolean :active, default: false
t.timestamps
end
end
-11
View File
@@ -1,11 +0,0 @@
class CreatePlans < ActiveRecord::Migration[7.2]
def change
create_table :plans do |t|
t.string :title
t.integer :pb_product_key
t.references :employer, null: false, foreign_key: true
t.timestamps
end
end
end
@@ -1,12 +0,0 @@
class CreatePlanBenefits < ActiveRecord::Migration[7.2]
def change
create_table :plan_benefits do |t|
t.string :benefit_desc
t.string :benefit
t.integer :sequence
t.references :plan, null: false, foreign_key: true
t.timestamps
end
end
end
@@ -1,6 +1,7 @@
class CreateCardProviders < ActiveRecord::Migration[7.2]
class CreateIdCardProviderSections < ActiveRecord::Migration[7.2]
def change
create_table :card_providers do |t|
create_table :id_card_provider_sections do |t|
t.string :title
t.string :provider_code
t.string :provider_line_1
t.string :provider_line_2
@@ -1,6 +1,6 @@
class CreateCardRxes < ActiveRecord::Migration[7.2]
class CreateIdCardRxSections < ActiveRecord::Migration[7.2]
def change
create_table :card_rxes do |t|
create_table :id_card_rx_sections do |t|
t.string :help_desk
t.string :customer_service
t.string :web_url
@@ -1,10 +1,10 @@
class CreateCardLogoFiles < ActiveRecord::Migration[7.2]
class CreateIdCardNetworkLogos < ActiveRecord::Migration[7.2]
def change
create_table :card_logo_files do |t|
create_table :id_card_network_logos do |t|
t.string :filename
t.binary :image_data
t.string :content_type
t.string :logo_type
t.float :aspect_ratio
t.boolean :active, default: false
t.timestamps
@@ -0,0 +1,13 @@
class CreateIdCardEmployerLogos < ActiveRecord::Migration[7.2]
def change
create_table :id_card_employer_logos do |t|
t.string :filename
t.binary :image_data
t.string :content_type
t.float :aspect_ratio
t.boolean :active, default: false
t.timestamps
end
end
end
@@ -0,0 +1,18 @@
class CreateIdCardSetups < ActiveRecord::Migration[7.2]
def change
create_table :id_card_setups do |t|
t.string :print_name
t.string :network_provider
t.string :card_template
t.string :rx_group_number
t.boolean :active, default: false
t.belongs_to :employer, null: false, foreign_key: true
t.belongs_to :id_card_employer_logo, null: true, foreign_key: true
t.belongs_to :id_card_network_logo, null: true, foreign_key: true
t.belongs_to :id_card_provider_section, null: false, foreign_key: true
t.belongs_to :id_card_rx_section, null: false, foreign_key: true
t.timestamps
end
end
end
@@ -0,0 +1,12 @@
class CreateIdCardPlans < ActiveRecord::Migration[7.2]
def change
create_table :id_card_plans do |t|
t.string :title
t.integer :pb_product_key
t.string :pl_plan_key
t.belongs_to :id_card_setup, null: true, foreign_key: true
t.timestamps
end
end
end
@@ -0,0 +1,12 @@
class CreateIdCardPlanBenefits < ActiveRecord::Migration[7.2]
def change
create_table :id_card_plan_benefits do |t|
t.string :benefit_desc
t.string :benefit
t.integer :sequence
t.belongs_to :id_card_plan, null: false, foreign_key: true
t.timestamps
end
end
end
@@ -1,12 +0,0 @@
class CreateNetworkLogos < ActiveRecord::Migration[7.0]
def change
create_table :alternate_network_logos do |t|
t.string :network_logo_filename
t.string :exception_type
t.string :exception_value
t.belongs_to :employer, null: false, foreign_key: true
t.timestamps
end
end
end
@@ -1,10 +1,12 @@
class CreateSampleIdCards < ActiveRecord::Migration[7.0]
class CreateIdCardPrintData < ActiveRecord::Migration[7.0]
def change
create_table :sample_id_cards do |t|
create_table :id_card_print_data do |t|
t.string :full_name
t.string :full_name_last_name_first
t.string :family_id
t.string :primary_mb_member_key
t.string :employer_name
t.string :pl_plan_key
t.string :group_number
t.string :rx_group
t.string :medical_eff_date
@@ -1,11 +0,0 @@
class CreateEmployerCardLogos < ActiveRecord::Migration[7.2]
def change
create_table :employer_card_logos do |t|
t.references :employer, null: false, foreign_key: true
t.references :card_logo_file, null: false, foreign_key: true
t.string :logo_type
t.timestamps
end
end
end
@@ -1,6 +0,0 @@
class AddCardRxToEmployers < ActiveRecord::Migration[7.2]
def change
add_reference :employers, :card_provider, null: true, foreign_key: true
add_reference :employers, :card_rx, null: true, foreign_key: true
end
end
+1 -1
View File
@@ -8,7 +8,7 @@ class CreateMembers < ActiveRecord::Migration[7.2]
t.integer :pb_entity_key
t.integer :pl_plan_key
t.belongs_to :employer, foreign_key: true
t.belongs_to :plan, null: true, foreign_key: true
t.belongs_to :id_card_plan, null: true, foreign_key: true
t.timestamps
end
@@ -1,11 +0,0 @@
class CreateCardExceptions < ActiveRecord::Migration[7.2]
def change
create_table :card_exceptions do |t|
t.string :type
t.string :value
t.belongs_to :employer, null: false, foreign_key: true
t.timestamps
end
end
end
@@ -0,0 +1,11 @@
class CreateIdCardExceptions < ActiveRecord::Migration[7.2]
def change
create_table :id_card_exceptions do |t|
t.string :type
t.string :value
t.belongs_to :id_card_setup, null: false, foreign_key: true
t.timestamps
end
end
end
@@ -1,13 +0,0 @@
class CreateCardExceptionItems < ActiveRecord::Migration[7.2]
def change
create_table :card_exception_items do |t|
t.string :field_name
t.string :field_value
t.belongs_to :card_exception, null: false, foreign_key: true
t.belongs_to :card_logo_file, null: true, foreign_key: true
t.belongs_to :card_provider, null: true, foreign_key: true
t.timestamps
end
end
end
@@ -0,0 +1,13 @@
class CreateIdCardExceptionItems < ActiveRecord::Migration[7.2]
def change
create_table :id_card_exception_items do |t|
t.string :field_name
t.string :field_value
t.belongs_to :id_card_exception, null: false, foreign_key: true
t.belongs_to :id_card_network_logo, null: true, foreign_key: true
t.belongs_to :id_card_provider_section, null: true, foreign_key: true
t.timestamps
end
end
end
@@ -1,5 +0,0 @@
class AddAspectRatioToCardLogoFiles < ActiveRecord::Migration[7.2]
def change
add_column :card_logo_files, :aspect_ratio, :float
end
end
@@ -1,5 +0,0 @@
class AddLastNameToSampleIdCard < ActiveRecord::Migration[7.2]
def change
add_column :sample_id_cards, :name, :string
end
end
@@ -1,5 +0,0 @@
class RenameCardFieldExceptionsToCardExceptionItems < ActiveRecord::Migration[7.2]
def change
rename_table :card_field_exceptions, :card_exception_items
end
end
@@ -1,5 +0,0 @@
class AddTitleToCardProviders < ActiveRecord::Migration[7.2]
def change
add_column :card_providers, :title, :string
end
end