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

Manage functions as standalone files #53

Closed
Craigfis opened this issue Sep 28, 2020 · 2 comments
Closed

Manage functions as standalone files #53

Craigfis opened this issue Sep 28, 2020 · 2 comments

Comments

@Craigfis
Copy link

Craigfis commented Sep 28, 2020

I'd like to be able to define my SQL functions in standalone files so that when I make changes to them they can be diffed against their previous versions. Currently I have to script dropping and recreating the function in a new migration, giving no easy way of seeing what the actual changes are via a diff.
If I could instead reference a function file in my migration I'd get the diff ability and the ability to have it automatically applied by the migration. (The hash for the migration should include hashing the contents of the referenced file.)

e.g. something like
9_ChangeMyFunc.sql:

-- Apply updated version of function
!include ./funcs/my_function.sql

Where funcs/my_function.sql contains:

drop function my_function(IN param number);
create function my_function(IN param number, IN param2 text)
as $BODY$
  select param, param2
$BODY$;

@ThomWright
Copy link
Owner

Hi, thanks for the issue. I think this is effectively a duplicate of #27, but with functions as a use case, not just views.

It's something I should consider supporting, I just haven't had the time/energy to put much thought into it.

@Craigfis
Copy link
Author

So, @ThomWright, no thoughts on how you'd like to see this support implemented?

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

No branches or pull requests

2 participants