bastodon/app/models/identity.rb
Eugen Rochko 4afda5444a
Change identities id column to a bigint (#9371)
* fix: change Identity's id column to a bigint

This appears to be the last model created using a 5.0 migration,
where column types defaulted to `integer` rather than `bigint`.

This migration changes the column type to match that of all of the
other ID columns.

* Change user_id column in identities to bigint and fix down-migration
2018-11-27 13:56:25 +01:00

22 lines
640 B
Ruby

# frozen_string_literal: true
# == Schema Information
#
# Table name: identities
#
# provider :string default(""), not null
# uid :string default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
# id :bigint(8) not null, primary key
# user_id :bigint(8)
#
class Identity < ApplicationRecord
belongs_to :user, dependent: :destroy
validates :uid, presence: true, uniqueness: { scope: :provider }
validates :provider, presence: true
def self.find_for_oauth(auth)
find_or_create_by(uid: auth.uid, provider: auth.provider)
end
end