Add default values for new fields

This commit is contained in:
François Turbelin
2022-02-01 21:31:23 +01:00
committed by Maikel Linke
parent 836a60a6c7
commit b8afb7ec4d
2 changed files with 4 additions and 4 deletions

View File

@@ -3,8 +3,8 @@ class SplitCustomersName < ActiveRecord::Migration[6.1]
end
def change
add_column :customers, :first_name, :string
add_column :customers, :last_name, :string
add_column :customers, :first_name, :string, null: false, default: ""
add_column :customers, :last_name, :string, null: false, default: ""
rename_column :customers, :name, :backup_name
reversible do |dir|
dir.up { migrate_customer_name_data }

View File

@@ -54,8 +54,8 @@ ActiveRecord::Schema.define(version: 2022_01_18_053107) do
t.string "backup_name", limit: 255
t.boolean "allow_charges", default: false, null: false
t.datetime "terms_and_conditions_accepted_at"
t.string "first_name"
t.string "last_name"
t.string "first_name", default: "", null: false
t.string "last_name", default: "", null: false
t.index ["bill_address_id"], name: "index_customers_on_bill_address_id"
t.index ["email"], name: "index_customers_on_email"
t.index ["enterprise_id", "code"], name: "index_customers_on_enterprise_id_and_code", unique: true