20161101131409_create_doorkeeper_tables.rb 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  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 null: false # rubocop:disable Zammad/ExistsDateTimePrecision
  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.references :application, 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 # rubocop:disable Zammad/ExistsDateTimePrecision
  20. t.datetime :revoked_at # rubocop:disable Zammad/ExistsDateTimePrecision
  21. t.string :scopes
  22. end
  23. add_index :oauth_access_grants, :token, unique: true
  24. add_foreign_key(
  25. :oauth_access_grants,
  26. :oauth_applications,
  27. column: :application_id
  28. )
  29. create_table :oauth_access_tokens do |t|
  30. t.integer :resource_owner_id
  31. t.references :application
  32. # If you use a custom token generator you may need to change this column
  33. # from string to text, so that it accepts tokens larger than 255
  34. # characters. More info on custom token generators in:
  35. # https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
  36. #
  37. # t.text :token, null: false
  38. t.string :token, null: false
  39. t.string :refresh_token
  40. t.integer :expires_in
  41. t.datetime :revoked_at # rubocop:disable Zammad/ExistsDateTimePrecision
  42. t.datetime :created_at, null: false # rubocop:disable Zammad/ExistsDateTimePrecision
  43. t.string :scopes
  44. # If there is a previous_refresh_token column,
  45. # refresh tokens will be revoked after a related access token is used.
  46. # If there is no previous_refresh_token column,
  47. # previous tokens are revoked as soon as a new access token is created.
  48. # Comment out this line if you'd rather have refresh tokens
  49. # instantly revoked.
  50. t.string :previous_refresh_token, null: false, default: ''
  51. end
  52. add_index :oauth_access_tokens, :token, unique: true
  53. add_index :oauth_access_tokens, :resource_owner_id
  54. add_index :oauth_access_tokens, :refresh_token, unique: true
  55. add_foreign_key(
  56. :oauth_access_tokens,
  57. :oauth_applications,
  58. column: :application_id
  59. )
  60. end
  61. end