diff options
author | sadbeast <sadbeast@sadbeast.com> | 2024-01-31 17:47:56 -0800 |
---|---|---|
committer | sadbeast <sadbeast@sadbeast.com> | 2024-01-31 17:47:56 -0800 |
commit | 332ec93366315fa1ed7b4acd7a3407c96e8ddfa7 (patch) | |
tree | 6ae553317f12a7a6a29c849c8805ffab96436dc2 /db/migrate/20240129044207_create_rodauth.rb | |
download | td-332ec93366315fa1ed7b4acd7a3407c96e8ddfa7.tar.gz td-332ec93366315fa1ed7b4acd7a3407c96e8ddfa7.tar.bz2 |
Diffstat (limited to 'db/migrate/20240129044207_create_rodauth.rb')
-rw-r--r-- | db/migrate/20240129044207_create_rodauth.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/db/migrate/20240129044207_create_rodauth.rb b/db/migrate/20240129044207_create_rodauth.rb new file mode 100644 index 0000000..9c38cbf --- /dev/null +++ b/db/migrate/20240129044207_create_rodauth.rb @@ -0,0 +1,47 @@ +class CreateRodauth < ActiveRecord::Migration[7.1] + def change + enable_extension "citext" + + create_table :accounts do |t| + t.integer :status, null: false, default: 1 + t.citext :email, null: false + t.index :email, unique: true, where: "status IN (1, 2)" + t.string :password_hash + end + + # Used by the password reset feature + create_table :account_password_reset_keys, id: false do |t| + t.bigint :id, primary_key: true + t.foreign_key :accounts, column: :id + t.string :key, null: false + t.datetime :deadline, null: false + t.datetime :email_last_sent, null: false, default: -> { "CURRENT_TIMESTAMP" } + end + + # Used by the account verification feature + create_table :account_verification_keys, id: false do |t| + t.bigint :id, primary_key: true + t.foreign_key :accounts, column: :id + t.string :key, null: false + t.datetime :requested_at, null: false, default: -> { "CURRENT_TIMESTAMP" } + t.datetime :email_last_sent, null: false, default: -> { "CURRENT_TIMESTAMP" } + end + + # Used by the verify login change feature + create_table :account_login_change_keys, id: false do |t| + t.bigint :id, primary_key: true + t.foreign_key :accounts, column: :id + t.string :key, null: false + t.string :login, null: false + t.datetime :deadline, null: false + end + + # Used by the remember me feature + create_table :account_remember_keys, id: false do |t| + t.bigint :id, primary_key: true + t.foreign_key :accounts, column: :id + t.string :key, null: false + t.datetime :deadline, null: false + end + end +end |