rubenv / sql-migrate

SQL schema migration tool for Go.
MIT License
3.18k stars 270 forks source link

create function in the migration file #178

Closed daddycarbone closed 1 year ago

daddycarbone commented 4 years ago

i am trying to create the function in .sql file here is my syntax

-- +migrate Up
CREATE OR REPLACE FUNCTION trigger_set_timestamp()
    RETURNS TRIGGER AS $$
BEGIN
    NEW.updated_at = NOW();
    RETURN NEW;
END;
$$

i was trying using -- +migrate StatementBegin and End but it said not matching

is there any way to create a function with sql-migrate?

DrBlury commented 1 year ago

I would kindly ask for the same functionality as it is required for my usecase. Is this planned? If this is not planned but PRs are welcome, I'd get working on it.

rubenv commented 1 year ago

There's an example here, it's supported: https://github.com/rubenv/sql-migrate/blob/master/sqlparse/sqlparse_test.go#L129-L162