From 89a75b73262d2ffdd9b5c80f144320ef9c70639f Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 15 Nov 2022 15:19:53 +0000 Subject: [PATCH] Add location_deactivations table and remove deactivation_date from locations --- app/models/location_deactivation.rb | 2 ++ .../20221115101732_add_deactivations_table.rb | 10 ++++++++++ .../20221115113437_remove_deactivatio_date.rb | 13 +++++++++++++ db/schema.rb | 12 ++++++++++-- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 app/models/location_deactivation.rb create mode 100644 db/migrate/20221115101732_add_deactivations_table.rb create mode 100644 db/migrate/20221115113437_remove_deactivatio_date.rb diff --git a/app/models/location_deactivation.rb b/app/models/location_deactivation.rb new file mode 100644 index 000000000..f5dbdb54f --- /dev/null +++ b/app/models/location_deactivation.rb @@ -0,0 +1,2 @@ +class LocationDeactivation < ApplicationRecord +end diff --git a/db/migrate/20221115101732_add_deactivations_table.rb b/db/migrate/20221115101732_add_deactivations_table.rb new file mode 100644 index 000000000..c961869e0 --- /dev/null +++ b/db/migrate/20221115101732_add_deactivations_table.rb @@ -0,0 +1,10 @@ +class AddDeactivationsTable < ActiveRecord::Migration[7.0] + def change + create_table :location_deactivations do |t| + t.datetime :deactivation_date + t.datetime :reactivation_date + t.belongs_to :location + t.timestamps + end + end +end diff --git a/db/migrate/20221115113437_remove_deactivatio_date.rb b/db/migrate/20221115113437_remove_deactivatio_date.rb new file mode 100644 index 000000000..c21c671bb --- /dev/null +++ b/db/migrate/20221115113437_remove_deactivatio_date.rb @@ -0,0 +1,13 @@ +class RemoveDeactivatioDate < ActiveRecord::Migration[7.0] + def up + change_table :locations, bulk: true do |t| + t.remove :deactivation_date + end + end + + def down + change_table :locations, bulk: true do |t| + t.column :deactivation_date, :datetime + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1ff8f157c..17a18e968 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: 2022_11_11_102656) do +ActiveRecord::Schema[7.0].define(version: 2022_11_15_113437) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -245,6 +245,15 @@ ActiveRecord::Schema[7.0].define(version: 2022_11_11_102656) do t.index ["scheme_id"], name: "index_lettings_logs_on_scheme_id" end + create_table "location_deactivations", force: :cascade do |t| + t.datetime "deactivation_date" + t.datetime "reactivation_date" + t.bigint "location_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["location_id"], name: "index_location_deactivations_on_location_id" + end + create_table "locations", force: :cascade do |t| t.string "location_code" t.string "postcode" @@ -260,7 +269,6 @@ ActiveRecord::Schema[7.0].define(version: 2022_11_11_102656) do t.datetime "startdate", precision: nil t.string "location_admin_district" t.boolean "confirmed" - t.datetime "deactivation_date" t.index ["old_id"], name: "index_locations_on_old_id", unique: true t.index ["scheme_id"], name: "index_locations_on_scheme_id" end