From 1ef9bfa8212d2e0018d110e3202a0d5ce803cdeb Mon Sep 17 00:00:00 2001 From: Lucy Stringer Date: Sun, 17 Nov 2024 15:43:22 +0000 Subject: [PATCH 1/5] feat: add requests fields to bookings --- ...20241117145434_add_requests_to_bookings.rb | 22 +++++++++++++++++++ db/schema.rb | 22 ++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20241117145434_add_requests_to_bookings.rb diff --git a/db/migrate/20241117145434_add_requests_to_bookings.rb b/db/migrate/20241117145434_add_requests_to_bookings.rb new file mode 100644 index 0000000..99c0d22 --- /dev/null +++ b/db/migrate/20241117145434_add_requests_to_bookings.rb @@ -0,0 +1,22 @@ +class AddRequestsToBookings < ActiveRecord::Migration[7.1] + def change + create_enum :lark_or_owl, ["lark", "owl", "neither"] + create_enum :massage_house, ["yes", "no", "don't mind"] + create_enum :late_n_loud, ["yes", "no", "don't mind"] + create_enum :chillout_house, ["yes", "no", "don't mind"] + create_enum :hot_tub_house, ["yes", "no", "don't mind"] + create_enum :sharing_bed, ["double", "two singles"] + create_enum :dog_house, ["yes", "no", "don't mind"] + + add_column :bookings, :lark_or_owl, :enum, enum_type: :lark_or_owl, null: false + add_column :bookings, :massage_house, :enum, enum_type: :massage_house, null: false + add_column :bookings, :late_n_loud, :enum, enum_type: :late_n_loud, null: false + add_column :bookings, :chillout_house, :enum, enum_type: :chillout_house, null: false + add_column :bookings, :dog_house, :enum, enum_type: :dog_house, null: false + add_column :bookings, :hot_tub_house, :enum, enum_type: :hot_tub_house, null: false + add_column :bookings, :family_room, :boolean + add_column :bookings, :sharing_with, :string + add_column :bookings, :sharing_bed, :enum, enum_type: :sharing_bed + add_column :bookings, :comments, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index ab90e7e..06546ed 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,21 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_11_17_083008) do +ActiveRecord::Schema[7.1].define(version: 2024_11_17_145434) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" + # Custom types defined in this database. + # Note that some types may not work with other database engines. Be careful if changing database. + create_enum "chillout_house", ["yes", "no", "don't mind"] + create_enum "dog_house", ["yes", "no", "don't mind"] + create_enum "hot_tub_house", ["yes", "no", "don't mind"] + create_enum "lark_or_owl", ["lark", "owl", "neither"] + create_enum "late_n_loud", ["yes", "no", "don't mind"] + create_enum "massage_house", ["yes", "no", "don't mind"] + create_enum "sharing_bed", ["double", "two singles"] + create_table "bookings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.date "arrival" t.date "departure" @@ -27,6 +37,16 @@ t.boolean "assistance_claim" t.boolean "single_person" t.integer "dog" + t.enum "lark_or_owl", null: false, enum_type: "lark_or_owl" + t.enum "massage_house", null: false, enum_type: "massage_house" + t.enum "late_n_loud", null: false, enum_type: "late_n_loud" + t.enum "chillout_house", null: false, enum_type: "chillout_house" + t.enum "dog_house", null: false, enum_type: "dog_house" + t.enum "hot_tub_house", null: false, enum_type: "hot_tub_house" + t.boolean "family_room" + t.string "sharing_with" + t.enum "sharing_bed", enum_type: "sharing_bed" + t.string "comments" t.index ["event_id"], name: "index_bookings_on_event_id" t.index ["user_id"], name: "index_bookings_on_user_id" end From 26a3dc70e853434a3700a35a2ec06333d493264f Mon Sep 17 00:00:00 2001 From: Lucy Stringer Date: Sun, 17 Nov 2024 16:30:54 +0000 Subject: [PATCH 2/5] fix: temp rollback migration to fix db state --- db/schema.rb | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 06546ed..c51a8e6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,21 +10,11 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_11_17_145434) do +ActiveRecord::Schema[7.1].define(version: 2024_11_17_083008) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" - # Custom types defined in this database. - # Note that some types may not work with other database engines. Be careful if changing database. - create_enum "chillout_house", ["yes", "no", "don't mind"] - create_enum "dog_house", ["yes", "no", "don't mind"] - create_enum "hot_tub_house", ["yes", "no", "don't mind"] - create_enum "lark_or_owl", ["lark", "owl", "neither"] - create_enum "late_n_loud", ["yes", "no", "don't mind"] - create_enum "massage_house", ["yes", "no", "don't mind"] - create_enum "sharing_bed", ["double", "two singles"] - create_table "bookings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.date "arrival" t.date "departure" @@ -32,21 +22,11 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.uuid "event_id", null: false - t.boolean "cancellable" t.integer "assistance_donate" - t.boolean "assistance_claim" - t.boolean "single_person" t.integer "dog" - t.enum "lark_or_owl", null: false, enum_type: "lark_or_owl" - t.enum "massage_house", null: false, enum_type: "massage_house" - t.enum "late_n_loud", null: false, enum_type: "late_n_loud" - t.enum "chillout_house", null: false, enum_type: "chillout_house" - t.enum "dog_house", null: false, enum_type: "dog_house" - t.enum "hot_tub_house", null: false, enum_type: "hot_tub_house" - t.boolean "family_room" - t.string "sharing_with" - t.enum "sharing_bed", enum_type: "sharing_bed" - t.string "comments" + t.boolean "single_person" + t.boolean "assistance_claim" + t.boolean "cancellable" t.index ["event_id"], name: "index_bookings_on_event_id" t.index ["user_id"], name: "index_bookings_on_user_id" end From 5060cdfee6febb1f334a201c6bf88eedcec03deb Mon Sep 17 00:00:00 2001 From: Lucy Stringer Date: Sun, 17 Nov 2024 16:42:04 +0000 Subject: [PATCH 3/5] fix: temp remove migration to rebase branch --- ...20241117145434_add_requests_to_bookings.rb | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 db/migrate/20241117145434_add_requests_to_bookings.rb diff --git a/db/migrate/20241117145434_add_requests_to_bookings.rb b/db/migrate/20241117145434_add_requests_to_bookings.rb deleted file mode 100644 index 99c0d22..0000000 --- a/db/migrate/20241117145434_add_requests_to_bookings.rb +++ /dev/null @@ -1,22 +0,0 @@ -class AddRequestsToBookings < ActiveRecord::Migration[7.1] - def change - create_enum :lark_or_owl, ["lark", "owl", "neither"] - create_enum :massage_house, ["yes", "no", "don't mind"] - create_enum :late_n_loud, ["yes", "no", "don't mind"] - create_enum :chillout_house, ["yes", "no", "don't mind"] - create_enum :hot_tub_house, ["yes", "no", "don't mind"] - create_enum :sharing_bed, ["double", "two singles"] - create_enum :dog_house, ["yes", "no", "don't mind"] - - add_column :bookings, :lark_or_owl, :enum, enum_type: :lark_or_owl, null: false - add_column :bookings, :massage_house, :enum, enum_type: :massage_house, null: false - add_column :bookings, :late_n_loud, :enum, enum_type: :late_n_loud, null: false - add_column :bookings, :chillout_house, :enum, enum_type: :chillout_house, null: false - add_column :bookings, :dog_house, :enum, enum_type: :dog_house, null: false - add_column :bookings, :hot_tub_house, :enum, enum_type: :hot_tub_house, null: false - add_column :bookings, :family_room, :boolean - add_column :bookings, :sharing_with, :string - add_column :bookings, :sharing_bed, :enum, enum_type: :sharing_bed - add_column :bookings, :comments, :string - end -end From c97e040e11c59870d9cabd694650528024e0ad3d Mon Sep 17 00:00:00 2001 From: Lucy Stringer Date: Sun, 17 Nov 2024 16:47:50 +0000 Subject: [PATCH 4/5] feat: add request fields to bookings --- ...20241117164534_add_requests_to_bookings.rb | 22 +++++++++++++++++++ db/schema.rb | 19 +++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20241117164534_add_requests_to_bookings.rb diff --git a/db/migrate/20241117164534_add_requests_to_bookings.rb b/db/migrate/20241117164534_add_requests_to_bookings.rb new file mode 100644 index 0000000..99c0d22 --- /dev/null +++ b/db/migrate/20241117164534_add_requests_to_bookings.rb @@ -0,0 +1,22 @@ +class AddRequestsToBookings < ActiveRecord::Migration[7.1] + def change + create_enum :lark_or_owl, ["lark", "owl", "neither"] + create_enum :massage_house, ["yes", "no", "don't mind"] + create_enum :late_n_loud, ["yes", "no", "don't mind"] + create_enum :chillout_house, ["yes", "no", "don't mind"] + create_enum :hot_tub_house, ["yes", "no", "don't mind"] + create_enum :sharing_bed, ["double", "two singles"] + create_enum :dog_house, ["yes", "no", "don't mind"] + + add_column :bookings, :lark_or_owl, :enum, enum_type: :lark_or_owl, null: false + add_column :bookings, :massage_house, :enum, enum_type: :massage_house, null: false + add_column :bookings, :late_n_loud, :enum, enum_type: :late_n_loud, null: false + add_column :bookings, :chillout_house, :enum, enum_type: :chillout_house, null: false + add_column :bookings, :dog_house, :enum, enum_type: :dog_house, null: false + add_column :bookings, :hot_tub_house, :enum, enum_type: :hot_tub_house, null: false + add_column :bookings, :family_room, :boolean + add_column :bookings, :sharing_with, :string + add_column :bookings, :sharing_bed, :enum, enum_type: :sharing_bed + add_column :bookings, :comments, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 72ee567..6ada847 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_11_17_160817) do +ActiveRecord::Schema[7.1].define(version: 2024_11_17_164534) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -19,6 +19,13 @@ # Note that some types may not work with other database engines. Be careful if changing database. create_enum "assistance_claim", ["yes", "no"] create_enum "cancellable", ["yes", "no"] + create_enum "chillout_house", ["yes", "no", "don't mind"] + create_enum "dog_house", ["yes", "no", "don't mind"] + create_enum "hot_tub_house", ["yes", "no", "don't mind"] + create_enum "lark_or_owl", ["lark", "owl", "neither"] + create_enum "late_n_loud", ["yes", "no", "don't mind"] + create_enum "massage_house", ["yes", "no", "don't mind"] + create_enum "sharing_bed", ["double", "two singles"] create_enum "single_person", ["yes", "no"] create_table "bookings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| @@ -33,6 +40,16 @@ t.enum "cancellable", null: false, enum_type: "cancellable" t.enum "assistance_claim", null: false, enum_type: "assistance_claim" t.enum "single_person", null: false, enum_type: "single_person" + t.enum "lark_or_owl", null: false, enum_type: "lark_or_owl" + t.enum "massage_house", null: false, enum_type: "massage_house" + t.enum "late_n_loud", null: false, enum_type: "late_n_loud" + t.enum "chillout_house", null: false, enum_type: "chillout_house" + t.enum "dog_house", null: false, enum_type: "dog_house" + t.enum "hot_tub_house", null: false, enum_type: "hot_tub_house" + t.boolean "family_room" + t.string "sharing_with" + t.enum "sharing_bed", enum_type: "sharing_bed" + t.string "comments" t.index ["event_id"], name: "index_bookings_on_event_id" t.index ["user_id"], name: "index_bookings_on_user_id" end From 76b47a67779e9967d9ebe7891f88a01604bab045 Mon Sep 17 00:00:00 2001 From: Lucy Stringer Date: Sun, 17 Nov 2024 16:58:41 +0000 Subject: [PATCH 5/5] feat: update bookings model & controller with request fields --- app/controllers/bookings_controller.rb | 25 +++++++++++++++++++++++-- app/models/booking.rb | 3 ++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/controllers/bookings_controller.rb b/app/controllers/bookings_controller.rb index d814e87..39e3be9 100644 --- a/app/controllers/bookings_controller.rb +++ b/app/controllers/bookings_controller.rb @@ -55,7 +55,17 @@ def booking_params :assistance_donate, :assistance_claim, :single_person, - :dog) + :dog, + :lark_or_owl, + :massage_house, + :late_n_loud, + :chillout_house, + :dog_house, + :hot_tub_house, + :family_room, + :sharing_with, + :sharing_bed, + :comments) end def new_booking @@ -67,6 +77,17 @@ def new_booking assistance_donate: params[:booking][:assistance_donate], assistance_claim: params[:booking][:assistance_claim], single_person: params[:booking][:single_person], - dog: params[:booking][:dog]) + dog: params[:booking][:dog], + lark_or_owl: params[:booking][:lark_or_owl], + massage_house: params[:booking][:massage_house], + late_n_loud: params[:booking][:late_n_loud], + chillout_house: params[:booking][:chillout_house], + dog_house: params[:booking][:dog_house], + hot_tub_house: params[:booking][:hot_tub_house], + family_room: params[:booking][:family_room], + sharing_with: params[:booking][:sharing_with], + sharing_bed: params[:booking][:sharing_bed], + comments: params[:booking][:comments] + ) end end diff --git a/app/models/booking.rb b/app/models/booking.rb index d6f13e0..23eeaf9 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -4,5 +4,6 @@ class Booking < ApplicationRecord belongs_to :user belongs_to :event - validates :arrival, :departure, :cancellable, :assistance_claim, :single_person, :dog, presence: true + validates :arrival, :departure, :cancellable, :assistance_claim, :single_person, :dog, :lark_or_owl, :massage_house, + :late_n_loud, :chillout_house, :dog_house, :hot_tub_house, :family_room, presence: true end