Can we get foreign keys ? #3662
-
|
Hello, Is it possible to retrieve the foreign key constraints of a table? Exemple : In my .g.dart, I have : But when I check it at runtime : I need to check constraint before I receive a SQLite file from server and I want check |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
I'm working on a future drift version that will properly expose information about constraints on columns, but at the moment it is indeed very tricky to get access to that. One thing you could do is:
I know this isn't great, but that seems to be the only way to get that information at the moment. |
Beta Was this translation helpful? Give feedback.
I'm working on a future drift version that will properly expose information about constraints on columns, but at the moment it is indeed very tricky to get access to that.
One thing you could do is:
GenerationContext.fromDb(yourDatabase).yourColumn.writeColumnDefinition(thatContext).GenerationContext.sqlto see whether it containsON UPDATE/ON DELETEas a substring.I know this isn't great, but that seems to be the only way to get that information at the moment.