Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add simple column defaults... still need to verify none had prior db … #721

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions db/migrate/20240228190145_add_column_defaults.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
class AddColumnDefaults < ActiveRecord::Migration[6.1]
def change
change_column_default :assigned_server_roles, :active, :from => nil, :to => false
change_column_default :blacklisted_events, :enabled, :from => nil, :to => true
change_column_default :classifications, :read_only, :from => nil, :to => false
change_column_default :classifications, :show, :from => nil, :to => true
change_column_default :classifications, :single_value, :from => nil, :to => false
change_column_default :classifications, :syntax, :from => nil, :to => "string"
change_column_default :cloud_database_flavors, :enabled, :from => nil, :to => true # STI class
change_column_default :dialog_fields, :load_values_on_init, :from => nil, :to => true # STI class, inherited
change_column_default :dialog_fields, :required, :from => nil, :to => false #
change_column_default :dialog_fields, :visible, :from => nil, :to => true # STI class, inherited
change_column_default :dialogs, :system, :from => nil, :to => false
change_column_default :endpoints, :verify_ssl, :from => nil, :to => 1
change_column_default :ext_management_systems, :enabled, :from => nil, :to => true # STI class, inherited
change_column_default :flavors, :enabled, :from => nil, :to => true # STI class
change_column_default :git_repositories, :verify_ssl, :from => nil, :to => 1
change_column_default :miq_approvals, :state, :from => nil, :to => "pending"
change_column_default :miq_groups, :group_type, :from => nil, :to => "user"
change_column_default :miq_policies, :active, :from => nil, :to => true
change_column_default :miq_policies, :mode, :from => nil, :to => 'control'
change_column_default :miq_policies, :towhat, :from => nil, :to => 'Vm'
change_column_default :miq_request_tasks, :state, :from => nil, :to => 'pending'
change_column_default :miq_request_tasks, :status, :from => nil, :to => 'Ok'
change_column_default :miq_requests, :process, :from => nil, :to => true
change_column_default :miq_requests, :request_state, :from => nil, :to => 'pending'
change_column_default :miq_requests, :status, :from => nil, :to => 'Ok'
change_column_default :miq_schedules, :enabled, :from => nil, :to => true
change_column_default :miq_schedules, :userid, :from => nil, :to => "system"
change_column_default :miq_servers, :name, :from => nil, :to => "EVM"
change_column_default :miq_user_roles, :read_only, :from => nil, :to => false
change_column_default :miq_widgets, :enabled, :from => nil, :to => true
change_column_default :miq_widgets, :read_only, :from => nil, :to => false
change_column_default :notification_recipients, :seen, :from => nil, :to => false
change_column_default :orchestration_templates, :draft, :from => nil, :to => false
change_column_default :orchestration_templates, :orderable, :from => nil, :to => true
change_column_default :pxe_servers, :customization_directory, :from => nil, :to => ""
change_column_default :service_resources, :group_idx, :from => nil, :to => 0
change_column_default :service_resources, :provision_index, :from => nil, :to => 0
change_column_default :service_resources, :scaling_max, :from => nil, :to => -1
change_column_default :service_resources, :scaling_min, :from => nil, :to => 1
change_column_default :service_templates, :internal, :from => nil, :to => false
change_column_default :service_templates, :service_type, :from => nil, :to => 'atomic'
change_column_default :services, :initiator, :from => nil, :to => 'user'
change_column_default :services, :lifecycle_state, :from => nil, :to => 'unprovisioned'
change_column_default :services, :retired, :from => nil, :to => false
change_column_default :services, :visible, :from => nil, :to => false
change_column_default :shares, :allow_tenant_inheritance, :from => nil, :to => false
change_column_default :system_consoles, :opened, :from => nil, :to => false
change_column_default :tenants, :description, :from => nil, :to => "Tenant for My Company"
change_column_default :tenants, :divisible, :from => nil, :to => true
change_column_default :tenants, :name, :from => nil, :to => "My Company"
change_column_default :tenants, :use_config_for_attributes, :from => nil, :to => false
change_column_default :users, :failed_login_attempts, :from => nil, :to => 0
change_column_default :zones, :visible, :from => nil, :to => true
end
end
39 changes: 39 additions & 0 deletions spec/migrations/20240228190145_add_column_defaults_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require_migration

# This is mostly necessary for data migrations, so feel free to delete this
# file if you do no need it.
describe AddColumnDefaults do
# let(:my_model_stub) { migration_stub(:MyModel) }

migration_context :up do
# Create data
#
# Example:
#
# my_model_stub.create!(attributes)

migrate

# Ensure data exists
#
# Example:
#
# expect(record).to have_attributes()
end

migration_context :down do
# Create data
#
# Example:
#
# my_model_stub.create!(attributes)

migrate

# Ensure data exists
#
# Example:
#
# expect(MyModel.count).to eq(0)
end
end
Loading