diff --git a/lib/database_cleaner/spec/database_helper.rb b/lib/database_cleaner/spec/database_helper.rb index b316c52..b1ae281 100644 --- a/lib/database_cleaner/spec/database_helper.rb +++ b/lib/database_cleaner/spec/database_helper.rb @@ -40,9 +40,17 @@ module DatabaseCleaner end def load_schema + id_column = case db + when :sqlite3 + "id INTEGER PRIMARY KEY AUTOINCREMENT" + when :mysql2 + "id INTEGER PRIMARY KEY AUTO_INCREMENT" + when :postgres + "id SERIAL PRIMARY KEY" + end connection.execute <<-SQL CREATE TABLE IF NOT EXISTS users ( - id SERIAL PRIMARY KEY, + #{id_column}, name INTEGER ); SQL