specify auto increment for each different db in db test helper.

This commit is contained in:
Micah Geisel 2020-05-09 13:04:06 -07:00
parent 64c0424f40
commit 96417bc938

View file

@ -40,9 +40,17 @@ module DatabaseCleaner
end end
def load_schema 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 connection.execute <<-SQL
CREATE TABLE IF NOT EXISTS users ( CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY, #{id_column},
name INTEGER name INTEGER
); );
SQL SQL