Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4089

Goose Postgresql Can't Create Or Replace Stored Procedure When Commit Up [duplicate]

$
0
0

First, I tried to use $$ symbols to wrap query, but it didn't work

-- +goose UpCREATE OR REPLACE PROCEDURE update_user_email(  _user_id VARCHAR,  _email VARCHAR,  _emailverify_id UUID)LANGUAGE plpgsqlAS $$  BEGIN    -- Update User Email    UPDATE Users    SET email = _email    WHERE user_id = _user_id;    -- Delete The Verification Record    DELETE FROM useremailverifications    WHERE emailverify_id = _emailverify_id;    RAISE NOTICE 'Successfully verify user email';  END;$$;

Got this error

(base) PS D:\Learn Go\Betamart\sql\schema> goose postgres postgres://postgres:password@localhost:5432/betamart?sslmode=disable up2024/09/16 22:36:38 goose run: ERROR 005_add_stored_procedure.sql: failed to run SQL migration: failed to execute SQL query "CREATE OR REPLACE PROCEDURE update_user_email(\n  _user_id VARCHAR,\n  _email VARCHAR,\n  _emailverify_id UUID\n)\nLANGUAGE plpgsql\nAS $$\n  BEGIN\n    -- Update User Email\n    UPDATE Users\n    SET email = _email\n    WHERE user_id = _user_id;\n": pq: unterminated dollar-quoted string at or near "$$  BEGIN    -- Update User Email    UPDATE Users    SET email = _email    WHERE user_id = _user_id;"

Then, I tried to use ' symbols to wrap query, but it still didn't work.

-- +goose UpCREATE OR REPLACE PROCEDURE update_user_email(  _user_id VARCHAR,  _email VARCHAR,  _emailverify_id UUID)LANGUAGE plpgsqlAS '  BEGIN    -- Update User Email    UPDATE Users    SET email = _email    WHERE user_id = _user_id;    -- Delete The Verification Record    DELETE FROM useremailverifications    WHERE emailverify_id = _emailverify_id;    RAISE NOTICE ''Successfully verify user email'';  END;';

Got this error

(base) PS D:\Learn Go\Betamart\sql\schema> goose postgres postgres://postgres:password@localhost:5432/betamart?sslmode=disable up2024/09/16 22:36:38 goose run: ERROR 005_add_stored_procedure.sql: failed to run SQL migration: failed to execute SQL query "CREATE OR REPLACE PROCEDURE update_user_email(\n  _user_id VARCHAR,\n  _email VARCHAR,\n  _emailverify_id UUID\n)\nLANGUAGE plpgsql\nAS $$\n  BEGIN\n    -- Update User Email\n    UPDATE Users\n    SET email = _email\n    WHERE user_id = _user_id;\n": pq: unterminated dollar-quoted string at or near "$$  BEGIN    -- Update User Email    UPDATE Users    SET email = _email    WHERE user_id = _user_id;"

Help me guys! How can i create stored procedure with goose?

I want to make sure if stored procedure can be created with goose.


Viewing all articles
Browse latest Browse all 4089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>