class CreateEcomModelMenus < ActiveRecord::Migration[6.0] def change create_table :ecom_model_menus do |t| t.string :label, null: false t.string :icon t.string :route, null: false t.references :parent, index: { name: 'menus_on_menus_indx' } t.references :application_module, index: { name: 'menus_on_am_indx' } t.timestamps end add_foreign_key :ecom_model_menus, :ecom_model_menus, column: :parent_id add_foreign_key :ecom_model_menus, :ecom_model_application_modules, column: :application_module_id create_table :ecom_model_menus_user_roles, id: false do |t| t.references :menu, index: false t.references :user_role, index: false end add_index :ecom_model_menus_user_roles, %i[menu_id user_role_id], unique: true, name: 'menus_user_roles_indx' add_foreign_key :ecom_model_menus_user_roles, :ecom_model_menus, column: :menu_id add_foreign_key :ecom_model_menus_user_roles, :ecom_model_user_roles, column: :user_role_id end end