-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add hooks to cli commands #501
Comments
Also related is #160 which asks for pre/post-migration sql files. |
Would be great with an example where a seed.ts file is executed after resetting the db. I always run into TS config issues with imports etc. I imagine I'm not the only one |
@NixBiks as you might have Deno set up in your workspace for functions anyway, using Deno for the seed script is quite comfortable.
|
would love to know if there have been more thoughts on this topic? Particularly for seed files. My seed.sql is getting really large, would be very helpful to be able to split it up a bit and simplify |
@mosnicholas we ran into this problem too, so we just wrote a little script that'll read CSVs from a You can also have If you name files Code is here: https://gist.github.com/isaacharrisholt/8b92d21429e2981827795c5e29763a5f |
oh wow nice idea :) when / how are you running it @isaacharrisholt ? |
@mosnicholas we run it using a pre-commit hook with the following:
But you could also do it in CI and push the changes to the branch, like you might do with One thing you have to be careful with is that it'll create insert statements exactly how you've written the CSVs - it won't add quotes or anything. This is handy though, because you can call postgres functions. If the following file is
Then it'll generate: INSERT INTO user (id, uuid, date, name)
VALUES (1, gen_random_uuid(), now(), 'Isaac'); |
Any updates here? :) |
would love a pre-migrations hook to run externally managed migrations e.g. for graphile/worker. |
This feature req would also be the best way to seed files into storage right? I really would like to have some files already present on starting local dev. |
This would be great. We already have custom scripts for e.g. seeding storage, and now looking to run idempotent migrations for some stuff like webhooks, and so fort. Would be great to pipe them into the CLI workflows, as custom scripts can be easy to forgotten / accidentially bypassed in the team. |
how do you approached seeding storage? I really would like to see a feature lfrom supabase ike seed-storage.yml where we just define the files together with the fileURL and map them to the buckets created in seed.sql. This way we could db reset everything and have a full running DB with storage again... |
Feature request
Is your feature request related to a problem? Please describe.
Currently, when I would like to run a command before or after certain supabase cli commands, I've to run that manually or write a script to run both commands.
Describe the solution you'd like
It would be useful if we could hook commands to supabase cli commands. One idea comes to mind is to define them within the
config.toml
such as:In the above example, the idea is that each lifecycle command (e.g. stop, start, reset) can have pre- or post-hook(s).
The text was updated successfully, but these errors were encountered: