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

"CREATE TABLE IF NOT EXISTS" results in a false-positive error if table already exists #52

Open
pk-ot opened this issue Jan 27, 2024 · 1 comment

Comments

@pk-ot
Copy link

pk-ot commented Jan 27, 2024

Take a script like the auto-generated migration history table creation by Entity Framework:

CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" (
    "MigrationId" character varying(150) NOT NULL,
    "ProductVersion" character varying(32) NOT NULL,
    CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId")
);

This results in a false error if the table actually already exists:

psql:/home/runner/work/somethingsomething.sql:5: NOTICE:  relation "__EFMigrationsHistory" already exists, skipping
[...]
Error: Error occurred while running action:
Error: error in file: /home/runner/work/somethingsomething.sql
psql:/home/runner/work/somethingsomething.sql:5: NOTICE:  relation "__EFMigrationsHistory" already exists, skipping

Which subsequently and wrongly fails the build.

@pk-ot
Copy link
Author

pk-ot commented Jan 27, 2024

A temporary workaround is to raise the client message min level to warnings, by adding an option in your connection string:

options='--client_min_messages=WARNING'

This prevents the false error but is not ideal because you'll also not have notices that might be interesting in the log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant