mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Merge pull request #52 from greg-barnett/database_cleaner
--- The first commit works, for versions of postgresql up to 9.* The second should work for any and all future versions of postgresql, as long as the implementation of postgresql_version in ActiveRecord doesnt change...
This commit is contained in:
commit
fb01b5fb67
1 changed files with 3 additions and 6 deletions
|
@ -60,18 +60,15 @@ module ActiveRecord
|
||||||
class PostgreSQLAdapter < AbstractAdapter
|
class PostgreSQLAdapter < AbstractAdapter
|
||||||
|
|
||||||
def db_version
|
def db_version
|
||||||
@db_version ||= select_values(
|
@db_version ||= postgresql_version
|
||||||
"SELECT CHARACTER_VALUE
|
|
||||||
FROM INFORMATION_SCHEMA.SQL_IMPLEMENTATION_INFO
|
|
||||||
WHERE IMPLEMENTATION_INFO_NAME = 'DBMS VERSION' ").join.to_s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cascade
|
def cascade
|
||||||
@cascade ||= db_version >= "08.02" ? "CASCADE" : ""
|
@cascade ||= db_version >= 80200 ? 'CASCADE' : ''
|
||||||
end
|
end
|
||||||
|
|
||||||
def restart_identity
|
def restart_identity
|
||||||
@restart_identity ||= db_version >= "08.04" ? "RESTART IDENTITY" : ""
|
@restart_identity ||= db_version >= 80400 ? 'RESTART IDENTITY' : ''
|
||||||
end
|
end
|
||||||
|
|
||||||
def truncate_table(table_name)
|
def truncate_table(table_name)
|
||||||
|
|
Loading…
Reference in a new issue