adds geozone reference to users

This commit is contained in:
kikito
2016-02-18 17:51:24 +01:00
parent a276bea528
commit c8096efa73
3 changed files with 10 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ class User < ActiveRecord::Base
has_many :comments, -> { with_hidden }
has_many :failed_census_calls
has_many :notifications
belongs_to :geozone
validates :username, presence: true, if: :username_required?
validates :username, uniqueness: true, if: :username_required?

View File

@@ -0,0 +1,5 @@
class AddGeozoneIdToUsers < ActiveRecord::Migration
def change
add_reference :users, :geozone, index: true, foreign_key: true
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160217101004) do
ActiveRecord::Schema.define(version: 20160218164923) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -408,10 +408,12 @@ ActiveRecord::Schema.define(version: 20160217101004) do
t.boolean "registering_with_oauth", default: false
t.string "locale"
t.string "oauth_email"
t.integer "geozone_id"
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["geozone_id"], name: "index_users_on_geozone_id", using: :btree
add_index "users", ["hidden_at"], name: "index_users_on_hidden_at", using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
@@ -491,4 +493,5 @@ ActiveRecord::Schema.define(version: 20160217101004) do
add_foreign_key "notifications", "users"
add_foreign_key "organizations", "users"
add_foreign_key "valuators", "users"
add_foreign_key "users", "geozones"
end