cashapp/sqldelight

Cannot use a simple migration statement

Angel-Ponce opened this issue · 4 comments

SQLDelight Version

2.0.2

SQLDelight Dialect

PostgreSQL

Describe the Bug

I'm trying to write a sqm migration file:

ALTER TABLE ProductUpdateDb ADD COLUMN IF NOT EXISTS apps_labels VARCHAR[] DEFAULT '{}';

But I got the following warning:
image

There are something wrong with my statement? or IF NOT EXISTS it's not supported yet?

Stacktrace

No response

😞 It's not supported - I will add to the list keeping track of migrations https://github.com/griffio/sqldelight-postgres-01

When I have a chance in the next day or so - I should add a PR for it, changing SqlDelight so that IF NOT EXISTS prevents the compiler adding a duplicate field in the data class

Btw - what would be a reason for needing IF NOT EXISTS on a column with SqlDelight?
e.g a column was manually added to the database, not using migrate script, and after the initial schema was created
Just in case there is some other edge-case 🌵 that I miss here

There are'nt a specific reason for needing IF NOT EXISTS it's only a good practice for me, because this sentence could prevent unnecessary errors.