diff --git a/app/models/room_advert.rb b/app/models/room_advert.rb index 53450456..9b2ac80d 100644 --- a/app/models/room_advert.rb +++ b/app/models/room_advert.rb @@ -7,6 +7,7 @@ class RoomAdvert < ApplicationRecord validates :contact, presence: true validates :description, presence: true validates :publicly_visible, inclusion: [true, false] + validates :available_from, presence: true scope :publicly_visible, (-> { where(publicly_visible: true) }) end diff --git a/db/migrate/20241018155243_update_room_adverts_available_from_string_to_date.rb b/db/migrate/20241018155243_update_room_adverts_available_from_string_to_date.rb new file mode 100644 index 00000000..7505d3b8 --- /dev/null +++ b/db/migrate/20241018155243_update_room_adverts_available_from_string_to_date.rb @@ -0,0 +1,7 @@ +class UpdateRoomAdvertsAvailableFromStringToDate < ActiveRecord::Migration[7.0] + def change + remove_column :room_adverts, :available_from, :string + add_column :room_adverts, :available_from, :date + change_column_null :room_adverts, :available_from, false + end +end diff --git a/db/schema.rb b/db/schema.rb index 3cb6bb07..428b436a 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.0].define(version: 2024_03_28_205012) do +ActiveRecord::Schema[7.0].define(version: 2024_10_18_155243) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -490,7 +490,6 @@ t.string "house_name", null: false t.string "contact", null: false t.string "location" - t.string "available_from" t.string "description", null: false t.string "cover_photo" t.boolean "publicly_visible" @@ -498,6 +497,7 @@ t.datetime "deleted_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.date "available_from", null: false end create_table "static_pages", id: :serial, force: :cascade do |t|