Sha256: e3d1b1b37c2222aee3eeed8c33cc3e9d32c4d5f06eb94a975b90e07114ba15b0

Contents?: true

Size: 1.81 KB

Versions: 12

Compression:

Stored size: 1.81 KB

Contents

# frozen_string_literal: true

class CreateOauthTables < ActiveRecord::Migration[6.0]
  def change
    create_table :oauth_applications, id: :uuid do |t|
      t.string  :name,    null: false
      t.string  :secret,  null: false
      t.text    :redirect_uri, null: false
      t.string  :scopes,       null: false, default: ''
      t.boolean :confidential, null: false, default: true
      t.timestamps             null: false
    end

    create_table :oauth_access_grants, id: :uuid do |t|
      t.uuid :resource_owner_id, null: false
      t.references :application, type: :uuid, null: false
      t.string   :token,             null: false
      t.integer  :expires_in,        null: false
      t.text     :redirect_uri,      null: false
      t.datetime :created_at,        null: false
      t.datetime :revoked_at
      t.string   :scopes, null: false, default: ''
    end

    add_index :oauth_access_grants, :token, unique: true
    add_foreign_key(
      :oauth_access_grants,
      :oauth_applications,
      column: :application_id
    )

    create_table :oauth_access_tokens, id: :uuid do |t|
      t.uuid :resource_owner_id
      t.references :application, type: :uuid
      t.string :token, null: false

      t.string   :refresh_token
      t.integer  :expires_in
      t.datetime :revoked_at
      t.datetime :created_at, null: false
      t.string   :scopes

      t.string   :previous_refresh_token, null: false, default: ''
    end

    add_index :oauth_access_tokens, :token, unique: true
    add_index :oauth_access_tokens, :refresh_token, unique: true
    add_foreign_key(
      :oauth_access_tokens,
      :oauth_applications,
      column: :application_id
    )

    add_foreign_key :oauth_access_grants, :users, column: :resource_owner_id
    add_foreign_key :oauth_access_tokens, :users, column: :resource_owner_id
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
osso-0.0.3.8 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.3.7 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.3.6 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.3.5 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.3.4 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.3.3 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.3.2 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.3.1 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.3 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.2.10 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.2.9 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb
osso-0.0.2.8 lib/osso/db/migrate/20200328143303_create_oauth_tables.rb