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
BaseDatabaseHelper.checkForeignKeySupport gets called during onUpgrade, but doesn't enable foreign keys. That call is a red herring for us to think that foreign key will ever work during onUpgrade.
I can confidently say it'll never work, because of two reasons:
(simplified)
Notice that onUpgrade is within a transaction, and there's no way around not having a transaction there.
The solution? configure the DB connection with foreign keys in onConfigure, before any operations happen. This would remove the need to call checkForeignKeySupport 3 times in BaseDatabaseHelper.
Background: we discovered this, because we wanted to rely on CASCADE during a migration, which simply didn't work, because it needs foreign keys to be enabled in order to do anything.
The text was updated successfully, but these errors were encountered:
ISSUE_TEMPLATE
DBFlow Version: 3.1.1-5.x
Bug or Feature Request: both?
Description:
Consider this simple database:
When I open this DB during normal operation, the following gives me
1
, i.e. foreign keys are enabledbut if I do this in a migration, I get
0
:the reason?
BaseDatabaseHelper.checkForeignKeySupport
gets called duringonUpgrade
, but doesn't enable foreign keys. That call is a red herring for us to think that foreign key will ever work duringonUpgrade
.I can confidently say it'll never work, because of two reasons:
(simplified)
Notice that
onUpgrade
is within a transaction, and there's no way around not having a transaction there.The solution? configure the DB connection with foreign keys in
onConfigure
, before any operations happen. This would remove the need to callcheckForeignKeySupport
3 times inBaseDatabaseHelper
.Background: we discovered this, because we wanted to rely on
CASCADE
during a migration, which simply didn't work, because it needs foreign keys to be enabled in order to do anything.The text was updated successfully, but these errors were encountered: