|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +class CreateSpreeUsers < ActiveRecord::Migration[7.0] |
| 4 | + def change |
| 5 | + create_table :spree_users, if_not_exists: true do |t| |
| 6 | + t.string :login |
| 7 | + t.string :email |
| 8 | + t.string :unconfirmed_email |
| 9 | + |
| 10 | + t.string :encrypted_password, limit: 128 |
| 11 | + t.string :password_salt, limit: 128 |
| 12 | + t.string :reset_password_token |
| 13 | + t.string :spree_api_key, limit: 48 |
| 14 | + |
| 15 | + t.string :confirmation_token |
| 16 | + t.string :perishable_token |
| 17 | + t.string :persistence_token |
| 18 | + t.string :remember_token |
| 19 | + t.string :unlock_token |
| 20 | + |
| 21 | + t.integer :sign_in_count, default: 0, null: false |
| 22 | + t.integer :failed_attempts, default: 0, null: false |
| 23 | + |
| 24 | + t.string :current_sign_in_ip |
| 25 | + t.string :last_sign_in_ip |
| 26 | + |
| 27 | + t.references :ship_address, foreign_key: {to_table: :spree_addresses} |
| 28 | + t.references :bill_address, foreign_key: {to_table: :spree_addresses} |
| 29 | + |
| 30 | + t.datetime :confirmation_sent_at |
| 31 | + t.datetime :confirmed_at |
| 32 | + t.datetime :current_sign_in_at |
| 33 | + t.datetime :deleted_at |
| 34 | + t.datetime :last_request_at |
| 35 | + t.datetime :last_sign_in_at |
| 36 | + t.datetime :locked_at |
| 37 | + t.datetime :remember_created_at |
| 38 | + t.datetime :reset_password_sent_at |
| 39 | + |
| 40 | + t.timestamps null: false |
| 41 | + end |
| 42 | + |
| 43 | + if column_exists?(:spree_users, :deleted_at) |
| 44 | + add_index :spree_users, :deleted_at, if_not_exists: true |
| 45 | + end |
| 46 | + |
| 47 | + if column_exists?(:spree_users, :email) |
| 48 | + add_index :spree_users, :email, |
| 49 | + name: "email_idx_unique", |
| 50 | + if_not_exists: true, |
| 51 | + unique: true |
| 52 | + end |
| 53 | + |
| 54 | + if column_exists?(:spree_users, :reset_password_token) |
| 55 | + add_index :spree_users, :reset_password_token, |
| 56 | + if_not_exists: true, |
| 57 | + unique: true |
| 58 | + end |
| 59 | + end |
| 60 | +end |
0 commit comments