mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Generate inet columns for postgresql
This commit is contained in:
parent
a51036196a
commit
53504f7e28
2 changed files with 17 additions and 2 deletions
|
@ -53,8 +53,8 @@ module ActiveRecord
|
||||||
t.integer :sign_in_count, default: 0, null: false
|
t.integer :sign_in_count, default: 0, null: false
|
||||||
t.datetime :current_sign_in_at
|
t.datetime :current_sign_in_at
|
||||||
t.datetime :last_sign_in_at
|
t.datetime :last_sign_in_at
|
||||||
t.string :current_sign_in_ip
|
t.#{ip_column} :current_sign_in_ip
|
||||||
t.string :last_sign_in_ip
|
t.#{ip_column} :last_sign_in_ip
|
||||||
|
|
||||||
## Confirmable
|
## Confirmable
|
||||||
# t.string :confirmation_token
|
# t.string :confirmation_token
|
||||||
|
@ -68,6 +68,15 @@ module ActiveRecord
|
||||||
# t.datetime :locked_at
|
# t.datetime :locked_at
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ip_column
|
||||||
|
# Padded with spaces so it aligns nicely with the rest of the columns.
|
||||||
|
"%-8s" % (postgresql? ? "inet" : "string")
|
||||||
|
end
|
||||||
|
|
||||||
|
def postgresql?
|
||||||
|
ActiveRecord::Base.connection.adapter_name.downcase == "postgresql"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,12 @@ if DEVISE_ORM == :active_record
|
||||||
assert_no_file "app/models/monster.rb"
|
assert_no_file "app/models/monster.rb"
|
||||||
assert_no_migration "db/migrate/devise_create_monsters.rb"
|
assert_no_migration "db/migrate/devise_create_monsters.rb"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "use string column type for ip addresses" do
|
||||||
|
run_generator %w(monster)
|
||||||
|
assert_migration "db/migrate/devise_create_monsters.rb", /t.string :current_sign_in_ip/
|
||||||
|
assert_migration "db/migrate/devise_create_monsters.rb", /t.string :last_sign_in_ip/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module RailsEngine
|
module RailsEngine
|
||||||
|
|
Loading…
Reference in a new issue