Skip to content

Commit

Permalink
Fix: room advert available_from type (#439)
Browse files Browse the repository at this point in the history
* write migration for changing available_from to a date

* just to be sure the migration does not fail

* even better

* I suppose this is also needed

* finally, figure out how to create a reversible migration

* oke en nu is ie ook non-null 😄
  • Loading branch information
DrumsnChocolate authored Oct 29, 2024
1 parent 153319a commit c18d2b4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/models/room_advert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -490,14 +490,14 @@
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"
t.integer "author_id"
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|
Expand Down

0 comments on commit c18d2b4

Please sign in to comment.