mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Merge pull request #49 from greg-barnett/database_cleaner
--- This solves the following issue: when truncating in postgresql, the sequences are not reset. If you have a test that depends on records getting specific ids when created, the test could fail.
This commit is contained in:
commit
fa13e77ad7
1 changed files with 5 additions and 1 deletions
|
@ -70,8 +70,12 @@ module ActiveRecord
|
|||
@cascade ||= db_version >= "08.02" ? "CASCADE" : ""
|
||||
end
|
||||
|
||||
def restart_identity
|
||||
@restart_identity ||= db_version >= "08.04" ? "RESTART IDENTITY" : ""
|
||||
end
|
||||
|
||||
def truncate_table(table_name)
|
||||
execute("TRUNCATE TABLE #{quote_table_name(table_name)} #{cascade};")
|
||||
execute("TRUNCATE TABLE #{quote_table_name(table_name)} #{restart_identity} #{cascade};")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue