"Fossies" - the Fresh Open Source Software Archive

Member "db/migrate/20161101131409_create_doorkeeper_tables.rb" (25 Mar 2021, 2678 Bytes) of package /linux/www/zammad-4.0.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "20161101131409_create_doorkeeper_tables.rb": 3.5.1_vs_4.0.0.

    1 class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
    2   def change
    3     create_table :oauth_applications do |t|
    4       t.string  :name,         null: false
    5       t.string  :uid,          null: false
    6       t.string  :secret,       null: false
    7       t.text    :redirect_uri, null: false
    8       t.string  :scopes,       null: false, default: ''
    9       t.timestamps             null: false # rubocop:disable Zammad/ExistsDateTimePrecision
   10     end
   11 
   12     add_index :oauth_applications, :uid, unique: true
   13 
   14     create_table :oauth_access_grants do |t|
   15       t.integer  :resource_owner_id, null: false
   16       t.references :application,     null: false
   17       t.string   :token,             null: false
   18       t.integer  :expires_in,        null: false
   19       t.text     :redirect_uri,      null: false
   20       t.datetime :created_at,        null: false # rubocop:disable Zammad/ExistsDateTimePrecision
   21       t.datetime :revoked_at # rubocop:disable Zammad/ExistsDateTimePrecision
   22       t.string   :scopes
   23     end
   24 
   25     add_index :oauth_access_grants, :token, unique: true
   26     add_foreign_key(
   27       :oauth_access_grants,
   28       :oauth_applications,
   29       column: :application_id
   30     )
   31 
   32     create_table :oauth_access_tokens do |t|
   33       t.integer  :resource_owner_id
   34       t.references :application
   35 
   36       # If you use a custom token generator you may need to change this column
   37       # from string to text, so that it accepts tokens larger than 255
   38       # characters. More info on custom token generators in:
   39       # https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
   40       #
   41       # t.text     :token,             null: false
   42       t.string   :token, null: false
   43 
   44       t.string   :refresh_token
   45       t.integer  :expires_in
   46       t.datetime :revoked_at # rubocop:disable Zammad/ExistsDateTimePrecision
   47       t.datetime :created_at, null: false # rubocop:disable Zammad/ExistsDateTimePrecision
   48       t.string   :scopes
   49 
   50       # If there is a previous_refresh_token column,
   51       # refresh tokens will be revoked after a related access token is used.
   52       # If there is no previous_refresh_token column,
   53       # previous tokens are revoked as soon as a new access token is created.
   54       # Comment out this line if you'd rather have refresh tokens
   55       # instantly revoked.
   56       t.string   :previous_refresh_token, null: false, default: ''
   57     end
   58 
   59     add_index :oauth_access_tokens, :token, unique: true
   60     add_index :oauth_access_tokens, :resource_owner_id
   61     add_index :oauth_access_tokens, :refresh_token, unique: true
   62     add_foreign_key(
   63       :oauth_access_tokens,
   64       :oauth_applications,
   65       column: :application_id
   66     )
   67   end
   68 end