-
Notifications
You must be signed in to change notification settings - Fork 223
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
Select used instead of Perform in migration causes issues when executing the migration SQL via PSQL #1089
Comments
Reproduced:
|
Weird, I was sure we had a test for this... We should add one... |
Oh actually these migration scenarios are usually not actually tested on a real database, just asserts on the SQL - which is why an error like this can slip through... Anyway, looks good to me, let's fix it. |
Unfortunately this broke normal migrations, since Idempotent migrations are a more rare feature, and in any case they can be edited to replace @nauticalcoder can you confirm whether you're running idempotent scripts, or was it some other scenario where DO blocks are being used? |
We are currently using idempotent scripts. This is the command we are using to generate the migration script which is then executed in Bamboo with psql.
|
@nauticalcoder thanks for confirming - makes sense. Unfortunately, the way things stand at the moment, we can only make one scenario work - either idempotent or non-idempotent - and as I wrote above we're going to have to allow non-idempotent migrations. On the other hand, note that the offending function call (setval) should only be generated once, when you transition your database from SERIAL-based columns to IDENTITY-based ones. That's typically a single migration in the lifetime of your project, which you can patch manually in the idempotent SQL script. |
Yeah, we don't anticipate having it pop up again as all of our environments have now been upgraded. We ended up running the migrations manually as you stated to get around the issue. Thanks for taking the time to look into it. |
Sure thing! |
Note that this is being fixed again in #1479 for idempotent migrations (but without affecting non-idempotent ones) |
The migration that is created to convert the existing Serial columns to Identity fails to run if the SQL is executed via the
psql
command line which is how we deploy our database migrations via Bamboo. The error is because aSELECT
is used without using the returned value. Here is an example:I believe simply changing the generated SQL to use a
PERFORM
instead of aSELECT
for this line:SELECT * FROM setval('"VisaStatuses_Id_seq"', nextval('"VisaStatuses_Id_old_seq"'), false);
would solve the problem.
The text was updated successfully, but these errors were encountered: