From 6b3420a5fd2fefc56655e327283f1f03ebccb07e Mon Sep 17 00:00:00 2001 From: Tyler Date: Sat, 16 Mar 2024 08:03:06 +0900 Subject: [PATCH] docs: Remove storage management section from the quick starts. (#21985) remove storage management to keep the guide simple --- .../components/MDX/storage_management.mdx | 111 ------------------ apps/docs/components/index.tsx | 2 - .../tutorials/with-angular.mdx | 4 - .../tutorials/with-expo-react-native.mdx | 4 - .../tutorials/with-flutter.mdx | 4 - .../tutorials/with-ionic-angular.mdx | 4 - .../tutorials/with-ionic-react.mdx | 4 - .../tutorials/with-ionic-vue.mdx | 4 - .../getting-started/tutorials/with-nextjs.mdx | 4 - .../getting-started/tutorials/with-nuxt-3.mdx | 4 - .../getting-started/tutorials/with-react.mdx | 4 - .../tutorials/with-redwoodjs.mdx | 4 - .../getting-started/tutorials/with-refine.mdx | 4 - .../tutorials/with-solidjs.mdx | 4 - .../getting-started/tutorials/with-svelte.mdx | 4 - .../tutorials/with-sveltekit.mdx | 4 - .../getting-started/tutorials/with-swift.mdx | 4 - .../getting-started/tutorials/with-vue-3.mdx | 4 - 18 files changed, 177 deletions(-) delete mode 100644 apps/docs/components/MDX/storage_management.mdx diff --git a/apps/docs/components/MDX/storage_management.mdx b/apps/docs/components/MDX/storage_management.mdx deleted file mode 100644 index 167fa3691d8..00000000000 --- a/apps/docs/components/MDX/storage_management.mdx +++ /dev/null @@ -1,111 +0,0 @@ -If you upload additional profile photos, they'll accumulate -in the `avatars` bucket because of their random names with only the latest being referenced -from `public.profiles` and the older versions getting orphaned. - -To automatically remove obsolete storage objects, extend the database -triggers. Note that it is not sufficient to delete the objects from the -`storage.objects` table because that would orphan and leak the actual storage objects in -the S3 backend. Instead, invoke the storage API within Postgres via the `http` extension. - -Enable the [http extension for the `extensions` schema](https://supabase.com/dashboard/project/_/database/extensions) in the Dashboard. -Then, define the following SQL functions in the SQL Editor to delete -storage objects via the API: - -```sql -create or replace function delete_storage_object(bucket text, object text, out status int, out content text) -returns record -language 'plpgsql' -security definer -as $$ -declare - project_url text := ''; - service_role_key text := ''; -- full access needed - url text := project_url||'/storage/v1/object/'||bucket||'/'||object; -begin - select - into status, content - result.status::int, result.content::text - FROM extensions.http(( - 'DELETE', - url, - ARRAY[extensions.http_header('authorization','Bearer '||service_role_key)], - NULL, - NULL)::extensions.http_request) as result; -end; -$$; - -create or replace function delete_avatar(avatar_url text, out status int, out content text) -returns record -language 'plpgsql' -security definer -as $$ -begin - select - into status, content - result.status, result.content - from public.delete_storage_object('avatars', avatar_url) as result; -end; -$$; - -``` - -Next, add a trigger that removes any obsolete avatar whenever the -profile is updated or deleted: - -```sql -create or replace function delete_old_avatar() -returns trigger -language 'plpgsql' -security definer -as $$ -declare - status int; - content text; - avatar_name text; -begin - if coalesce(old.avatar_url, '') <> '' - and (tg_op = 'DELETE' or (old.avatar_url <> coalesce(new.avatar_url, ''))) then - -- extract avatar name - avatar_name := old.avatar_url; - select - into status, content - result.status, result.content - from public.delete_avatar(avatar_name) as result; - if status <> 200 then - raise warning 'Could not delete avatar: % %', status, content; - end if; - end if; - if tg_op = 'DELETE' then - return old; - end if; - return new; -end; -$$; - -create trigger before_profile_changes - before update of avatar_url or delete on public.profiles - for each row execute function public.delete_old_avatar(); - -``` - -Finally, delete the `public.profile` row before a user is deleted. -If this step is omitted, you won't be able to delete users without -first manually deleting their avatar image. - -```sql -create or replace function delete_old_profile() -returns trigger -language 'plpgsql' -security definer -as $$ -begin - delete from public.profiles where id = old.id; - return old; -end; -$$; - -create trigger before_delete_user - before delete on auth.users - for each row execute function public.delete_old_profile(); - -``` diff --git a/apps/docs/components/index.tsx b/apps/docs/components/index.tsx index 42ce7b4614c..107b4f8bd3a 100644 --- a/apps/docs/components/index.tsx +++ b/apps/docs/components/index.tsx @@ -41,7 +41,6 @@ import ProjectSetup from './MDX/project_setup.mdx' import QuickstartIntro from './MDX/quickstart_intro.mdx' import SocialProviderSettingsSupabase from './MDX/social_provider_settings_supabase.mdx' import SocialProviderSetup from './MDX/social_provider_setup.mdx' -import StorageManagement from './MDX/storage_management.mdx' // Icons import { @@ -153,7 +152,6 @@ const components = { SocialProviderSettingsSupabase, SocialProviderSetup, StepHikeCompact, - StorageManagement, TabPanel: (props: any) => {props.children}, Tabs: (props: any) => , } diff --git a/apps/docs/content/guides/getting-started/tutorials/with-angular.mdx b/apps/docs/content/guides/getting-started/tutorials/with-angular.mdx index 4a308fe33fc..1a338015904 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-angular.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-angular.mdx @@ -525,8 +525,4 @@ export class AccountComponent implements OnInit { } ``` -### Storage management - - - At this stage you have a fully functional application! diff --git a/apps/docs/content/guides/getting-started/tutorials/with-expo-react-native.mdx b/apps/docs/content/guides/getting-started/tutorials/with-expo-react-native.mdx index 43873bc3d77..6d6319c8a27 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-expo-react-native.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-expo-react-native.mdx @@ -631,8 +631,4 @@ Now you will need to run the prebuild command to get the application working on expo prebuild ``` -### Storage management - - - At this stage you have a fully functional application! diff --git a/apps/docs/content/guides/getting-started/tutorials/with-flutter.mdx b/apps/docs/content/guides/getting-started/tutorials/with-flutter.mdx index 524329892f2..6ec8c5fb811 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-flutter.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-flutter.mdx @@ -856,10 +856,6 @@ class _AccountPageState extends State { } ``` -### Storage management - - - Congratulations, you've built a fully functional user management app using Flutter and Supabase! ## See also diff --git a/apps/docs/content/guides/getting-started/tutorials/with-ionic-angular.mdx b/apps/docs/content/guides/getting-started/tutorials/with-ionic-angular.mdx index db01f52844a..4dce06707bb 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-ionic-angular.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-ionic-angular.mdx @@ -552,10 +552,6 @@ template: ` ` ``` -### Storage management - - - At this stage, you have a fully functional application! ## See also diff --git a/apps/docs/content/guides/getting-started/tutorials/with-ionic-react.mdx b/apps/docs/content/guides/getting-started/tutorials/with-ionic-react.mdx index 69d08c1d957..cbfc4db3f49 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-ionic-react.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-ionic-react.mdx @@ -493,8 +493,4 @@ return ( ``` -### Storage management - - - At this stage you have a fully functional application! diff --git a/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdx b/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdx index 3eee57f4d2a..00b85b6aa6f 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-ionic-vue.mdx @@ -553,8 +553,4 @@ export default defineComponent({ ``` -### Storage management - - - At this stage you have a fully functional application! diff --git a/apps/docs/content/guides/getting-started/tutorials/with-nextjs.mdx b/apps/docs/content/guides/getting-started/tutorials/with-nextjs.mdx index cf66bff382b..d44da1bbb07 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-nextjs.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-nextjs.mdx @@ -1467,10 +1467,6 @@ return ( -### Storage management - - - At this stage you have a fully functional application! ## See also diff --git a/apps/docs/content/guides/getting-started/tutorials/with-nuxt-3.mdx b/apps/docs/content/guides/getting-started/tutorials/with-nuxt-3.mdx index 70f9d7e5485..ef3180c37b0 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-nuxt-3.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-nuxt-3.mdx @@ -434,8 +434,4 @@ async function signOut() { ``` -### Storage management - - - That is it! You should now be able to upload a profile photo to Supabase Storage and you have a fully functional application. diff --git a/apps/docs/content/guides/getting-started/tutorials/with-react.mdx b/apps/docs/content/guides/getting-started/tutorials/with-react.mdx index 5f0307fdb24..8ca9181db0d 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-react.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-react.mdx @@ -396,8 +396,4 @@ return ( ) ``` -### Storage management - - - At this stage you have a fully functional application! diff --git a/apps/docs/content/guides/getting-started/tutorials/with-redwoodjs.mdx b/apps/docs/content/guides/getting-started/tutorials/with-redwoodjs.mdx index 58300bd88f3..75e51643f4c 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-redwoodjs.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-redwoodjs.mdx @@ -603,10 +603,6 @@ return ( ) ``` -### Storage management - - - At this stage you have a fully functional application! ## See also diff --git a/apps/docs/content/guides/getting-started/tutorials/with-refine.mdx b/apps/docs/content/guides/getting-started/tutorials/with-refine.mdx index 502e4d6cd3a..0192a305f14 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-refine.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-refine.mdx @@ -626,8 +626,4 @@ return ( ) ``` -### Storage management - - - At this stage, you have a fully functional application! diff --git a/apps/docs/content/guides/getting-started/tutorials/with-solidjs.mdx b/apps/docs/content/guides/getting-started/tutorials/with-solidjs.mdx index 80d4dba6167..92544c54791 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-solidjs.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-solidjs.mdx @@ -415,8 +415,4 @@ return ( ) ``` -### Storage management - - - At this stage you have a fully functional application! diff --git a/apps/docs/content/guides/getting-started/tutorials/with-svelte.mdx b/apps/docs/content/guides/getting-started/tutorials/with-svelte.mdx index b85eb77996c..85a9f223967 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-svelte.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-svelte.mdx @@ -367,8 +367,4 @@ And then we can add the widget to the Account page: ``` -### Storage management - - - At this stage you have a fully functional application! diff --git a/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx b/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx index edd59df53e3..5b5172b6c37 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx @@ -610,8 +610,4 @@ And then we can add the widget to the Account page: ``` -### Storage management - - - At this stage you have a fully functional application! diff --git a/apps/docs/content/guides/getting-started/tutorials/with-swift.mdx b/apps/docs/content/guides/getting-started/tutorials/with-swift.mdx index 369748f09e5..6c110b51b6e 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-swift.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-swift.mdx @@ -514,8 +514,4 @@ struct Profile: Codable { You no longer need the `UpdateProfileParams` struct, as you can now reuse the `Profile` struct for both request and response calls. -### Storage management - - - At this stage you have a fully functional application! diff --git a/apps/docs/content/guides/getting-started/tutorials/with-vue-3.mdx b/apps/docs/content/guides/getting-started/tutorials/with-vue-3.mdx index 10bf93c4c6e..27778b2a6b2 100644 --- a/apps/docs/content/guides/getting-started/tutorials/with-vue-3.mdx +++ b/apps/docs/content/guides/getting-started/tutorials/with-vue-3.mdx @@ -377,8 +377,4 @@ import Avatar from './Avatar.vue' ``` -### Storage management - - - At this stage you have a fully functional application!