Adding unique() to an existing table in Supabase

Is it possible to add (table) => [unique().on(table.userId, table.division, table.week, table.year, table.sportId)] on an existing table? I just noticed that duplicate data has been entered into one of my tables from a form that's submitted on my site. I just realized it happened last year once and then again this year. LKooking at my schema I don't have a unique() for this particular table. Is it possible to add that and then run drizzle-kit generate followed by a drizzle-kit migrate to then add that? Will it mess anything up with the existing tabler? Also, can I update an existing unique?
2 Replies
lonelyplanet
lonelyplanet5d ago
The migration will fail, first clean up the data manual with some hand crafted SQL queries for your table. Once completed then run the migration.
jsingleton37
jsingleton37OP4d ago
I’ve cleaned up an the duplicates to my knowledge 🤞🏼

Did you find this page helpful?