You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The test case schema creates a table with a partial unique index, on the test1 column for rows where test1=t. This works as expected. Multiple rows with test1=f can be inserted at this point as the index ignores them.
The migration then performs any operation that requires the table to be dropped and recreated - which is pretty much anything other than adding a column or renaming the table in SQLite. So removing a column is sufficient. When the table is recreated, the partial aspect of the index should be retained as was originally specified.
Actual behavior
When the table is recreated as part of a migration that has to recreate the table, the partial aspect of the index is lost:
Accordingly, the tests I provided fail because now the unique index covers rows where test1=f as well, so only one can be inserted and the tests fail with a unique index violation.
System configuration
Rails version: 5.1.0
Ruby version: 2.4.2p198
The text was updated successfully, but these errors were encountered:
Steps to reproduce
I created an executable test case for this bug: https://gist.github.com/celsworth/d3a2fe16d23f57a514655662b1d12cb7
Expected behavior
The test case schema creates a table with a partial unique index, on the
test1
column for rows wheretest1=t
. This works as expected. Multiple rows withtest1=f
can be inserted at this point as the index ignores them.The migration then performs any operation that requires the table to be dropped and recreated - which is pretty much anything other than adding a column or renaming the table in SQLite. So removing a column is sufficient. When the table is recreated, the partial aspect of the index should be retained as was originally specified.
Actual behavior
When the table is recreated as part of a migration that has to recreate the table, the partial aspect of the index is lost:
Accordingly, the tests I provided fail because now the unique index covers rows where
test1=f
as well, so only one can be inserted and the tests fail with a unique index violation.System configuration
Rails version: 5.1.0
Ruby version: 2.4.2p198
The text was updated successfully, but these errors were encountered: