Update migrations
Fixed User table and added Doorkeeper tables
This commit is contained in:
parent
8a31a73a63
commit
7dcd298fc7
3 changed files with 116 additions and 9 deletions
|
|
@ -1,10 +1,10 @@
|
|||
class CreateUsers < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :users, id: :uuid, default: -> { "gen_random_uuid()" } do |t|
|
||||
t.string :email
|
||||
t.string :password
|
||||
t.string :username
|
||||
t.integer :granblue_id
|
||||
t.string :email, :unique => true
|
||||
t.string :password_digest
|
||||
t.string :username, :unique => true
|
||||
t.integer :granblue_id, :unique => true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
|
|
|||
70
db/migrate/20200923205642_create_doorkeeper_tables.rb
Normal file
70
db/migrate/20200923205642_create_doorkeeper_tables.rb
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateDoorkeeperTables < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :oauth_applications, id: :uuid do |t|
|
||||
t.string :name, null: false
|
||||
t.string :uid, null: false
|
||||
t.string :secret, null: false
|
||||
t.text :redirect_uri, null: false
|
||||
t.string :scopes, null: false, default: ''
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :oauth_applications, :uid, unique: true
|
||||
|
||||
create_table :oauth_access_grants, id: :uuid do |t|
|
||||
t.uuid :resource_owner_id, null: false
|
||||
t.uuid :application_id, 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
|
||||
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.uuid :application_id
|
||||
|
||||
# If you use a custom token generator you may need to change this column
|
||||
# from string to text, so that it accepts tokens larger than 255
|
||||
# characters. More info on custom token generators in:
|
||||
# https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
|
||||
#
|
||||
# t.text :token, null: false
|
||||
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
|
||||
|
||||
# If there is a previous_refresh_token column,
|
||||
# refresh tokens will be revoked after a related access token is used.
|
||||
# If there is no previous_refresh_token column,
|
||||
# previous tokens are revoked as soon as a new access token is created.
|
||||
# Comment out this line if you'd rather have refresh tokens
|
||||
# instantly revoked.
|
||||
t.string :previous_refresh_token, null: false, default: ""
|
||||
end
|
||||
|
||||
add_index :oauth_access_tokens, :token, unique: true
|
||||
add_index :oauth_access_tokens, :resource_owner_id
|
||||
add_index :oauth_access_tokens, :refresh_token, unique: true
|
||||
add_foreign_key(
|
||||
:oauth_access_tokens,
|
||||
:oauth_applications,
|
||||
column: :application_id
|
||||
)
|
||||
end
|
||||
end
|
||||
47
db/schema.rb
47
db/schema.rb
|
|
@ -10,12 +10,11 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_09_13_092045) do
|
||||
ActiveRecord::Schema.define(version: 2020_09_23_205642) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
enable_extension "uuid-ossp"
|
||||
|
||||
create_table "grid_weapons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "party_id"
|
||||
|
|
@ -33,6 +32,44 @@ ActiveRecord::Schema.define(version: 2020_09_13_092045) do
|
|||
t.index ["weapon_key2_id"], name: "index_grid_weapons_on_weapon_key2_id"
|
||||
end
|
||||
|
||||
create_table "oauth_access_grants", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "resource_owner_id", null: false
|
||||
t.uuid "application_id", 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"
|
||||
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
|
||||
end
|
||||
|
||||
create_table "oauth_access_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "resource_owner_id"
|
||||
t.uuid "application_id"
|
||||
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", default: "", null: false
|
||||
t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true
|
||||
t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id"
|
||||
t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true
|
||||
end
|
||||
|
||||
create_table "oauth_applications", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "uid", null: false
|
||||
t.string "secret", null: false
|
||||
t.text "redirect_uri", null: false
|
||||
t.string "scopes", default: "", null: false
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
|
||||
end
|
||||
|
||||
create_table "parties", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "user_id"
|
||||
t.string "shortcode"
|
||||
|
|
@ -43,7 +80,7 @@ ActiveRecord::Schema.define(version: 2020_09_13_092045) do
|
|||
|
||||
create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "email"
|
||||
t.string "password"
|
||||
t.string "password_digest"
|
||||
t.string "username"
|
||||
t.integer "granblue_id"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
|
|
@ -51,14 +88,12 @@ ActiveRecord::Schema.define(version: 2020_09_13_092045) do
|
|||
end
|
||||
|
||||
create_table "weapon_keys", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.bigint "weapon_id"
|
||||
t.string "name_en"
|
||||
t.string "name_jp"
|
||||
t.integer "series"
|
||||
t.integer "type"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["weapon_id"], name: "index_weapon_keys_on_weapon_id"
|
||||
end
|
||||
|
||||
create_table "weapons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
|
|
@ -83,4 +118,6 @@ ActiveRecord::Schema.define(version: 2020_09_13_092045) do
|
|||
t.integer "max_atk_ulb"
|
||||
end
|
||||
|
||||
add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id"
|
||||
add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id"
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue