Support skipping conflicting rows during CSV import #49685
Unanswered
mizukendesu
asked this question in
Feature Requests
Replies: 2 comments 1 reply
|
While Studio's built-in GUI CSV table importer performs atomic batch inserts (failing the transaction on first constraint collision), you can achieve Recommended Workflow:
INSERT INTO target_table (id, name, email, created_at)
SELECT id, name, email, created_at
FROM staging_import
ON CONFLICT (id) DO NOTHING; -- or ON CONFLICT (email) DO NOTHING
-- See which rows were duplicates/skipped:
SELECT s.*
FROM staging_import s
LEFT JOIN target_table t ON s.id = t.id
WHERE t.id IS NULL;
-- Drop staging table
DROP TABLE staging_import;This guarantees that all non-colliding rows are successfully inserted without throwing 23505 duplicate key violations. |
1 reply
|
Supabase team also confirmed to us that this is not currently supported and that our feedback has been added to an existing Dashboard feature request currently in triage. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
When importing CSV data through Supabase Studio, some rows may conflict with existing primary key or unique constraint values.
In cases where a CSV contains both new rows and rows that already exist in the table, it would be helpful if the non-conflicting rows could still be imported while the conflicting rows are skipped.
This would be similar to PostgreSQL's:
I couldn't find an equivalent option in the Studio CSV import flow, so I wanted to suggest it as a possible enhancement.
It would be helpful to have an option in the CSV import UI such as:
Conceptually, this could behave similarly to:
ON CONFLICT DO NOTHINGAs a possible future enhancement, users could also be allowed to choose a specific unique constraint as the conflict target. However, simply supporting
DO NOTHINGon conflicts would already cover the primary use case.The same behavior can be achieved manually using SQL, scripts, or temporary staging tables.
However, for ad-hoc data migration and operational tasks, having this available directly in Supabase Studio would make CSV imports more convenient.
If there is already a supported way to achieve this in Studio that I have missed, I'd be happy to use that instead.
All reactions