diff --git a/lib/database_cleaner/active_record/truncation.rb b/lib/database_cleaner/active_record/truncation.rb index b44efbd..76ec0fe 100755 --- a/lib/database_cleaner/active_record/truncation.rb +++ b/lib/database_cleaner/active_record/truncation.rb @@ -54,6 +54,7 @@ module ActiveRecord class SQLite3Adapter < SQLITE_ADAPTER_PARENT def delete_table(table_name) execute("DELETE FROM #{quote_table_name(table_name)};") + execute("DELETE FROM sqlite_sequence where name = '#{table_name}';") end alias truncate_table delete_table end diff --git a/lib/database_cleaner/data_mapper/truncation.rb b/lib/database_cleaner/data_mapper/truncation.rb index 1896c09..47cabcb 100644 --- a/lib/database_cleaner/data_mapper/truncation.rb +++ b/lib/database_cleaner/data_mapper/truncation.rb @@ -53,6 +53,7 @@ module DataMapper def truncate_table(table_name) execute("DELETE FROM #{quote_name(table_name)};") + execute("DELETE FROM sqlite_sequence where name = '#{table_name}';") end # this is a no-op copied from activerecord @@ -79,6 +80,7 @@ module DataMapper def truncate_table(table_name) execute("DELETE FROM #{quote_name(table_name)};") + execute("DELETE FROM sqlite_sequence where name = '#{table_name}';") end # this is a no-op copied from activerecord @@ -107,7 +109,7 @@ module DataMapper end def truncate_table(table_name) - execute("TRUNCATE TABLE #{quote_name(table_name)} CASCADE;") + execute("TRUNCATE TABLE #{quote_name(table_name)} RESTART IDENTITY CASCADE;") end # FIXME