mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 13:38:18 -08:00
Add category/subcategory ID columns to uniquely identify records
This commit is contained in:
parent
516e0a95db
commit
4fd6dac791
4 changed files with 20 additions and 1 deletions
|
|
@ -0,0 +1,8 @@
|
|||
class AddCategoryIdToSqmCategory < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :sqm_categories, :category_id, :string, default: 'default-category-id', null: false
|
||||
|
||||
# give everything a default value
|
||||
change_column_default :sqm_categories, :category_id, from: 'default-category-id', to: nil
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
class AddSubcategoryIdToSubcategory < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :subcategories, :subcategory_id, :string, default: 'default-subcategory-id', null: false
|
||||
|
||||
change_column_default :subcategories, :subcategory_id, from: 'default-subcategory-id', to: nil
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_11_02_130307) do
|
||||
ActiveRecord::Schema.define(version: 2021_11_04_181819) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
@ -221,6 +221,7 @@ ActiveRecord::Schema.define(version: 2021_11_02_130307) do
|
|||
t.integer "sort_index"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.string "category_id", null: false
|
||||
t.index ["slug"], name: "index_sqm_categories_on_slug", unique: true
|
||||
end
|
||||
|
||||
|
|
@ -242,6 +243,7 @@ ActiveRecord::Schema.define(version: 2021_11_02_130307) do
|
|||
t.text "description"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.string "subcategory_id", null: false
|
||||
end
|
||||
|
||||
create_table "survey_item_responses", id: :serial, force: :cascade do |t|
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ FactoryBot.define do
|
|||
|
||||
factory :sqm_category do
|
||||
name { "A #{rand} category" }
|
||||
category_id { rand.to_s }
|
||||
description { "A description of a category" }
|
||||
slug { "a-#{rand}-category" }
|
||||
sort_index { 1 }
|
||||
|
|
@ -25,6 +26,7 @@ FactoryBot.define do
|
|||
|
||||
factory :subcategory do
|
||||
name { "A subcategory" }
|
||||
subcategory_id { rand.to_s }
|
||||
description { "A description of a subcategory" }
|
||||
sqm_category
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue