Module: DeviseSecurity::Schema
- Included in:
- Orm::ActiveRecord::Schema
- Defined in:
- lib/devise-security/schema.rb
Overview
add schema helper for migrations
Instance Method Summary collapse
- #expirable ⇒ Object
-
#password_archivable ⇒ Object
Add password_archivable columns.
-
#password_expirable ⇒ Object
Add password_changed_at columns in the resource’s database table.
-
#session_limitable ⇒ Object
Add session_limitable columns in the resource’s database table.
Instance Method Details
#expirable ⇒ Object
61 62 63 64 |
# File 'lib/devise-security/schema.rb', line 61 def expirable apply_devise_schema :expired_at, DateTime apply_devise_schema :last_activity_at, DateTime end |
#password_archivable ⇒ Object
Add password_archivable columns
Examples
create_table :old_passwords do
t.password_archivable
end add_index :old_passwords, [:password_archivable_type, :password_archivable_id], name: ‘index_password_archivable’
34 35 36 37 38 39 40 |
# File 'lib/devise-security/schema.rb', line 34 def password_archivable apply_devise_schema :encrypted_password, String, limit: 128, null: false apply_devise_schema :password_salt, String apply_devise_schema :password_archivable_id, Integer, null: false apply_devise_schema :password_archivable_type, String, null: false apply_devise_schema :created_at, DateTime end |
#password_expirable ⇒ Object
Add password_changed_at columns in the resource’s database table.
Examples
# For a new resource migration: create_table :the_resources do |t|
t.password_expirable
… end
# or if the resource’s table already exists, define a migration and put this in: change_table :the_resources do |t|
t.datetime :password_changed_at
end
21 22 23 |
# File 'lib/devise-security/schema.rb', line 21 def password_expirable apply_devise_schema :password_changed_at, DateTime end |
#session_limitable ⇒ Object
Add session_limitable columns in the resource’s database table.
Examples
# For a new resource migration: create_table :the_resources do |t|
t.session_limitable
… end
# or if the resource’s table already exists, define a migration and put this in: change_table :the_resources do |t|
t.string :unique_session_id, limit: 20
end
57 58 59 |
# File 'lib/devise-security/schema.rb', line 57 def session_limitable apply_devise_schema :unique_session_id, String, limit: 20 end |