Change the PK value while keeping the FK links #2893
-
Hi Simon ! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi! Sure, you can construct that update statement in drift with Future<void> updateId(int oldId, int newId) async {
final stmt = update(table)..where((row) => row.id.equals(oldId));
await stmt.write(TableCompanion(id: Value(newId)));
} Is this what you were looking for? As you've said, this should also update foreign keys if they have an |
Beta Was this translation helpful? Give feedback.
-
Thank's, it's perfect ! |
Beta Was this translation helpful? Give feedback.
Hi! Sure, you can construct that update statement in drift with
Is this what you were looking for? As you've said, this should also update foreign keys if they have an
ON UPDATE CASCADE
option.