Skip to content

Select bug in pg/EF00001_PopulateOIDCDb #286

@tomtom5152

Description

@tomtom5152

At the end of pg/EF0001_PopulateOIDCDb there are commands to insert the migration data into __Efmigrationshistory that use a nested SELECT … FROM … WHERE NOT to assign the values. This works if the table contains data, but if there are no rows to start with, the values are not selected, producing an empty result and empty insert.

= Alternatives

  1. INSERT INTO … VALUES ... ON CONFLICT
  2. SELECT … WHERE NOT (without FROM clause)

I believe the intention here was to prevent the script erroring if the migration rows already exist, although this shouldn’t be possible as it is already inside an IF NOT EXISTS block. As such, it may be possible to drop the conditional stage and use a simple INSERT INTO … VALUES statement.

I am happy to create a PR with these changes to the existing file, so future migrations work as expected if there’s any guidance on the preferred method/combining inserts, unless there is a compelling reason not to update the existing file I’m unaware of.

Tested with Postgres 16 + 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions