1
0

20160306172223_create_doorkeeper_tables.rb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # frozen_string_literal: true
  2. class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
  3. def change
  4. create_table :oauth_applications do |t|
  5. t.string :name, null: false
  6. t.string :uid, null: false
  7. t.string :secret, null: false
  8. t.text :redirect_uri, null: false
  9. t.string :scopes, null: false, default: ''
  10. t.timestamps
  11. end
  12. add_index :oauth_applications, :uid, unique: true
  13. create_table :oauth_access_grants do |t|
  14. t.integer :resource_owner_id, null: false
  15. t.integer :application_id, null: false
  16. t.string :token, null: false
  17. t.integer :expires_in, null: false
  18. t.text :redirect_uri, null: false
  19. t.datetime :created_at, null: false
  20. t.datetime :revoked_at
  21. t.string :scopes
  22. end
  23. add_index :oauth_access_grants, :token, unique: true
  24. create_table :oauth_access_tokens do |t|
  25. t.integer :resource_owner_id
  26. t.integer :application_id
  27. # If you use a custom token generator you may need to change this column
  28. # from string to text, so that it accepts tokens larger than 255
  29. # characters. More info on custom token generators in:
  30. # https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
  31. #
  32. # t.text :token, null: false
  33. t.string :token, null: false
  34. t.string :refresh_token
  35. t.integer :expires_in
  36. t.datetime :revoked_at
  37. t.datetime :created_at, null: false
  38. t.string :scopes
  39. end
  40. add_index :oauth_access_tokens, :token, unique: true
  41. add_index :oauth_access_tokens, :resource_owner_id
  42. add_index :oauth_access_tokens, :refresh_token, unique: true
  43. end
  44. end