From 37f13716e87e92d1305a781cf6e5f74a1291343e Mon Sep 17 00:00:00 2001 From: Liam Morley Date: Tue, 2 Nov 2021 09:05:56 -0400 Subject: [PATCH] Add timestamps to all SQM models --- .../20211102125207_add_timestamps_to_measures.rb | 10 ++++++++++ ...0211102130223_add_timestamps_to_sqm_categories.rb | 10 ++++++++++ ...20211102130232_add_timestamps_to_subcategories.rb | 10 ++++++++++ .../20211102130250_add_timestamps_to_survey_items.rb | 10 ++++++++++ ...130307_add_timestamps_to_survey_item_responses.rb | 10 ++++++++++ db/schema.rb | 12 +++++++++++- 6 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20211102125207_add_timestamps_to_measures.rb create mode 100644 db/migrate/20211102130223_add_timestamps_to_sqm_categories.rb create mode 100644 db/migrate/20211102130232_add_timestamps_to_subcategories.rb create mode 100644 db/migrate/20211102130250_add_timestamps_to_survey_items.rb create mode 100644 db/migrate/20211102130307_add_timestamps_to_survey_item_responses.rb diff --git a/db/migrate/20211102125207_add_timestamps_to_measures.rb b/db/migrate/20211102125207_add_timestamps_to_measures.rb new file mode 100644 index 00000000..9c804bd1 --- /dev/null +++ b/db/migrate/20211102125207_add_timestamps_to_measures.rb @@ -0,0 +1,10 @@ +class AddTimestampsToMeasures < ActiveRecord::Migration[6.1] + def change + now = Time.zone.now + change_table :measures do |t| + t.timestamps default: now + end + change_column_default :measures, :created_at, from: now, to: nil + change_column_default :measures, :updated_at, from: now, to: nil + end +end diff --git a/db/migrate/20211102130223_add_timestamps_to_sqm_categories.rb b/db/migrate/20211102130223_add_timestamps_to_sqm_categories.rb new file mode 100644 index 00000000..f359f487 --- /dev/null +++ b/db/migrate/20211102130223_add_timestamps_to_sqm_categories.rb @@ -0,0 +1,10 @@ +class AddTimestampsToSqmCategories < ActiveRecord::Migration[6.1] + def change + now = Time.zone.now + change_table :sqm_categories do |t| + t.timestamps default: now + end + change_column_default :sqm_categories, :created_at, from: now, to: nil + change_column_default :sqm_categories, :updated_at, from: now, to: nil + end +end diff --git a/db/migrate/20211102130232_add_timestamps_to_subcategories.rb b/db/migrate/20211102130232_add_timestamps_to_subcategories.rb new file mode 100644 index 00000000..ca29301c --- /dev/null +++ b/db/migrate/20211102130232_add_timestamps_to_subcategories.rb @@ -0,0 +1,10 @@ +class AddTimestampsToSubcategories < ActiveRecord::Migration[6.1] + def change + now = Time.zone.now + change_table :subcategories do |t| + t.timestamps default: now + end + change_column_default :subcategories, :created_at, from: now, to: nil + change_column_default :subcategories, :updated_at, from: now, to: nil + end +end diff --git a/db/migrate/20211102130250_add_timestamps_to_survey_items.rb b/db/migrate/20211102130250_add_timestamps_to_survey_items.rb new file mode 100644 index 00000000..1fc28730 --- /dev/null +++ b/db/migrate/20211102130250_add_timestamps_to_survey_items.rb @@ -0,0 +1,10 @@ +class AddTimestampsToSurveyItems < ActiveRecord::Migration[6.1] + def change + now = Time.zone.now + change_table :survey_items do |t| + t.timestamps default: now + end + change_column_default :survey_items, :created_at, from: now, to: nil + change_column_default :survey_items, :updated_at, from: now, to: nil + end +end diff --git a/db/migrate/20211102130307_add_timestamps_to_survey_item_responses.rb b/db/migrate/20211102130307_add_timestamps_to_survey_item_responses.rb new file mode 100644 index 00000000..59dd30d0 --- /dev/null +++ b/db/migrate/20211102130307_add_timestamps_to_survey_item_responses.rb @@ -0,0 +1,10 @@ +class AddTimestampsToSurveyItemResponses < ActiveRecord::Migration[6.1] + def change + now = Time.zone.now + change_table :survey_item_responses do |t| + t.timestamps default: now + end + change_column_default :survey_item_responses, :created_at, from: now, to: nil + change_column_default :survey_item_responses, :updated_at, from: now, to: nil + end +end diff --git a/db/schema.rb b/db/schema.rb index 81b6e61c..4daa96b5 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.define(version: 2021_10_29_195454) do +ActiveRecord::Schema.define(version: 2021_11_02_130307) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -80,6 +80,8 @@ ActiveRecord::Schema.define(version: 2021_10_29_195454) do t.float "ideal_low_benchmark" t.integer "subcategory_id", null: false t.text "description" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false t.index ["measure_id"], name: "index_measures_on_measure_id" t.index ["subcategory_id"], name: "index_measures_on_subcategory_id" end @@ -217,6 +219,8 @@ ActiveRecord::Schema.define(version: 2021_10_29_195454) do t.text "description" t.string "slug" t.integer "sort_index" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false t.index ["slug"], name: "index_sqm_categories_on_slug", unique: true end @@ -236,6 +240,8 @@ ActiveRecord::Schema.define(version: 2021_10_29_195454) do t.string "name" t.integer "sqm_category_id" t.text "description" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false end create_table "survey_item_responses", id: :serial, force: :cascade do |t| @@ -244,6 +250,8 @@ ActiveRecord::Schema.define(version: 2021_10_29_195454) do t.integer "survey_item_id", null: false t.string "response_id", null: false t.integer "academic_year_id", null: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false t.index ["academic_year_id"], name: "index_survey_item_responses_on_academic_year_id" t.index ["response_id"], name: "index_survey_item_responses_on_response_id" t.index ["school_id"], name: "index_survey_item_responses_on_school_id" @@ -254,6 +262,8 @@ ActiveRecord::Schema.define(version: 2021_10_29_195454) do t.integer "measure_id", null: false t.string "survey_item_id", null: false t.string "prompt" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false t.index ["measure_id"], name: "index_survey_items_on_measure_id" t.index ["survey_item_id"], name: "index_survey_items_on_survey_item_id" end