cashapp / sqldelight

SQLDelight - Generates typesafe Kotlin APIs from SQL
https://cashapp.github.io/sqldelight/
Apache License 2.0
6.01k stars 501 forks source link

Cannot use a simple migration statement #5309

Open Angel-Ponce opened 1 week ago

Angel-Ponce commented 1 week ago

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

griffio commented 1 week ago

😞 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

griffio commented 1 week ago

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

Angel-Ponce commented 1 week ago

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.