Chore: Add default value for label color (#981)

This commit is contained in:
Pranav Raj S
2020-06-25 21:33:56 +05:30
committed by GitHub
parent 97ad39713b
commit 0aab717bb3
3 changed files with 14 additions and 3 deletions

View File

@@ -3,7 +3,7 @@
# Table name: labels
#
# id :bigint not null, primary key
# color :string
# color :string default("#1f93ff"), not null
# description :text
# show_on_sidebar :boolean
# title :string

View File

@@ -0,0 +1,11 @@
class AddDefaultValueToColor < ActiveRecord::Migration[6.0]
def up
Label.where(color: nil).find_each { |u| u.update(color: '#1f93ff') }
change_column :labels, :color, :string, default: '#1f93ff', null: false
end
def down
change_column :labels, :color, :string, default: nil, null: true
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_06_25_124400) do
ActiveRecord::Schema.define(version: 2020_06_25_154254) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
@@ -274,7 +274,7 @@ ActiveRecord::Schema.define(version: 2020_06_25_124400) do
create_table "labels", force: :cascade do |t|
t.string "title"
t.text "description"
t.string "color"
t.string "color", default: "#1f93ff", null: false
t.boolean "show_on_sidebar"
t.bigint "account_id"
t.datetime "created_at", precision: 6, null: false