mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
specify auto increment for each different db in db test helper.
This commit is contained in:
parent
64c0424f40
commit
96417bc938
1 changed files with 9 additions and 1 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue