Skip to content

Instantly share code, notes, and snippets.

Dropping Migration Table, Models, Controller

Command Line

1. Drop Table/Migration

rails generate migration DropTablename

A file will be created, in the db > migrate folder, make sure it looks like:

@d-m-u
d-m-u / gist:d51a7d20e56b9946cf5136f5897b7628
Created July 16, 2020 22:13
testing migration issues part 300
without the schema symlink: `REGION=702 bundle exec rake db:migrate`
fails in the same way... so it's not our code. and I can't change regions so I have to test this ... some other way.
so if i run it locally and spin up vms
I will have to create relationships
or if you could rspec this somehow?
-- Converting ems_ref_obj to ems_ref_type for MigrateEmsRefObjToEmsRefType::Host
-> 1.1567s
Failures:
1) ManageIQ::Providers::Inventory::Persister tests we can serialize inventory object with nested lazy references
Failure/Error: self.miq_group ||= tenant_group || current_user_group || ems_tenant_group || root_tenant_group
ActiveModel::MissingAttributeError:
missing attribute: miq_group_id
# /Users/drewmu/.rvm/gems/ruby-2.5.5/gems/activerecord-5.2.4.3/lib/active_record/attribute_methods/read.rb:77:in `block in _read_attribute'
# /Users/drewmu/.rvm/gems/ruby-2.5.5/gems/activemodel-5.2.4.3/lib/active_model/attribute_set.rb:48:in `block in fetch_value'
# /Users/drewmu/.rvm/gems/ruby-2.5.5/gems/activemodel-5.2.4.3/lib/active_model/attribute.rb:222:in `value'
@d-m-u
d-m-u / gist:84bc154c4d32622aa5a0f8f7e0e3110b
Created November 19, 2019 19:33
custom button add error
FATAL -- : Error caught: [NoMethodError] undefined method `[]' for nil:NilClass
/Users/duhlmann/.rvm/gems/ruby-2.5.7/bundler/gems/manageiq-ui-classic-6e87da71221f/app/controllers/application_controller/buttons.rb:478:in `button_create_update'
/Users/duhlmann/.rvm/gems/ruby-2.5.7/bundler/gems/manageiq-ui-classic-6e87da71221f/app/controllers/application_controller/buttons.rb:190:in `button_create'
/Users/duhlmann/.rvm/gems/ruby-2.5.7/gems/actionpack-5.1.7/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
/Users/duhlmann/.rvm/gems/ruby-2.5.7/gems/actionpack-5.1.7/lib/abstract_controller/base.rb:186:in `process_action'
/Users/duhlmann/.rvm/gems/ruby-2.5.7/gems/actionpack-5.1.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
/Users/duhlmann/.rvm/gems/ruby-2.5.7/gems/actionpack-5.1.7/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/Users/duhlmann/.rvm/gems/ruby-2.5.7/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:131:in `run_callbacks'
/Users/duh
@d-m-u
d-m-u / gist:5782340cb21cd836be75fe3c96663617
Created October 1, 2019 11:03
automate domain import ImportFileUpload error
[2019-10-01T07:01:20.382292 #81380:3fddf931d640] ERROR -- : MIQ(miq_ae_tools_controller-automate_json): Error: import processing failed: Couldn't find ImportFileUpload with 'id'=8
@d-m-u
d-m-u / gist:13dea93840fb8a1795a2be6c31a732c8
Created October 1, 2019 10:53
undefined method `lookup_by_userid'
F, [2019-10-01T06:50:58.317694 #78907:3ff75b85dea4] FATAL -- : Error caught: [NoMethodError] undefined method `lookup_by_userid' for #<Class:0x00007feeb5d30b48>
Did you mean? lookup_by_identity
/Users/duhlmann/.rvm/gems/ruby-2.5.3/gems/activerecord-5.1.7/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
/Users/duhlmann/manageiq-ui-classic/app/services/user_validation_service.rb:36:in `validate_user'
/Users/duhlmann/manageiq-ui-classic/app/controllers/dashboard_controller.rb:658:in `validate_user'
/Users/duhlmann/manageiq-ui-classic/app/controllers/dashboard_controller.rb:545:in `authenticate'
/Users/duhlmann/.rvm/gems/ruby-2.5.3/gems/actionpack-5.1.7/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
/Users/duhlmann/.rvm/gems/ruby-2.5.3/gems/actionpack-5.1.7/lib/abstract_controller/base.rb:186:in `process_action'
/Users/duhlmann/.rvm/gems/ruby-2.5.3/gems/actionpack-5.1.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
/Users/duhlmann/.rvm/gems/ruby-2.5.3/gems/
@d-m-u
d-m-u / not working.md
Last active September 4, 2019 11:17
rails 2.5.5 threading things

2.5.5 rails console output from simulate_queue_worker

the first ~180 lines

** Delivering Message id: [92],  id: [], Zone: [], Role: [], Server: [], MiqTask id: [], Ident: [generic], Target id: [], Instance id: [18], Task id: [], Command: [ServiceTemplateProvisionRequest.call_automate_event], Timeout: [3600], Priority: [100], State: [ready], Deliver On: [], Data: [], Args: ["request_created"]

  ServiceTemplateProvisionRequest Load (1.8ms)  SELECT  "miq_requests".* FROM "miq_requests" WHERE "miq_requests"."type" IN ('ServiceTemplateProvisionRequest', 'ServiceTemplateTransformationPlanRequest') AND "miq_requests"."id" = $1 LIMIT $2  [["id", 18], ["LIMIT", 1]]
  ServiceTemplateProvisionRequest Inst Including Associations (44.6ms - 1rows)
def ==(o)
o = Rufus::Scheduler.parse(o)
o.seconds == @seconds &&
(o.zone == @zone || o.zone.current_period == @zone.current_period)
end
rather than what got merged on Friday:
https://github.com/ManageIQ/manageiq/blob/master/config/initializers/convert_time_to_eo.rb#L6
@d-m-u
d-m-u / gist:13e049f48a918afb8a05895e85ceffef
Last active July 31, 2019 13:52
`convert_to_uri': bad argument (expected URI object or URI string) (ArgumentError)
log/automation.log:[----] E, [2019-07-30T20:38:44.620116 #58697:3fe44cd408e4] ERROR -- : <AEMethod miq_provision_customize_body> The following error occurred during method evaluation:
log/automation.log:[----] E, [2019-07-30T20:38:44.620931 #58697:3fe44cd408e4] ERROR -- : <AEMethod miq_provision_customize_body> ArgumentError: bad argument (expected URI object or URI string)
log/automation.log:[----] E, [2019-07-30T20:38:44.621754 #58697:3fe44cd408e4] ERROR -- : <AEMethod miq_provision_customize_body> (drbunix:///var/folders/n5/1rtj753d4s569vt8njt3_gs80000gn/T/automation_engine20190730-58697-8w69uj) /Users/duhlmann/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/uri/rfc3986_parser.rb:119:in `convert_to_uri'
log/automation.log:[----] E, [2019-07-30T20:38:44.625736 #58697:3fe44cd408e4] ERROR -- : Method STDERR: (drbunix:///var/folders/n5/1rtj753d4s569vt8njt3_gs80000gn/T/automation_engine20190730-58697-8w69uj) /Users/duhlmann/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/uri/rfc3986_parser.rb:119:in `convert_to_uri': bad argum
@d-m-u
d-m-u / gist:d6b96f907d014b62c9a6e0a8c571c9fe
Created July 26, 2019 19:44
Openstack::NetworkManager::RefreshParser ovirt
[----] D, [2019-07-26T15:41:07.313880 #84904:3ffd8a465b50] DEBUG -- : (0.7ms) SELECT "miq_product_features"."identifier" FROM "miq_product_features" INNER JOIN "miq_roles_features" ON "miq_product_features"."id" = "miq_roles_features"."miq_product_feature_id" WHERE "miq_roles_features"."miq_user_role_id" = $1 [["miq_user_role_id", 1]]
[----] F, [2019-07-26T15:41:07.325757 #84904:3ffd8a465b50] FATAL -- : Error caught: [NameError] uninitialized constant ManageIQ::Providers::Openstack::NetworkManager::RefreshParser
/Users/duhlmann/.rvm/gems/ruby-2.5.5/bundler/gems/manageiq-providers-ovirt-8313271cb048/app/models/manageiq/providers/redhat/network_manager/refresh_parser.rb:2:in `<module:Providers>'
/Users/duhlmann/.rvm/gems/ruby-2.5.5/bundler/gems/manageiq-providers-ovirt-8313271cb048/app/models/manageiq/providers/redhat/network_manager/refresh_parser.rb:1:in `<top (required)>'
/Users/duhlmann/.rvm/gems/ruby-2.5.5/gems/activesupport-5.1.7/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
/