database_cleaner-active_record
database_cleaner-active_record copied to clipboard
Truncation failure with CockroachDB
DatabaseCleaner treats CockroachDB as PostgreSQL (which makes sense because CockroachDB emulated PostgreSQL to some extent). It uses the RESTART IDENTITY clause in the TRUNCATE TABLE query, which isn't supported by CockroachDB. There should probably be separate handling for CockroachDB that doesn't use that clause, and perhaps runs a separate query to reset the auto-increment counter.
Hi @agaffney, thanks for the issue. We don't currently support CockroachDB in this adapter, but I'm certainly open to supporting it in one way or another! The question is what that should look like. Does it look like adding support (code and tests) to this repo, or does it look like creating a new adapter for database_cleaner, or maybe even generalizing the code in this adapter to leverage AR's built-in abilities to abstract across various DBs? Thoughts?
I do not have a suggested course of action here. This is just something I ran into while testing moving a Rails app from PostgreSQL to CockroachDB.
I was able to work around the issue by manually removing the RESTART IDENTITY part of the query, but that seemed to cause some issues with our spec tests, because they expect the ID column's value to get reset between tests.