docbrown/db/migrate/20200412194408_create_user_optional_fields.rb
Yechiel Kalmenson 131d11aa73
[deploy] Add optional fields to user (#7246)
* add optional fields to user

- this provides the back-end implementation for #2365

* fix mistakes in schema.rb

* renamed OptionalField to userOptionalField

* rename field column in user_optional_fields to label

* add uniqueness validation on user_optional_field labels

* scope flag uniqueness to user_id

* add indexing on label in user_optional_fields

* add optional fields to user

- this provides the back-end implementation for #2365

* fix mistakes in schema.rb

* add index on user_id for user_optional_fields

* Remove duplicate model

* Fix schema

* Re-add past indexes

* Remove old index

* Remove another old index

* add `null:false` to columns in optional fields

* add `null: false` to the migration

- Updated test to account for the null constraint

* add null:false to user_id on user_optional_tables

Co-authored-by: rhymes <rhymesete@gmail.com>
Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2020-04-28 15:42:41 -04:00

13 lines
357 B
Ruby

class CreateUserOptionalFields < ActiveRecord::Migration[5.2]
def change
create_table :user_optional_fields do |t|
t.string :label, null: false
t.string :value, null: false
t.references :user, foreign_key: true, null: false
t.timestamps
end
add_index :user_optional_fields, [:label, :user_id], unique: true
end
end