sqldelight icon indicating copy to clipboard operation
sqldelight copied to clipboard

Unable to run `ALTER TABLE <> DROP CONSTRAINT <> RESTRICT;` when using postgresql

Open StylianosGakis opened this issue 1 year ago • 2 comments

SQLDelight Version

2.0.2

SQLDelight Dialect

app.cash.sqldelight:postgresql-dialect

Describe the Bug

I tried to make a migration file with the contents:

ALTER TABLE notes
DROP CONSTRAINT must_have_unique_text_for_one_user_in_one_class RESTRICT;

Taken the syntax from https://www.postgresql.org/docs/7.2/sql-altertable.html

Running this exact text just normally on the terminal works fine.

Stacktrace

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':backend:generateMainSqlDelightMigrations'.
> A failure occurred while executing app.cash.sqldelight.gradle.GenerateMigrationOutputTask$GenerateMigration
   > Error Reading 3_remove_unique_notes.sqm:
     
     /Users/backend/backend/src/main/sqldelight/com/stylianosgakis/migrations/3_remove_unique_notes.sqm: (4, 4): <column name real> or COLUMN expected, got 'CONSTRAINT'
     3    ALTER TABLE table_name
     4    DROP CONSTRAINT constraint_name RESTRICT

StylianosGakis avatar Jun 06 '24 13:06 StylianosGakis

😞 Sadly DROP CONSTRAINT is not implemented

I will add it to the list https://github.com/griffio/sqldelight-postgres-01 and see if it can be quickly implemented

griffio avatar Jun 06 '24 17:06 griffio

Sounds great, thanks a lot!

StylianosGakis avatar Jun 06 '24 21:06 StylianosGakis