diff --git a/migrations/tenant/0046-buckets-objects-grants.sql b/migrations/tenant/0046-buckets-objects-grants.sql new file mode 100644 index 000000000..45c3a621f --- /dev/null +++ b/migrations/tenant/0046-buckets-objects-grants.sql @@ -0,0 +1,15 @@ +do $$ +declare + super_user text = coalesce(current_setting('storage.super_user', true), 'postgres'); +begin + execute 'grant all on storage.buckets, storage.objects to ' || super_user || ' with grant option'; +end $$; + +do $$ +declare + anon_role text = coalesce(current_setting('storage.anon_role', true), 'anon'); + authenticated_role text = coalesce(current_setting('storage.authenticated_role', true), 'authenticated'); + service_role text = coalesce(current_setting('storage.service_role', true), 'service_role'); +begin + execute 'grant all on storage.buckets, storage.objects to ' || service_role || ', ' || authenticated_role || ', ' || anon_role; +end $$; diff --git a/src/internal/database/migrations/types.ts b/src/internal/database/migrations/types.ts index fd6292b89..ce2eb03f7 100644 --- a/src/internal/database/migrations/types.ts +++ b/src/internal/database/migrations/types.ts @@ -44,4 +44,5 @@ export const DBMigration = { 'fix-object-level': 43, 'vector-bucket-type': 44, 'vector-buckets': 45, + 'buckets-objects-grants': 46, }