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
Hi Electric Developer, I encountered an error when the product table and the product_images table have a relationship.
OS : Mac
Browser: Chrome
Electric Version: 0.10.0
Error: FOREIGN KEY constraint failed
the table structure
I'm trying to query in my localhost, it's not problem and fetch as expected. and also the data is not filled on supabase.
SELECT p.id,
p.name,
p.price,
pi.id as product_image_id,
pi.product_image as product_image
FROM
product p
LEFT JOIN
product_images pi ON p.id = pi.product_id;
if you need the migration syntax
CREATE TABLE IF NOT EXISTS product_images (
id UUID PRIMARY KEY,
product_id UUID NOT NULL,
product_image TEXT,
FOREIGN KEY (product_id) REFERENCES product(id)
);
ALTER TABLE product_images ENABLE ELECTRIC;
The text was updated successfully, but these errors were encountered:
@dreamid27 from your sync code it seems like you are only syncing the product table and not the product_image table, and are executing a join on a table that's not been synced.
this will sync the product table as well as any entries in the product_image table that have an FK relationship to any of the synced rows in the product table. Now your query should be able to execute since all the relevant data is present on the device.
Hi Electric Developer, I encountered an error when the product table and the product_images table have a relationship.
OS : Mac
Browser: Chrome
Electric Version: 0.10.0
Error: FOREIGN KEY constraint failed
the table structure
I'm trying to query in my localhost, it's not problem and fetch as expected. and also the data is not filled on supabase.
if you need the migration syntax
The text was updated successfully, but these errors were encountered: