-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not supported for Postgresql: ALTER COLUMN y DROP NOT NULL #4714
Comments
Support should be in 2.0.0 was merged back in May 🕊️ Are you seeing a compilation error Have tried the below syntax in migration file Note: Alter table statements are forbidden outside of migration files
|
I'm also experiencing a problem with |
🤔 I tried it two ways - let me know if you have a different structure? with Two statements CREATE TABLE and ALTER TABLE in
Then again with the CREATE in
DB Checked
|
🧾 I think the issue being raised here is that the generated field This only does so if the column is dropped and added in the migration file
|
After looking into 👓 - it's quite tricky to solve with the current code and I can only get it to half work. Lines 54 to 58 in e6ac047
|
👋🏻 Any workaround for the migration not being applied to the generated code? |
@iruizmar Example - to drop the not null constraint on y Existing CREATE TABLE X(
y INTEGER NOT NULL,
t TEXT
);
Change to CREATE TABLE X(
y INTEGER,
t TEXT
); Your new migration ALTER TABLE X
ALTER COLUMN y DROP NOT NULL; Then run your migration - check that the Table data class has the nullable type and any queries are nullable type now |
Thanks for that, @griffio. That's a brilliant idea to deceive the SQLDelight code generation, but it won't work in some CI environments in which migrations are verified via checksum, for example, just as Flyway does. It'll modify the generated migration and Flyway will complain (if verification is enabled, which I guess should be for security reasons). Or am I misunderstanding something? |
🔕 it's not a work-around for such a scenario, only useful if it helps immediately. Somehow a "fix" in the PostgreSQL Dialect where the new constraints 🔗 are modified and applied during code generation will have to be found. Currently there is quite a lot of PostgreSql functionality missing (The upcoming 2.1 release will have some improvements) #3944 (reply in thread) However, supporting migrations correctly is a priority as otherwise prevents greater adoption in production environments. 👨🚀 |
SQLDelight Version
2.0.0
SQLDelight Dialect
postgresql
Describe the Bug
Drop not null is not supported. Only way to mitigate this is to drop the column and recreate it again.
ALTER TABLE X ALTER COLUMN Y DROP NOT NULL
Stacktrace
No response
The text was updated successfully, but these errors were encountered: