Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add kind column to parent_levels_child_levels table #34649

Merged
merged 2 commits into from May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions dashboard/app/models/parent_levels_child_level.rb
Expand Up @@ -6,6 +6,7 @@
# parent_level_id :integer not null
# child_level_id :integer not null
# position :integer
# kind :string(255) default("sublevel"), not null
#
# Indexes
#
Expand Down
@@ -0,0 +1,5 @@
class AddKindToParentLevelsChildLevels < ActiveRecord::Migration[5.0]
def change
add_column :parent_levels_child_levels, :kind, :string, null: false, default: 'sublevel'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is default only used because the existing table needs to be backfilled? Just checking for my understanding.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default is so that if you do not specify a value, you'll get a sublevel, rather than a validation error, in the next PR #34650 . the unit tests there attempt to illustrate this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's slightly better to require a value, but not enough to ask you to change anything. Would be an interesting topic to discuss for next time this comes up, if you feel differently.

end
end
7 changes: 4 additions & 3 deletions dashboard/db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20200503222610) do
ActiveRecord::Schema.define(version: 20200504010945) do

create_table "activities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" do |t|
t.integer "user_id"
Expand Down Expand Up @@ -622,9 +622,10 @@
end

create_table "parent_levels_child_levels", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" do |t|
t.integer "parent_level_id", null: false
t.integer "child_level_id", null: false
t.integer "parent_level_id", null: false
t.integer "child_level_id", null: false
t.integer "position"
t.string "kind", default: "sublevel", null: false
t.index ["child_level_id"], name: "index_parent_levels_child_levels_on_child_level_id", using: :btree
t.index ["parent_level_id"], name: "index_parent_levels_child_levels_on_parent_level_id", using: :btree
end
Expand Down