You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
[hooks]
post_start='psql postgresql://postgres:postgres@localhost:54322/postgres < custom_seed.sql'post_start='dart run generate_types.dart'post_db_reset='dart run generate_types.dart'pre_stop='pg_dump postgresql://postgres:postgres@localhost:54322/postgres -n public > dumps/schema_dump.sql'
excuse my poor toml -- I'm sure this could be structured in a better way for sub-commands (e.g. supabase db reset).
In the above example, the idea is that each lifecycle command (e.g. stop, start, reset) can have pre- or post-hook(s).
Reacted by Carl Assmann, Isaac Harris-Holt, Timm Stokke, Philipp Steinrötter, Dallas James, Lauri, Han Qiao, India, John Dykes and Oputo50
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
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 supabase/seeds directory and create a load of insert statements in the seeds.sql file.
You can also have pre-seed.sql and post-seed.sql for running any other SQL you need (extensions etc.).
If you name files 1-foo.csv, 2-bar.csv, the numbering will be respected (and 10 will come after 9, not 1... thanks ascii...).
@mosnicholas we run it using a pre-commit hook with the following:
bash -c 'cd scripts/csv-seeder; go run main.go ../../supabase'
But you could also do it in CI and push the changes to the branch, like you might do with supabase gen types.
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 user.csv:
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.
This would be great. We already have custom scripts for e.g. seeding storage
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...
AFAIK seed files are run before storage objects are added, so hooks as requested in this issue would still have benefits even in this scope, e.g. to populate tables that link to storage.objects.
We're closing this because it has not had any activity for 45 days, and we try to keep the Supabase CLI issue tracker focused on reports that are still current.
If this still reproduces on the latest Supabase CLI, please comment with /reopen on its own line and include your CLI version, updated reproduction steps, and any recent error output. We appreciate the signal and are happy to take another look.
We're closing this because it has not had any activity for 45 days, and we try to keep the Supabase CLI issue tracker focused on reports that are still current.
If this still reproduces on the latest Supabase CLI, please comment with /reopen on its own line and include your CLI version, updated reproduction steps, and any recent error output. We appreciate the signal and are happy to take another look.
Activity
sweatybridge commentedon Oct 14, 2022
Also related is #160 which asks for pre/post-migration sql files.
NixBiks commentedon Jan 11, 2023
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
carlassmann commentedon Jan 24, 2023
@NixBiks as you might have Deno set up in your workspace for functions anyway, using Deno for the seed script is quite comfortable.
supabase start && deno run --allow-read=. --allow-net scripts/seed.tsmosnicholas commentedon Mar 7, 2023
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
isaacharrisholt commentedon Mar 16, 2023
@mosnicholas we ran into this problem too, so we just wrote a little script that'll read CSVs from a
supabase/seedsdirectory and create a load ofinsertstatements in theseeds.sqlfile.You can also have
pre-seed.sqlandpost-seed.sqlfor running any other SQL you need (extensions etc.).If you name files
1-foo.csv,2-bar.csv, the numbering will be respected (and 10 will come after 9, not 1... thanks ascii...).Code is here: https://gist.github.com/isaacharrisholt/8b92d21429e2981827795c5e29763a5f
mosnicholas commentedon Mar 16, 2023
oh wow nice idea :) when / how are you running it @isaacharrisholt ?
isaacharrisholt commentedon Mar 16, 2023
@mosnicholas we run it using a pre-commit hook with the following:
bash -c 'cd scripts/csv-seeder; go run main.go ../../supabase'But you could also do it in CI and push the changes to the branch, like you might do with
supabase gen types.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
user.csv:Then it'll generate:
ydennisy commentedon Jun 27, 2023
Any updates here? :)
psteinroe commentedon Dec 13, 2023
would love a pre-migrations hook to run externally managed migrations e.g. for graphile/worker.
logemann commentedon Jan 15, 2024
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.
lauri865 commentedon Feb 6, 2024
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.
logemann commentedon Jul 30, 2024
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...
jackd commentedon May 12, 2025
I realize this is a fairly old issue, but for anyone coming across it, you can now split your seed across multiple files and seed storage shows how to seed storage.
AFAIK seed files are run before storage objects are added, so hooks as requested in this issue would still have benefits even in this scope, e.g. to populate tables that link to
storage.objects.github-actions commentedon Jun 17, 2026
Hi! Thanks for opening this issue.
We're closing this because it has not had any activity for 45 days, and we try to keep the Supabase CLI issue tracker focused on reports that are still current.
If this still reproduces on the latest Supabase CLI, please comment with
/reopenon its own line and include your CLI version, updated reproduction steps, and any recent error output. We appreciate the signal and are happy to take another look.edurenye commentedon Jun 18, 2026
We still want this feature
jgoux commentedon Jun 23, 2026
/reopen
github-actions commentedon Aug 8, 2026
Hi! Thanks for opening this issue.
We're closing this because it has not had any activity for 45 days, and we try to keep the Supabase CLI issue tracker focused on reports that are still current.
If this still reproduces on the latest Supabase CLI, please comment with
/reopenon its own line and include your CLI version, updated reproduction steps, and any recent error output. We appreciate the signal and are happy to take another look.edurenye commentedon Aug 8, 2026
Would still be nice to have