Chore: Add default value for label color (#981)
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
# Table name: labels
|
# Table name: labels
|
||||||
#
|
#
|
||||||
# id :bigint not null, primary key
|
# id :bigint not null, primary key
|
||||||
# color :string
|
# color :string default("#1f93ff"), not null
|
||||||
# description :text
|
# description :text
|
||||||
# show_on_sidebar :boolean
|
# show_on_sidebar :boolean
|
||||||
# title :string
|
# title :string
|
||||||
|
|||||||
11
db/migrate/20200625154254_add_default_value_to_color.rb
Normal file
11
db/migrate/20200625154254_add_default_value_to_color.rb
Normal 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
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_stat_statements"
|
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|
|
create_table "labels", force: :cascade do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.string "color"
|
t.string "color", default: "#1f93ff", null: false
|
||||||
t.boolean "show_on_sidebar"
|
t.boolean "show_on_sidebar"
|
||||||
t.bigint "account_id"
|
t.bigint "account_id"
|
||||||
t.datetime "created_at", precision: 6, null: false
|
t.datetime "created_at", precision: 6, null: false
|
||||||
|
|||||||
Reference in New Issue
Block a user