diff --git a/app/controllers/addresses_controller.rb b/app/controllers/addresses_controller.rb deleted file mode 100644 index 9600752dd..000000000 --- a/app/controllers/addresses_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class AddressesController < ApplicationController -end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb deleted file mode 100644 index 83e326d1e..000000000 --- a/app/controllers/organizations_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class OrganizationsController < ApplicationController -end diff --git a/app/models/organization.rb b/app/models/organization.rb index a9008ed8c..2836a1621 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -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 diff --git a/app/models/organization_workshop.rb b/app/models/organization_workshop.rb new file mode 100644 index 000000000..88f864b5f --- /dev/null +++ b/app/models/organization_workshop.rb @@ -0,0 +1,4 @@ +class OrganizationWorkshop < ApplicationRecord + belongs_to :organization + belongs_to :workshop +end diff --git a/app/models/workshop.rb b/app/models/workshop.rb index 9cad06782..cdad5e72e 100644 --- a/app/models/workshop.rb +++ b/app/models/workshop.rb @@ -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 diff --git a/db/migrate/20250914130435_change_organizations_id_to_integer.rb b/db/migrate/20250914130435_change_organizations_id_to_integer.rb new file mode 100644 index 000000000..66cdc04c4 --- /dev/null +++ b/db/migrate/20250914130435_change_organizations_id_to_integer.rb @@ -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 diff --git a/db/migrate/20250914131648_create_organization_workshops.rb b/db/migrate/20250914131648_create_organization_workshops.rb new file mode 100644 index 000000000..bfb77855a --- /dev/null +++ b/db/migrate/20250914131648_create_organization_workshops.rb @@ -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 diff --git a/db/migrate/20250914132157_change_facilitators_id_to_integer.rb b/db/migrate/20250914132157_change_facilitators_id_to_integer.rb new file mode 100644 index 000000000..d7a6a8c4c --- /dev/null +++ b/db/migrate/20250914132157_change_facilitators_id_to_integer.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 223820a45..27a7a13d2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,26 +10,25 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2025_09_13_171135) do - +ActiveRecord::Schema[8.1].define(version: 2025_09_14_132157) do create_table "addresses", charset: "utf8mb3", force: :cascade do |t| - t.bigint "organization_id", null: false - t.string "street", null: false t.string "city", null: false - t.string "state", null: false - t.string "zip", null: false t.string "country" - t.string "locality" t.string "county" + t.datetime "created_at", null: false t.integer "la_city_council_district" - t.integer "la_supervisorial_district" t.integer "la_service_planning_area" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.integer "la_supervisorial_district" + t.string "locality" + t.integer "organization_id", null: false + t.string "state", null: false + t.string "street", null: false + t.datetime "updated_at", null: false + t.string "zip", null: false t.index ["organization_id"], name: "index_addresses_on_organization_id" end - create_table "admins", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "admins", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil t.datetime "current_sign_in_at", precision: nil t.string "current_sign_in_ip" @@ -48,7 +47,7 @@ t.index ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true end - create_table "age_ranges", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "age_ranges", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.string "name" t.datetime "updated_at", precision: nil, null: false @@ -56,14 +55,14 @@ t.index ["windows_type_id"], name: "index_age_ranges_on_windows_type_id" end - create_table "answer_options", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "answer_options", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.string "name" t.integer "order" t.datetime "updated_at", precision: nil, null: false end - create_table "attachments", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "attachments", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.string "file_content_type" t.string "file_file_name" @@ -74,14 +73,14 @@ t.datetime "updated_at", precision: nil, null: false end - create_table "banners", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "banners", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.text "content" t.datetime "created_at", precision: nil, null: false t.boolean "show" t.datetime "updated_at", precision: nil, null: false end - create_table "bookmark_annotations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "bookmark_annotations", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.text "annotation", size: :medium t.integer "bookmark_id" t.datetime "created_at", precision: nil, null: false @@ -89,7 +88,7 @@ t.index ["bookmark_id"], name: "index_bookmark_annotations_on_bookmark_id" end - create_table "bookmarks", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "bookmarks", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.integer "bookmarkable_id" t.string "bookmarkable_type" t.datetime "created_at", precision: nil, null: false @@ -98,7 +97,7 @@ t.index ["user_id"], name: "index_bookmarks_on_user_id" end - create_table "categories", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "categories", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "legacy_id" t.integer "metadatum_id" @@ -108,7 +107,7 @@ t.index ["metadatum_id"], name: "index_categories_on_metadatum_id" end - create_table "categorizable_items", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "categorizable_items", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.integer "categorizable_id" t.string "categorizable_type" t.integer "category_id" @@ -119,7 +118,7 @@ t.index ["category_id"], name: "index_categorizable_items_on_category_id" end - create_table "ckeditor_assets", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "ckeditor_assets", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "actual_url" t.integer "assetable_id" t.string "assetable_type", limit: 30 @@ -135,7 +134,7 @@ t.index ["assetable_type", "type", "assetable_id"], name: "idx_ckeditor_assetable_type" end - create_table "event_registrations", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "event_registrations", charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", null: false t.string "email" t.bigint "event_id" @@ -145,7 +144,7 @@ t.index ["event_id"], name: "index_event_registrations_on_event_id" end - create_table "events", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "events", charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", null: false t.text "description" t.datetime "end_date", precision: nil @@ -157,16 +156,16 @@ end create_table "facilitator_organizations", charset: "utf8mb3", force: :cascade do |t| - t.bigint "facilitator_id", null: false - t.bigint "organization_id", null: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.integer "facilitator_id", null: false + t.integer "organization_id", null: false + t.datetime "updated_at", null: false t.index ["facilitator_id", "organization_id"], name: "index_facilitator_organizations_on_ids", unique: true t.index ["facilitator_id"], name: "index_facilitator_organizations_on_facilitator_id" t.index ["organization_id"], name: "index_facilitator_organizations_on_organization_id" end - create_table "facilitators", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "facilitators", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "city", null: false t.string "country", null: false t.datetime "created_at", null: false @@ -183,7 +182,7 @@ t.string "zip", null: false end - create_table "faqs", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "faqs", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.text "answer", size: :medium t.datetime "created_at", precision: nil, null: false t.boolean "inactive" @@ -192,7 +191,7 @@ t.datetime "updated_at", precision: nil, null: false end - create_table "footers", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "footers", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "adult_program" t.string "children_program" t.datetime "created_at", precision: nil, null: false @@ -201,7 +200,7 @@ t.datetime "updated_at", precision: nil, null: false end - create_table "form_builders", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "form_builders", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.text "description", size: :medium t.string "name" @@ -211,7 +210,7 @@ t.index ["windows_type_id"], name: "index_form_builders_on_windows_type_id" end - create_table "form_field_answer_options", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "form_field_answer_options", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.integer "answer_option_id" t.datetime "created_at", precision: nil, null: false t.integer "form_field_id" @@ -220,7 +219,7 @@ t.index ["form_field_id"], name: "index_form_field_answer_options_on_form_field_id" end - create_table "form_fields", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "form_fields", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.integer "answer_datatype" t.integer "answer_type" t.datetime "created_at", precision: nil, null: false @@ -235,7 +234,7 @@ t.index ["form_id"], name: "index_form_fields_on_form_id" end - create_table "forms", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "forms", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "form_builder_id" t.integer "owner_id" @@ -244,7 +243,7 @@ t.index ["form_builder_id"], name: "index_forms_on_form_builder_id" end - create_table "images", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "images", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.string "file_content_type" t.string "file_file_name" @@ -257,7 +256,7 @@ t.index ["owner_id"], name: "index_images_on_owner_id" end - create_table "locations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "locations", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "city" t.string "country" t.datetime "created_at", precision: nil, null: false @@ -265,7 +264,7 @@ t.datetime "updated_at", precision: nil, null: false end - create_table "media_files", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "media_files", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "file_content_type" t.string "file_file_name" t.integer "file_file_size" @@ -274,7 +273,7 @@ t.integer "workshop_log_id" end - create_table "metadata", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "metadata", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.string "legacy_id" t.string "name" @@ -282,7 +281,7 @@ t.datetime "updated_at", precision: nil, null: false end - create_table "monthly_reports", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "monthly_reports", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "best_call_time" t.boolean "call_requested" t.text "comments", size: :medium @@ -305,7 +304,7 @@ t.index ["project_user_id"], name: "index_monthly_reports_on_project_user_id" end - create_table "notifications", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "notifications", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "noticeable_id" t.string "noticeable_type" @@ -313,41 +312,51 @@ t.datetime "updated_at", precision: nil, null: false end - create_table "organizations", charset: "utf8mb3", force: :cascade do |t| - t.string "name", null: false - t.boolean "is_active", default: true - t.date "start_date" - t.date "close_date" - t.string "website_url" + create_table "organization_workshops", charset: "utf8mb3", force: :cascade do |t| + t.datetime "created_at", null: false + t.integer "organization_id", null: false + t.datetime "updated_at", null: false + t.integer "workshop_id", null: false + t.index ["organization_id", "workshop_id"], name: "index_organization_workshops_on_ids", unique: true + t.index ["organization_id"], name: "index_organization_workshops_on_organization_id" + t.index ["workshop_id"], name: "index_organization_workshops_on_workshop_id" + end + + create_table "organizations", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "agency_type", null: false t.string "agency_type_other" - t.string "phone", null: false + t.date "close_date" + t.datetime "created_at", null: false + t.boolean "is_active", default: true t.text "mission" + t.string "name", null: false + t.string "phone", null: false t.string "project_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.date "start_date" + t.datetime "updated_at", null: false + t.string "website_url" end - create_table "permissions", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "permissions", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "legacy_id" t.string "security_cat" t.datetime "updated_at", precision: nil, null: false end - create_table "project_obligations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "project_obligations", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.string "name" t.datetime "updated_at", precision: nil, null: false end - create_table "project_statuses", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "project_statuses", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.string "name" t.datetime "updated_at", precision: nil, null: false end - create_table "project_users", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "project_users", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.integer "agency_id" t.datetime "created_at", precision: nil, null: false t.string "filemaker_code" @@ -360,7 +369,7 @@ t.index ["user_id"], name: "index_project_users_on_user_id" end - create_table "projects", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "projects", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.text "description", size: :medium t.string "district" @@ -382,7 +391,7 @@ t.index ["windows_type_id"], name: "index_projects_on_windows_type_id" end - create_table "quotable_item_quotes", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "quotable_item_quotes", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "legacy_id" t.integer "quotable_id" @@ -392,7 +401,7 @@ t.index ["quote_id"], name: "index_quotable_item_quotes_on_quote_id" end - create_table "quotes", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "quotes", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "age" t.datetime "created_at", precision: nil, null: false t.string "gender", limit: 1 @@ -406,7 +415,7 @@ t.index ["workshop_id"], name: "index_quotes_on_workshop_id" end - create_table "report_form_field_answers", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "report_form_field_answers", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.text "answer", size: :medium t.integer "answer_option_id" t.datetime "created_at", precision: nil @@ -418,7 +427,7 @@ t.index ["report_id"], name: "index_report_form_field_answers_on_report_id" end - create_table "reports", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "reports", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.integer "adults_first_time", default: 0 t.integer "adults_ongoing", default: 0 t.integer "children_first_time", default: 0 @@ -448,7 +457,7 @@ t.index ["windows_type_id"], name: "index_reports_on_windows_type_id" end - create_table "resources", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "resources", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "agency" t.string "author" t.datetime "created_at", precision: nil, null: false @@ -473,7 +482,7 @@ t.index ["workshop_id"], name: "index_resources_on_workshop_id" end - create_table "sectorable_items", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "sectorable_items", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.boolean "inactive", default: true t.integer "sector_id" @@ -483,14 +492,14 @@ t.index ["sector_id"], name: "index_sectorable_items_on_sector_id" end - create_table "sectors", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "sectors", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.string "name" t.boolean "published", default: false t.datetime "updated_at", precision: nil, null: false end - create_table "user_form_form_fields", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "user_form_form_fields", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "form_field_id" t.text "text", size: :medium @@ -500,7 +509,7 @@ t.index ["user_form_id"], name: "index_user_form_form_fields_on_user_form_id" end - create_table "user_forms", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "user_forms", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "form_id" t.datetime "updated_at", precision: nil, null: false @@ -509,7 +518,7 @@ t.index ["user_id"], name: "index_user_forms_on_user_id" end - create_table "user_permissions", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "user_permissions", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "permission_id" t.datetime "updated_at", precision: nil, null: false @@ -518,7 +527,7 @@ t.index ["user_id"], name: "index_user_permissions_on_user_id" end - create_table "users", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "users", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.string "address" t.string "address2" t.integer "agency_id" @@ -537,7 +546,7 @@ t.string "current_sign_in_ip" t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false - t.bigint "facilitator_id" + t.integer "facilitator_id" t.string "first_name", default: "" t.boolean "inactive", default: false t.string "last_name", default: "" @@ -567,7 +576,7 @@ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end - create_table "windows_types", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "windows_types", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "legacy_id" t.string "name" @@ -575,7 +584,7 @@ t.datetime "updated_at", precision: nil, null: false end - create_table "workshop_age_ranges", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "workshop_age_ranges", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.integer "age_range_id" t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false @@ -584,7 +593,7 @@ t.index ["workshop_id"], name: "index_workshop_age_ranges_on_workshop_id" end - create_table "workshop_logs", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "workshop_logs", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.text "challenges", size: :medium t.text "comments", size: :medium t.datetime "created_at", precision: nil, null: false @@ -609,7 +618,7 @@ t.index ["workshop_id"], name: "index_workshop_logs_on_workshop_id" end - create_table "workshop_resources", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "workshop_resources", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "resource_id" t.datetime "updated_at", precision: nil, null: false @@ -618,7 +627,7 @@ t.index ["workshop_id"], name: "index_workshop_resources_on_workshop_id" end - create_table "workshop_variations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "workshop_variations", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.text "code", size: :medium t.datetime "created_at", precision: nil, null: false t.boolean "inactive", default: true @@ -631,7 +640,7 @@ t.index ["workshop_id"], name: "index_workshop_variations_on_workshop_id" end - create_table "workshops", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "workshops", id: :integer, charset: "utf8mb3", force: :cascade do |t| t.text "age_range", size: :medium t.text "age_range_spanish", size: :medium t.string "author_location" @@ -730,6 +739,8 @@ add_foreign_key "forms", "form_builders" add_foreign_key "monthly_reports", "project_users" add_foreign_key "monthly_reports", "projects" + add_foreign_key "organization_workshops", "organizations" + add_foreign_key "organization_workshops", "workshops" add_foreign_key "project_users", "projects" add_foreign_key "project_users", "projects", column: "agency_id" add_foreign_key "project_users", "users" diff --git a/spec/factories/workshops.rb b/spec/factories/workshops.rb index 513e7b650..50b76fb54 100644 --- a/spec/factories/workshops.rb +++ b/spec/factories/workshops.rb @@ -16,5 +16,10 @@ thumbnail_file_name { nil } header_file_name { nil } + trait :with_organization do + after(:create) do |workshop| + workshop.organizations << create(:organization) + end + end end end \ No newline at end of file diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb index 4f8432ee4..9420c6366 100644 --- a/spec/models/organization_spec.rb +++ b/spec/models/organization_spec.rb @@ -5,6 +5,8 @@ it { should have_many(:addresses).dependent(:destroy) } it { should have_many(:facilitator_organizations).dependent(:restrict_with_exception) } it { should have_many(:facilitators).through(:facilitator_organizations) } + it { should have_many(:organization_workshops).dependent(:restrict_with_exception) } + it { should have_many(:workshops).through(:organization_workshops) } end describe 'validations' do diff --git a/spec/models/organization_workshop_spec.rb b/spec/models/organization_workshop_spec.rb new file mode 100644 index 000000000..f6fb12860 --- /dev/null +++ b/spec/models/organization_workshop_spec.rb @@ -0,0 +1,8 @@ +require 'rails_helper' + +RSpec.describe OrganizationWorkshop, type: :model do + describe 'associations' do + it { should belong_to(:organization) } + it { should belong_to(:workshop) } + end +end \ No newline at end of file diff --git a/spec/models/workshop_spec.rb b/spec/models/workshop_spec.rb index 4c7898c7c..4e1c7754f 100644 --- a/spec/models/workshop_spec.rb +++ b/spec/models/workshop_spec.rb @@ -28,6 +28,8 @@ it { should have_many(:quotes).through(:quotable_item_quotes) } it { should have_many(:workshop_resources).dependent(:destroy) } it { should have_many(:resources).through(:workshop_resources) } + it { should have_many(:organization_workshops).dependent(:restrict_with_exception) } + it { should have_many(:organizations).through(:organization_workshops) } it { should have_many(:attachments).dependent(:destroy) } # As owner it { should have_many(:workshop_age_ranges) }