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

Migrations fail if SQL file exists that is commented out #2839

Open
dvasdekis opened this issue Sep 5, 2019 · 3 comments
Open

Migrations fail if SQL file exists that is commented out #2839

dvasdekis opened this issue Sep 5, 2019 · 3 comments
Assignees
Labels
c/server Related to server

Comments

@dvasdekis
Copy link

dvasdekis commented Sep 5, 2019

Hi folks,

I was able to create a failure on boot that blocked the server from starting by including the below in a SQL migrations file:

/* Below doesn't work!
DROP TRIGGER IF EXISTS trigger_tbl_stg_option_details_update_time_checked ON tbl_stg_option_details;
CREATE OR REPLACE FUNCTION fx_tbl_stg_option_details_update_time_checked()
RETURNS trigger AS 'BEGIN
UPDATE tbl_stg_option_details
    SET NEW.time_checked = now();
END' LANGUAGE 'plpgsql';

CREATE TRIGGER trigger_tbl_stg_option_details_update_time_checked
  AFTER UPDATE OF return_json
  ON tbl_stg_option_details
  FOR EACH ROW
  EXECUTE PROCEDURE fx_tbl_stg_option_details_update_time_checked();
*/

Irrespective if the trigger works or doesn't etc., the statement should be ignored as it is commented out.

Thanks again! Your product is wonderful and this problem was easy to pinpoint :)

Am using hasura/graphql-engine:latest.cli-migrations docker image (beta 6)

@dvasdekis
Copy link
Author

Sorry was potentially unclear - stick the above code in a new .sql migrations file

@0x777
Copy link
Member

0x777 commented Sep 6, 2019

I guess you see an error like this?

{
    "statement": "....",
    "prepared": false,
    "error": {
        "exec_status": "EmptyQuery",
        "hint": null,
        "message": null,
        "status_code": null,
        "description": null
    },
    "arguments": []
}

Looks like the server doesn't accept empty queries. I think we should catch this error and return an empty response. For now if your migration file is empty (post comments), stick something like select 1; in the end to work around this.

@jflambert
Copy link
Contributor

jflambert commented Aug 11, 2021

This has affected me today. select 1; works. Hasura 2.0.5 with Postgres 13.3

Doesn't feel like it should be treated as an error though.

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

No branches or pull requests

4 participants