Skip to content
Open
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
2 changes: 0 additions & 2 deletions app/controllers/addresses_controller.rb
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this controller deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an empty controller not serving any purpose, so I actually never meant to include it in the initial PR, and thought we could add it back in if we need it in the future.

This file was deleted.

2 changes: 0 additions & 2 deletions app/controllers/organizations_controller.rb
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want the organizations controller anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mean to include an empty controller in the last PR, so my thinking was that I'd remove it until we actually need it.

This file was deleted.

2 changes: 2 additions & 0 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class Organization < ApplicationRecord
has_many :addresses, dependent: :destroy
has_many :facilitator_organizations, dependent: :restrict_with_exception
has_many :facilitators, through: :facilitator_organizations
has_many :organization_workshops, dependent: :restrict_with_exception
has_many :workshops, through: :organization_workshops

validates :name, presence: true
validates :agency_type, presence: true
Expand Down
4 changes: 4 additions & 0 deletions app/models/organization_workshop.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class OrganizationWorkshop < ApplicationRecord
belongs_to :organization
belongs_to :workshop
end
3 changes: 3 additions & 0 deletions app/models/workshop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Workshop < ApplicationRecord
has_many :workshop_resources, dependent: :destroy
has_many :resources, through: :workshop_resources

has_many :organization_workshops, dependent: :restrict_with_exception
has_many :organizations, through: :organization_workshops

belongs_to :windows_type
has_many :attachments, as: :owner, dependent: :destroy
has_many :workshop_age_ranges
Expand Down
16 changes: 16 additions & 0 deletions db/migrate/20250914130435_change_organizations_id_to_integer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class ChangeOrganizationsIdToInteger < ActiveRecord::Migration[8.1]
def change
# Drop foreign keys first
remove_foreign_key :addresses, :organizations
remove_foreign_key :facilitator_organizations, :organizations

# Change column types
change_column :organizations, :id, :integer
change_column :addresses, :organization_id, :integer
change_column :facilitator_organizations, :organization_id, :integer

# Re-add foreign keys
add_foreign_key :addresses, :organizations
add_foreign_key :facilitator_organizations, :organizations
end
end
12 changes: 12 additions & 0 deletions db/migrate/20250914131648_create_organization_workshops.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateOrganizationWorkshops < ActiveRecord::Migration[8.1]
def change
create_table :organization_workshops do |t|
t.references :organization, null: false, foreign_key: true, type: :integer
t.references :workshop, null: false, foreign_key: true, type: :integer

t.timestamps
end

add_index :organization_workshops, [:organization_id, :workshop_id], unique: true, name: 'index_organization_workshops_on_ids'
end
end
16 changes: 16 additions & 0 deletions db/migrate/20250914132157_change_facilitators_id_to_integer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class ChangeFacilitatorsIdToInteger < ActiveRecord::Migration[8.1]
def change
# Drop foreign keys first
remove_foreign_key :facilitator_organizations, :facilitators
remove_foreign_key :users, :facilitators

# Change column types
change_column :facilitators, :id, :integer
change_column :facilitator_organizations, :facilitator_id, :integer
change_column :users, :facilitator_id, :integer

# Re-add foreign keys
add_foreign_key :facilitator_organizations, :facilitators
add_foreign_key :users, :facilitators
end
end
Loading