Skip to content
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

Can't change from SERIAL to IDENTITY columns in idempotent migrations #1157

Closed
roji opened this issue Dec 9, 2019 · 6 comments · Fixed by #1479
Closed

Can't change from SERIAL to IDENTITY columns in idempotent migrations #1157

roji opened this issue Dec 9, 2019 · 6 comments · Fixed by #1479
Assignees
Labels
bug Something isn't working
Milestone

Comments

@roji
Copy link
Member

roji commented Dec 9, 2019

Originally raised in #1089, attempted fix in #1092 broke non-idempotent migrations, so we're reverting it in #1156.

Our idempotent scripts run under PL/pgSQL, whereas non-idempotent scripts run in plain SQL. Unfortunately, when executing a function whose return value should be discarded, in PL/pgSQL we need to use PERFORM, whereas regular SQL requires SELECT. At the moment we can't distinguish between idempotent and non-idempotent in the migrations generator (dotnet/efcore#19250).

Another solution to this would be to run all migrations under PL/pgSQL.

@Slaviusz
Copy link

Is there any known workaround? Proposed downgrade to 3.0.1 does not work and we're currently blocked moving on from .NetCore 2.2 to 3.1 migration within our project because of migrations failing from SERIAL to IDENTITY with PERFORM.

@roji
Copy link
Member Author

roji commented Jan 21, 2020

To work around this, edit the generated idempotent migration SQL and change the SELECT to PERFORM. It's a one-time operation that occurs when first changing from SERIAL to IDENTITY, once it's done you shouldn't need to do it again for other migration types.

@jhartmann123
Copy link
Contributor

@roji You mentioned that the issue with PERFORM is reverted in 3.1.1 (#1089 (comment)). However, it's still in there. Looking at the git tree, the revert is only in dev and 3.0.2. Any chance of getting a quick 3.1.2 with the PERFORM issue being reverted?

@roji
Copy link
Member Author

roji commented Feb 3, 2020

Shoot, sorry about that - I backported to 3.0 but apparently forgot to backport to 3.1...

I am releasing 3.1.1.1 with this fix (we try to more or less maintain version sync with EF Core, but they haven't yet released 3.1.2), this should help you all out.

Note that this kind of bug should no longer occur since we now have real migration tests which actually execute DDL on PostgreSQL. But that's on the 5.0 branch only...

@jhartmann123
Copy link
Contributor

Perfect, everything works fine with 3.1.1.1. Thanks for the quick fix!

@YohDeadfall
Copy link
Contributor

It's still blocked but by dotnet/efcore#14746.

@roji roji removed the blocked label Aug 5, 2020
roji added a commit to roji/efcore.pg that referenced this issue Aug 29, 2020
roji added a commit to roji/efcore.pg that referenced this issue Aug 29, 2020
@roji roji linked a pull request Aug 29, 2020 that will close this issue
roji added a commit to roji/efcore.pg that referenced this issue Aug 31, 2020
roji added a commit that referenced this issue Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants