Skip to content

Instantly share code, notes, and snippets.

@ryenski
Created July 27, 2018 14:41
Show Gist options
  • Save ryenski/ac256aff4c9fcbc3d1fd014b3bc2aba3 to your computer and use it in GitHub Desktop.
Save ryenski/ac256aff4c9fcbc3d1fd014b3bc2aba3 to your computer and use it in GitHub Desktop.
Oauth Identities
# == Schema Information
#
# Table name: identities
#
# id :integer not null, primary key
# user_id :integer
# provider :string
# uid :string
# created_at :datetime not null
# updated_at :datetime not null
# metadata :json
#
# Store Oauth identities for a user.
# Each
class Identity < ApplicationRecord
belongs_to :user, autosave: true
validates :uid, :provider, presence: true
validates :uid, uniqueness: {scope: [:provider]}
end
create_table "identities", id: :serial, force: :cascade do |t|
t.integer "user_id"
t.string "provider"
t.string "uid"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.json "metadata"
t.index ["user_id"], name: "index_identities_on_user_id"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment