does your migration approach handle storage change...
# off-topic
k
does your migration approach handle storage changes? I think there's probably a way to do it by writing a custom script to diff changes against entries in storage across db's. Curious if anyone has done that yet
s
I don't think you would or should be making changes to the storage schema so migrations shouldn't worry about that
Unless you are migrating data which I don't think is a good idea especially when dealing with production and staging servers
My migrations are purely db schema based, not data in the schema
k
so the issue I see with migrations is that if you add a new storage bucket in a
dev
environment, and also add policies for that bucket, and migrate the schema, then your
prod
environment would have the policies but not the bucket. since you'd probably want the same buckets across environments, it seems to me to make sense for migrating the actual data inside of the
storage.buckets
table alongside the schema changes.
storage.buckets
just contains info about the bucket themselves, not the actual content contained within
s
In that case you could still just write an insert in one of the migration files to do that, so the only issue here is that s3 itself wouldn't have the bucket, but since my migrations are just JS files I think I could probably write a function using the supabase library to create a bucket in it (I need to test this)
k
nice yeah that makes sense, i'll have to play with that too!
looks like you can straight up create a bucket through sql too though
s
Hmm, I wonder if that now triggers the s3 bucket creation?
I'm going to test it in the SQL editor from the UI now and see
k
yeah maybe there is some trigger watching the db? not sure how it works behind the scenes for that part
s
It will be awesome if it does
Oh wow, it worked
But I'm guessing they don't need to create the s3 bucket as yet, the creation can happen when you upload your first file
Thanks for this, now my migration tool can work even better knowing that storage bucket creation are catered for too
k
yeah no problem! came across this when I was writing the migra migration article
s
I really need to put my head down and write some articles too, just can't seem to find the time to focus enough