From 45a4b1ba244fe8f663690b20040431d7d99dbe1b Mon Sep 17 00:00:00 2001 From: Lucas Santana Date: Fri, 31 Jan 2025 10:50:48 -0300 Subject: [PATCH] =?UTF-8?q?docs:=20adicionando=20documenta=C3=A7=C3=A3o=20?= =?UTF-8?q?ao=20projeto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supabase/contexts/constraints.md | 408 +++++++++++ supabase/contexts/dependencies.md | 698 +++++++++++++++++++ supabase/contexts/full_schema.md | 637 +++++++++++++++++ supabase/contexts/functions.md | 1084 +++++++++++++++++++++++++++++ supabase/contexts/policies.md | 91 +++ 5 files changed, 2918 insertions(+) create mode 100644 supabase/contexts/constraints.md create mode 100644 supabase/contexts/dependencies.md create mode 100644 supabase/contexts/full_schema.md create mode 100644 supabase/contexts/functions.md create mode 100644 supabase/contexts/policies.md diff --git a/supabase/contexts/constraints.md b/supabase/contexts/constraints.md new file mode 100644 index 0000000..f0ec259 --- /dev/null +++ b/supabase/contexts/constraints.md @@ -0,0 +1,408 @@ +| table_schema | table_name | column_name | constraint_type | +| ------------------- | ------------------------------- | --------------------- | --------------- | +| public | story_exercise_words | id | PRIMARY KEY | +| public | story_exercise_words | story_id | FOREIGN KEY | +| public | story_exercise_words | story_id | UNIQUE | +| public | story_exercise_words | word | UNIQUE | +| public | story_exercise_words | exercise_type | UNIQUE | +| public | story_exercise_words | | CHECK | +| public | story_pages | story_id | FOREIGN KEY | +| public | story_pages | story_id | FOREIGN KEY | +| public | story_pages | id | PRIMARY KEY | +| public | story_generations | id | PRIMARY KEY | +| public | story_generations | story_id | FOREIGN KEY | +| public | schools | id | PRIMARY KEY | +| public | teachers | email | UNIQUE | +| public | teachers | id | PRIMARY KEY | +| public | teachers | school_id | FOREIGN KEY | +| public | teachers | | CHECK | +| public | classes | id | PRIMARY KEY | +| public | classes | school_id | FOREIGN KEY | +| public | classes | teacher_id | FOREIGN KEY | +| public | teacher_classes | class_id | FOREIGN KEY | +| public | teacher_classes | id | PRIMARY KEY | +| public | teacher_classes | teacher_id | UNIQUE | +| public | teacher_classes | class_id | UNIQUE | +| public | teacher_classes | teacher_id | FOREIGN KEY | +| public | students | class_id | FOREIGN KEY | +| public | students | email | UNIQUE | +| public | students | id | PRIMARY KEY | +| public | students | school_id | FOREIGN KEY | +| public | students | | CHECK | +| public | story_themes | id | PRIMARY KEY | +| public | story_themes | slug | UNIQUE | +| public | story_subjects | id | PRIMARY KEY | +| public | story_subjects | slug | UNIQUE | +| public | story_characters | id | PRIMARY KEY | +| public | story_characters | slug | UNIQUE | +| public | story_settings | id | PRIMARY KEY | +| public | story_settings | slug | UNIQUE | +| public | stories | character_id | FOREIGN KEY | +| public | stories | setting_id | FOREIGN KEY | +| public | stories | subject_id | FOREIGN KEY | +| public | stories | theme_id | FOREIGN KEY | +| public | stories | character_id | FOREIGN KEY | +| public | stories | id | PRIMARY KEY | +| public | stories | setting_id | FOREIGN KEY | +| public | stories | | CHECK | +| public | stories | student_id | FOREIGN KEY | +| public | stories | subject_id | FOREIGN KEY | +| public | stories | theme_id | FOREIGN KEY | +| public | teacher_invites | id | PRIMARY KEY | +| public | teacher_invites | school_id | FOREIGN KEY | +| public | teacher_invites | | CHECK | +| public | teacher_invites | token | UNIQUE | +| public | phonics_exercise_types | id | PRIMARY KEY | +| public | phonics_exercises | id | PRIMARY KEY | +| public | phonics_exercises | type_id | FOREIGN KEY | +| public | phonics_words | id | PRIMARY KEY | +| public | phonics_exercise_words | exercise_id | FOREIGN KEY | +| public | phonics_exercise_words | exercise_id | UNIQUE | +| public | phonics_exercise_words | word_id | UNIQUE | +| public | phonics_exercise_words | id | PRIMARY KEY | +| public | phonics_exercise_words | word_id | FOREIGN KEY | +| public | phonics_categories | id | PRIMARY KEY | +| public | phonics_exercise_media | exercise_id | FOREIGN KEY | +| public | phonics_exercise_media | media_type_id | FOREIGN KEY | +| public | phonics_exercise_media | id | PRIMARY KEY | +| public | student_phonics_attempt_answers | attempt_id | FOREIGN KEY | +| public | student_phonics_attempt_answers | id | PRIMARY KEY | +| public | student_phonics_attempt_answers | word_id | FOREIGN KEY | +| public | media_types | id | PRIMARY KEY | +| public | student_phonics_progress | exercise_id | FOREIGN KEY | +| public | student_phonics_progress | id | PRIMARY KEY | +| public | student_phonics_progress | student_id | UNIQUE | +| public | student_phonics_progress | exercise_id | UNIQUE | +| public | student_phonics_progress | student_id | FOREIGN KEY | +| public | student_phonics_attempts | exercise_id | FOREIGN KEY | +| public | student_phonics_attempts | id | PRIMARY KEY | +| public | student_phonics_attempts | student_id | FOREIGN KEY | +| public | achievement_types | id | PRIMARY KEY | +| public | phonics_achievements | id | PRIMARY KEY | +| public | phonics_achievements | type_id | FOREIGN KEY | +| public | student_phonics_achievements | achievement_id | FOREIGN KEY | +| public | student_phonics_achievements | id | PRIMARY KEY | +| public | student_phonics_achievements | student_id | UNIQUE | +| public | student_phonics_achievements | achievement_id | UNIQUE | +| public | student_phonics_achievements | student_id | FOREIGN KEY | +| public | phonics_word_audio | id | PRIMARY KEY | +| public | phonics_word_audio | word | UNIQUE | +| public | story_recordings | story_id | FOREIGN KEY | +| public | story_recordings | story_id | FOREIGN KEY | +| public | story_recordings | | CHECK | +| public | story_recordings | | CHECK | +| public | story_recordings | | CHECK | +| public | story_recordings | id | PRIMARY KEY | +| public | story_recordings | | CHECK | +| public | story_recordings | student_id | FOREIGN KEY | +| public | interests | id | PRIMARY KEY | +| public | interests | student_id | UNIQUE | +| public | interests | category | UNIQUE | +| public | interests | item | UNIQUE | +| public | interests | student_id | FOREIGN KEY | +| public | achievements | id | PRIMARY KEY | +| public | student_achievements_old | achievement_id | FOREIGN KEY | +| public | student_achievements_old | id | PRIMARY KEY | +| public | student_achievements_old | student_id | FOREIGN KEY | +| public | student_achievements | achievement_id | FOREIGN KEY | +| public | student_achievements | id | PRIMARY KEY | +| public | student_achievements | student_id | FOREIGN KEY | +| storage | buckets | id | PRIMARY KEY | +| storage | migrations | name | UNIQUE | +| storage | migrations | id | PRIMARY KEY | +| storage | objects | bucket_id | FOREIGN KEY | +| storage | objects | id | PRIMARY KEY | +| storage | s3_multipart_uploads | bucket_id | FOREIGN KEY | +| storage | s3_multipart_uploads | id | PRIMARY KEY | +| storage | s3_multipart_uploads_parts | bucket_id | FOREIGN KEY | +| storage | s3_multipart_uploads_parts | id | PRIMARY KEY | +| storage | s3_multipart_uploads_parts | upload_id | FOREIGN KEY | +| auth | refresh_tokens | id | PRIMARY KEY | +| auth | refresh_tokens | session_id | FOREIGN KEY | +| auth | refresh_tokens | token | UNIQUE | +| auth | instances | id | PRIMARY KEY | +| auth | schema_migrations | version | PRIMARY KEY | +| auth | users | | CHECK | +| auth | users | phone | UNIQUE | +| auth | users | id | PRIMARY KEY | +| auth | sso_providers | | CHECK | +| auth | sso_providers | id | PRIMARY KEY | +| auth | saml_relay_states | | CHECK | +| auth | saml_relay_states | flow_state_id | FOREIGN KEY | +| auth | saml_relay_states | id | PRIMARY KEY | +| auth | saml_relay_states | sso_provider_id | FOREIGN KEY | +| auth | flow_state | id | PRIMARY KEY | +| auth | one_time_tokens | id | PRIMARY KEY | +| auth | one_time_tokens | | CHECK | +| auth | one_time_tokens | user_id | FOREIGN KEY | +| auth | audit_log_entries | id | PRIMARY KEY | +| auth | mfa_factors | last_challenged_at | UNIQUE | +| auth | mfa_factors | id | PRIMARY KEY | +| auth | mfa_factors | user_id | FOREIGN KEY | +| auth | sessions | id | PRIMARY KEY | +| auth | sessions | user_id | FOREIGN KEY | +| auth | sso_domains | | CHECK | +| auth | sso_domains | id | PRIMARY KEY | +| auth | sso_domains | sso_provider_id | FOREIGN KEY | +| auth | mfa_challenges | factor_id | FOREIGN KEY | +| auth | mfa_challenges | id | PRIMARY KEY | +| auth | mfa_amr_claims | id | PRIMARY KEY | +| auth | mfa_amr_claims | session_id | UNIQUE | +| auth | mfa_amr_claims | authentication_method | UNIQUE | +| auth | mfa_amr_claims | session_id | FOREIGN KEY | +| auth | saml_providers | | CHECK | +| auth | saml_providers | | CHECK | +| auth | saml_providers | | CHECK | +| auth | saml_providers | entity_id | UNIQUE | +| auth | saml_providers | id | PRIMARY KEY | +| auth | saml_providers | sso_provider_id | FOREIGN KEY | +| auth | identities | id | PRIMARY KEY | +| auth | identities | provider | UNIQUE | +| auth | identities | provider_id | UNIQUE | +| auth | identities | user_id | FOREIGN KEY | +| realtime | schema_migrations | version | PRIMARY KEY | +| realtime | subscription | id | PRIMARY KEY | +| realtime | messages | id | PRIMARY KEY | +| realtime | messages | inserted_at | PRIMARY KEY | +| pgsodium | key | | CHECK | +| pgsodium | key | parent_key | FOREIGN KEY | +| pgsodium | key | id | PRIMARY KEY | +| pgsodium | key | name | UNIQUE | +| pgsodium | key | | CHECK | +| vault | secrets | key_id | FOREIGN KEY | +| vault | secrets | id | PRIMARY KEY | +| supabase_migrations | schema_migrations | version | PRIMARY KEY | +| supabase_migrations | seed_files | path | PRIMARY KEY | +| public | story_exercise_words | | CHECK | +| public | story_exercise_words | | CHECK | +| public | story_exercise_words | | CHECK | +| public | story_pages | | CHECK | +| public | story_pages | | CHECK | +| public | story_pages | | CHECK | +| public | story_pages | | CHECK | +| public | story_pages | | CHECK | +| public | story_generations | | CHECK | +| public | story_generations | | CHECK | +| public | story_generations | | CHECK | +| public | story_generations | | CHECK | +| public | story_generations | | CHECK | +| public | schools | | CHECK | +| public | schools | | CHECK | +| public | schools | | CHECK | +| public | schools | | CHECK | +| public | schools | | CHECK | +| public | teachers | | CHECK | +| public | teachers | | CHECK | +| public | teachers | | CHECK | +| public | teachers | | CHECK | +| public | teachers | | CHECK | +| public | teachers | | CHECK | +| public | classes | | CHECK | +| public | classes | | CHECK | +| public | classes | | CHECK | +| public | classes | | CHECK | +| public | classes | | CHECK | +| public | classes | | CHECK | +| public | classes | | CHECK | +| public | teacher_classes | | CHECK | +| public | teacher_classes | | CHECK | +| public | teacher_classes | | CHECK | +| public | teacher_classes | | CHECK | +| public | students | | CHECK | +| public | students | | CHECK | +| public | students | | CHECK | +| public | students | | CHECK | +| public | students | | CHECK | +| public | students | | CHECK | +| public | students | | CHECK | +| public | students | | CHECK | +| public | story_themes | | CHECK | +| public | story_themes | | CHECK | +| public | story_themes | | CHECK | +| public | story_themes | | CHECK | +| public | story_themes | | CHECK | +| public | story_themes | | CHECK | +| public | story_themes | | CHECK | +| public | story_subjects | | CHECK | +| public | story_subjects | | CHECK | +| public | story_subjects | | CHECK | +| public | story_subjects | | CHECK | +| public | story_subjects | | CHECK | +| public | story_subjects | | CHECK | +| public | story_subjects | | CHECK | +| public | story_characters | | CHECK | +| public | story_characters | | CHECK | +| public | story_characters | | CHECK | +| public | story_characters | | CHECK | +| public | story_characters | | CHECK | +| public | story_characters | | CHECK | +| public | story_characters | | CHECK | +| public | story_settings | | CHECK | +| public | story_settings | | CHECK | +| public | story_settings | | CHECK | +| public | story_settings | | CHECK | +| public | story_settings | | CHECK | +| public | story_settings | | CHECK | +| public | story_settings | | CHECK | +| public | stories | | CHECK | +| public | stories | | CHECK | +| public | stories | | CHECK | +| public | stories | | CHECK | +| public | stories | | CHECK | +| public | stories | | CHECK | +| public | teacher_invites | | CHECK | +| public | teacher_invites | | CHECK | +| public | teacher_invites | | CHECK | +| public | teacher_invites | | CHECK | +| public | teacher_invites | | CHECK | +| public | teacher_invites | | CHECK | +| public | teacher_invites | | CHECK | +| public | phonics_exercise_types | | CHECK | +| public | phonics_exercise_types | | CHECK | +| public | phonics_exercises | | CHECK | +| public | phonics_exercises | | CHECK | +| public | phonics_exercises | | CHECK | +| public | phonics_exercises | | CHECK | +| public | phonics_words | | CHECK | +| public | phonics_words | | CHECK | +| public | phonics_words | | CHECK | +| public | phonics_exercise_words | | CHECK | +| public | phonics_categories | | CHECK | +| public | phonics_categories | | CHECK | +| public | phonics_categories | | CHECK | +| public | phonics_categories | | CHECK | +| public | phonics_exercise_media | | CHECK | +| public | phonics_exercise_media | | CHECK | +| public | student_phonics_attempt_answers | | CHECK | +| public | student_phonics_attempt_answers | | CHECK | +| public | media_types | | CHECK | +| public | media_types | | CHECK | +| public | student_phonics_progress | | CHECK | +| public | student_phonics_attempts | | CHECK | +| public | student_phonics_attempts | | CHECK | +| public | achievement_types | | CHECK | +| public | achievement_types | | CHECK | +| public | phonics_achievements | | CHECK | +| public | phonics_achievements | | CHECK | +| public | student_phonics_achievements | | CHECK | +| public | phonics_word_audio | | CHECK | +| public | phonics_word_audio | | CHECK | +| public | phonics_word_audio | | CHECK | +| public | phonics_word_audio | | CHECK | +| public | story_recordings | | CHECK | +| public | story_recordings | | CHECK | +| public | story_recordings | | CHECK | +| public | interests | | CHECK | +| public | interests | | CHECK | +| public | interests | | CHECK | +| public | interests | | CHECK | +| public | interests | | CHECK | +| public | interests | | CHECK | +| public | achievements | | CHECK | +| public | student_achievements_old | | CHECK | +| public | student_achievements | | CHECK | +| storage | buckets | | CHECK | +| storage | buckets | | CHECK | +| storage | migrations | | CHECK | +| storage | migrations | | CHECK | +| storage | migrations | | CHECK | +| storage | objects | | CHECK | +| storage | s3_multipart_uploads | | CHECK | +| storage | s3_multipart_uploads | | CHECK | +| storage | s3_multipart_uploads | | CHECK | +| storage | s3_multipart_uploads | | CHECK | +| storage | s3_multipart_uploads | | CHECK | +| storage | s3_multipart_uploads | | CHECK | +| storage | s3_multipart_uploads | | CHECK | +| storage | s3_multipart_uploads_parts | | CHECK | +| storage | s3_multipart_uploads_parts | | CHECK | +| storage | s3_multipart_uploads_parts | | CHECK | +| storage | s3_multipart_uploads_parts | | CHECK | +| storage | s3_multipart_uploads_parts | | CHECK | +| storage | s3_multipart_uploads_parts | | CHECK | +| storage | s3_multipart_uploads_parts | | CHECK | +| storage | s3_multipart_uploads_parts | | CHECK | +| storage | s3_multipart_uploads_parts | | CHECK | +| auth | refresh_tokens | | CHECK | +| auth | instances | | CHECK | +| auth | schema_migrations | | CHECK | +| auth | users | | CHECK | +| auth | users | | CHECK | +| auth | users | | CHECK | +| auth | sso_providers | | CHECK | +| auth | saml_relay_states | | CHECK | +| auth | saml_relay_states | | CHECK | +| auth | saml_relay_states | | CHECK | +| auth | flow_state | | CHECK | +| auth | flow_state | | CHECK | +| auth | flow_state | | CHECK | +| auth | flow_state | | CHECK | +| auth | flow_state | | CHECK | +| auth | flow_state | | CHECK | +| auth | one_time_tokens | | CHECK | +| auth | one_time_tokens | | CHECK | +| auth | one_time_tokens | | CHECK | +| auth | one_time_tokens | | CHECK | +| auth | one_time_tokens | | CHECK | +| auth | one_time_tokens | | CHECK | +| auth | one_time_tokens | | CHECK | +| auth | audit_log_entries | | CHECK | +| auth | audit_log_entries | | CHECK | +| auth | mfa_factors | | CHECK | +| auth | mfa_factors | | CHECK | +| auth | mfa_factors | | CHECK | +| auth | mfa_factors | | CHECK | +| auth | mfa_factors | | CHECK | +| auth | mfa_factors | | CHECK | +| auth | sessions | | CHECK | +| auth | sessions | | CHECK | +| auth | sso_domains | | CHECK | +| auth | sso_domains | | CHECK | +| auth | sso_domains | | CHECK | +| auth | mfa_challenges | | CHECK | +| auth | mfa_challenges | | CHECK | +| auth | mfa_challenges | | CHECK | +| auth | mfa_challenges | | CHECK | +| auth | mfa_amr_claims | | CHECK | +| auth | mfa_amr_claims | | CHECK | +| auth | mfa_amr_claims | | CHECK | +| auth | mfa_amr_claims | | CHECK | +| auth | mfa_amr_claims | | CHECK | +| auth | saml_providers | | CHECK | +| auth | saml_providers | | CHECK | +| auth | saml_providers | | CHECK | +| auth | saml_providers | | CHECK | +| auth | identities | | CHECK | +| auth | identities | | CHECK | +| auth | identities | | CHECK | +| auth | identities | | CHECK | +| auth | identities | | CHECK | +| realtime | schema_migrations | | CHECK | +| realtime | subscription | | CHECK | +| realtime | subscription | | CHECK | +| realtime | subscription | | CHECK | +| realtime | subscription | | CHECK | +| realtime | subscription | | CHECK | +| realtime | subscription | | CHECK | +| realtime | subscription | | CHECK | +| realtime | messages | | CHECK | +| realtime | messages | | CHECK | +| realtime | messages | | CHECK | +| realtime | messages | | CHECK | +| realtime | messages | | CHECK | +| pgsodium | key | | CHECK | +| pgsodium | key | | CHECK | +| vault | secrets | | CHECK | +| vault | secrets | | CHECK | +| vault | secrets | | CHECK | +| vault | secrets | | CHECK | +| vault | secrets | | CHECK | +| supabase_migrations | schema_migrations | | CHECK | +| supabase_migrations | seed_files | | CHECK | +| supabase_migrations | seed_files | | CHECK | +| net | http_request_queue | | CHECK | +| net | http_request_queue | | CHECK | +| net | http_request_queue | | CHECK | +| net | http_request_queue | | CHECK | +| net | http_request_queue | | CHECK | +| net | _http_response | | CHECK | \ No newline at end of file diff --git a/supabase/contexts/dependencies.md b/supabase/contexts/dependencies.md new file mode 100644 index 0000000..4395e99 --- /dev/null +++ b/supabase/contexts/dependencies.md @@ -0,0 +1,698 @@ +| dependent_object | source_object | +| ---------------- | -------------------------------------------------------- | +| 12003 | pg_roles | +| 12008 | pg_shadow | +| 12013 | pg_group | +| 12017 | pg_user | +| 12017 | pg_shadow | +| 12017 | pg_shadow | +| 12017 | pg_shadow | +| 12017 | pg_shadow | +| 12017 | pg_shadow | +| 12017 | pg_shadow | +| 12017 | pg_shadow | +| 12017 | pg_shadow | +| 12021 | pg_policies | +| 12026 | pg_rules | +| 12031 | pg_views | +| 12036 | pg_tables | +| 12041 | pg_matviews | +| 12046 | pg_indexes | +| 12051 | pg_sequences | +| 12056 | pg_stats | +| 12061 | pg_stats_ext | +| 12066 | pg_stats_ext_exprs | +| 12071 | pg_publication_tables | +| 12076 | pg_locks | +| 12080 | pg_cursors | +| 12084 | pg_available_extensions | +| 12088 | pg_available_extension_versions | +| 12093 | pg_prepared_xacts | +| 12098 | pg_prepared_statements | +| 12102 | pg_seclabels | +| 12107 | pg_settings | +| 12108 | pg_settings | +| 12108 | pg_settings | +| 12108 | pg_settings | +| 12109 | pg_settings | +| 12113 | pg_file_settings | +| 12117 | pg_hba_file_rules | +| 12121 | pg_ident_file_mappings | +| 12125 | pg_timezone_abbrevs | +| 12129 | pg_timezone_names | +| 12133 | pg_config | +| 12137 | pg_shmem_allocations | +| 12141 | pg_backend_memory_contexts | +| 12145 | pg_stat_all_tables | +| 12150 | pg_stat_xact_all_tables | +| 12155 | pg_stat_sys_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12155 | pg_stat_all_tables | +| 12160 | pg_stat_xact_sys_tables | +| 12160 | pg_stat_xact_all_tables | +| 12160 | pg_stat_xact_all_tables | +| 12160 | pg_stat_xact_all_tables | +| 12160 | pg_stat_xact_all_tables | +| 12160 | pg_stat_xact_all_tables | +| 12160 | pg_stat_xact_all_tables | +| 12160 | pg_stat_xact_all_tables | +| 12160 | pg_stat_xact_all_tables | +| 12160 | pg_stat_xact_all_tables | +| 12160 | pg_stat_xact_all_tables | +| 12160 | pg_stat_xact_all_tables | +| 12164 | pg_stat_user_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12164 | pg_stat_all_tables | +| 12169 | pg_stat_xact_user_tables | +| 12169 | pg_stat_xact_all_tables | +| 12169 | pg_stat_xact_all_tables | +| 12169 | pg_stat_xact_all_tables | +| 12169 | pg_stat_xact_all_tables | +| 12169 | pg_stat_xact_all_tables | +| 12169 | pg_stat_xact_all_tables | +| 12169 | pg_stat_xact_all_tables | +| 12169 | pg_stat_xact_all_tables | +| 12169 | pg_stat_xact_all_tables | +| 12169 | pg_stat_xact_all_tables | +| 12169 | pg_stat_xact_all_tables | +| 12173 | pg_statio_all_tables | +| 12178 | pg_statio_sys_tables | +| 12178 | pg_statio_all_tables | +| 12178 | pg_statio_all_tables | +| 12178 | pg_statio_all_tables | +| 12178 | pg_statio_all_tables | +| 12178 | pg_statio_all_tables | +| 12178 | pg_statio_all_tables | +| 12178 | pg_statio_all_tables | +| 12178 | pg_statio_all_tables | +| 12178 | pg_statio_all_tables | +| 12178 | pg_statio_all_tables | +| 12178 | pg_statio_all_tables | +| 12182 | pg_statio_user_tables | +| 12182 | pg_statio_all_tables | +| 12182 | pg_statio_all_tables | +| 12182 | pg_statio_all_tables | +| 12182 | pg_statio_all_tables | +| 12182 | pg_statio_all_tables | +| 12182 | pg_statio_all_tables | +| 12182 | pg_statio_all_tables | +| 12182 | pg_statio_all_tables | +| 12182 | pg_statio_all_tables | +| 12182 | pg_statio_all_tables | +| 12182 | pg_statio_all_tables | +| 12186 | pg_stat_all_indexes | +| 12191 | pg_stat_sys_indexes | +| 12191 | pg_stat_all_indexes | +| 12191 | pg_stat_all_indexes | +| 12191 | pg_stat_all_indexes | +| 12191 | pg_stat_all_indexes | +| 12191 | pg_stat_all_indexes | +| 12191 | pg_stat_all_indexes | +| 12191 | pg_stat_all_indexes | +| 12191 | pg_stat_all_indexes | +| 12195 | pg_stat_user_indexes | +| 12195 | pg_stat_all_indexes | +| 12195 | pg_stat_all_indexes | +| 12195 | pg_stat_all_indexes | +| 12195 | pg_stat_all_indexes | +| 12195 | pg_stat_all_indexes | +| 12195 | pg_stat_all_indexes | +| 12195 | pg_stat_all_indexes | +| 12195 | pg_stat_all_indexes | +| 12199 | pg_statio_all_indexes | +| 12204 | pg_statio_sys_indexes | +| 12204 | pg_statio_all_indexes | +| 12204 | pg_statio_all_indexes | +| 12204 | pg_statio_all_indexes | +| 12204 | pg_statio_all_indexes | +| 12204 | pg_statio_all_indexes | +| 12204 | pg_statio_all_indexes | +| 12204 | pg_statio_all_indexes | +| 12208 | pg_statio_user_indexes | +| 12208 | pg_statio_all_indexes | +| 12208 | pg_statio_all_indexes | +| 12208 | pg_statio_all_indexes | +| 12208 | pg_statio_all_indexes | +| 12208 | pg_statio_all_indexes | +| 12208 | pg_statio_all_indexes | +| 12208 | pg_statio_all_indexes | +| 12212 | pg_statio_all_sequences | +| 12217 | pg_statio_sys_sequences | +| 12217 | pg_statio_all_sequences | +| 12217 | pg_statio_all_sequences | +| 12217 | pg_statio_all_sequences | +| 12217 | pg_statio_all_sequences | +| 12217 | pg_statio_all_sequences | +| 12221 | pg_statio_user_sequences | +| 12221 | pg_statio_all_sequences | +| 12221 | pg_statio_all_sequences | +| 12221 | pg_statio_all_sequences | +| 12221 | pg_statio_all_sequences | +| 12221 | pg_statio_all_sequences | +| 12225 | pg_stat_activity | +| 12230 | pg_stat_replication | +| 12235 | pg_stat_slru | +| 12239 | pg_stat_wal_receiver | +| 12243 | pg_stat_recovery_prefetch | +| 12247 | pg_stat_subscription | +| 12252 | pg_stat_ssl | +| 12256 | pg_stat_gssapi | +| 12260 | pg_replication_slots | +| 12265 | pg_stat_replication_slots | +| 12265 | pg_replication_slots | +| 12265 | pg_replication_slots | +| 12269 | pg_stat_database | +| 12274 | pg_stat_database_conflicts | +| 12278 | pg_stat_user_functions | +| 12283 | pg_stat_xact_user_functions | +| 12288 | pg_stat_archiver | +| 12292 | pg_stat_bgwriter | +| 12296 | pg_stat_wal | +| 12300 | pg_stat_progress_analyze | +| 12305 | pg_stat_progress_vacuum | +| 12310 | pg_stat_progress_cluster | +| 12315 | pg_stat_progress_create_index | +| 12320 | pg_stat_progress_basebackup | +| 12325 | pg_stat_progress_copy | +| 12330 | pg_user_mappings | +| 12335 | pg_replication_origin_status | +| 12339 | pg_stat_subscription_stats | +| 13231 | information_schema.information_schema_catalog_name | +| 13240 | information_schema.applicable_roles | +| 13245 | information_schema.administrable_role_authorizations | +| 13245 | information_schema.applicable_roles | +| 13245 | information_schema.applicable_roles | +| 13245 | information_schema.applicable_roles | +| 13249 | information_schema.attributes | +| 13254 | information_schema.character_sets | +| 13259 | information_schema.check_constraint_routine_usage | +| 13264 | information_schema.check_constraints | +| 13269 | information_schema.collations | +| 13274 | information_schema.collation_character_set_applicability | +| 13279 | information_schema.column_column_usage | +| 13284 | information_schema.column_domain_usage | +| 13289 | information_schema.column_privileges | +| 13294 | information_schema.column_udt_usage | +| 13299 | information_schema.columns | +| 13304 | information_schema.constraint_column_usage | +| 13309 | information_schema.constraint_table_usage | +| 13314 | information_schema.domain_constraints | +| 13319 | information_schema.domain_udt_usage | +| 13324 | information_schema.domains | +| 13329 | information_schema.enabled_roles | +| 13333 | information_schema.key_column_usage | +| 13338 | information_schema.parameters | +| 13343 | information_schema.referential_constraints | +| 13348 | information_schema.role_column_grants | +| 13348 | information_schema.enabled_roles | +| 13348 | information_schema.column_privileges | +| 13348 | information_schema.column_privileges | +| 13348 | information_schema.column_privileges | +| 13348 | information_schema.column_privileges | +| 13348 | information_schema.column_privileges | +| 13348 | information_schema.column_privileges | +| 13348 | information_schema.column_privileges | +| 13348 | information_schema.column_privileges | +| 13352 | information_schema.routine_column_usage | +| 13357 | information_schema.routine_privileges | +| 13362 | information_schema.role_routine_grants | +| 13362 | information_schema.routine_privileges | +| 13362 | information_schema.routine_privileges | +| 13362 | information_schema.routine_privileges | +| 13362 | information_schema.routine_privileges | +| 13362 | information_schema.routine_privileges | +| 13362 | information_schema.routine_privileges | +| 13362 | information_schema.routine_privileges | +| 13362 | information_schema.routine_privileges | +| 13362 | information_schema.routine_privileges | +| 13362 | information_schema.routine_privileges | +| 13362 | information_schema.enabled_roles | +| 13366 | information_schema.routine_routine_usage | +| 13371 | information_schema.routine_sequence_usage | +| 13376 | information_schema.routine_table_usage | +| 13381 | information_schema.routines | +| 13386 | information_schema.schemata | +| 13390 | information_schema.sequences | +| 13415 | information_schema.table_constraints | +| 13420 | information_schema.table_privileges | +| 13425 | information_schema.role_table_grants | +| 13425 | information_schema.table_privileges | +| 13425 | information_schema.table_privileges | +| 13425 | information_schema.table_privileges | +| 13425 | information_schema.table_privileges | +| 13425 | information_schema.table_privileges | +| 13425 | information_schema.table_privileges | +| 13425 | information_schema.table_privileges | +| 13425 | information_schema.table_privileges | +| 13425 | information_schema.enabled_roles | +| 13429 | information_schema.tables | +| 13434 | information_schema.transforms | +| 13439 | information_schema.triggered_update_columns | +| 13444 | information_schema.triggers | +| 13449 | information_schema.udt_privileges | +| 13454 | information_schema.role_udt_grants | +| 13454 | information_schema.udt_privileges | +| 13454 | information_schema.udt_privileges | +| 13454 | information_schema.udt_privileges | +| 13454 | information_schema.udt_privileges | +| 13454 | information_schema.udt_privileges | +| 13454 | information_schema.udt_privileges | +| 13454 | information_schema.udt_privileges | +| 13454 | information_schema.enabled_roles | +| 13458 | information_schema.usage_privileges | +| 13463 | information_schema.role_usage_grants | +| 13463 | information_schema.usage_privileges | +| 13463 | information_schema.usage_privileges | +| 13463 | information_schema.usage_privileges | +| 13463 | information_schema.usage_privileges | +| 13463 | information_schema.usage_privileges | +| 13463 | information_schema.usage_privileges | +| 13463 | information_schema.usage_privileges | +| 13463 | information_schema.usage_privileges | +| 13463 | information_schema.enabled_roles | +| 13467 | information_schema.user_defined_types | +| 13472 | information_schema.view_column_usage | +| 13477 | information_schema.view_routine_usage | +| 13482 | information_schema.view_table_usage | +| 13487 | information_schema.views | +| 13492 | information_schema.data_type_privileges | +| 13492 | information_schema.routines | +| 13492 | information_schema.routines | +| 13492 | information_schema.routines | +| 13492 | information_schema.parameters | +| 13492 | information_schema.parameters | +| 13492 | information_schema.parameters | +| 13492 | information_schema.domains | +| 13492 | information_schema.domains | +| 13492 | information_schema.domains | +| 13492 | information_schema.columns | +| 13492 | information_schema.columns | +| 13492 | information_schema.columns | +| 13492 | information_schema.attributes | +| 13492 | information_schema.attributes | +| 13492 | information_schema.attributes | +| 13497 | information_schema.element_types | +| 13497 | information_schema.data_type_privileges | +| 13497 | information_schema.data_type_privileges | +| 13497 | information_schema.data_type_privileges | +| 13497 | information_schema.data_type_privileges | +| 13502 | information_schema._pg_foreign_table_columns | +| 13507 | information_schema.column_options | +| 13507 | information_schema._pg_foreign_table_columns | +| 13507 | information_schema._pg_foreign_table_columns | +| 13507 | information_schema._pg_foreign_table_columns | +| 13507 | information_schema._pg_foreign_table_columns | +| 13511 | information_schema._pg_foreign_data_wrappers | +| 13515 | information_schema.foreign_data_wrapper_options | +| 13515 | information_schema._pg_foreign_data_wrappers | +| 13515 | information_schema._pg_foreign_data_wrappers | +| 13515 | information_schema._pg_foreign_data_wrappers | +| 13519 | information_schema.foreign_data_wrappers | +| 13519 | information_schema._pg_foreign_data_wrappers | +| 13519 | information_schema._pg_foreign_data_wrappers | +| 13519 | information_schema._pg_foreign_data_wrappers | +| 13519 | information_schema._pg_foreign_data_wrappers | +| 13523 | information_schema._pg_foreign_servers | +| 13528 | information_schema.foreign_server_options | +| 13528 | information_schema._pg_foreign_servers | +| 13528 | information_schema._pg_foreign_servers | +| 13528 | information_schema._pg_foreign_servers | +| 13532 | information_schema.foreign_servers | +| 13532 | information_schema._pg_foreign_servers | +| 13532 | information_schema._pg_foreign_servers | +| 13532 | information_schema._pg_foreign_servers | +| 13532 | information_schema._pg_foreign_servers | +| 13532 | information_schema._pg_foreign_servers | +| 13532 | information_schema._pg_foreign_servers | +| 13532 | information_schema._pg_foreign_servers | +| 13536 | information_schema._pg_foreign_tables | +| 13541 | information_schema.foreign_table_options | +| 13541 | information_schema._pg_foreign_tables | +| 13541 | information_schema._pg_foreign_tables | +| 13541 | information_schema._pg_foreign_tables | +| 13541 | information_schema._pg_foreign_tables | +| 13545 | information_schema.foreign_tables | +| 13545 | information_schema._pg_foreign_tables | +| 13545 | information_schema._pg_foreign_tables | +| 13545 | information_schema._pg_foreign_tables | +| 13545 | information_schema._pg_foreign_tables | +| 13545 | information_schema._pg_foreign_tables | +| 13549 | information_schema._pg_user_mappings | +| 13549 | information_schema._pg_foreign_servers | +| 13549 | information_schema._pg_foreign_servers | +| 13549 | information_schema._pg_foreign_servers | +| 13549 | information_schema._pg_foreign_servers | +| 13554 | information_schema.user_mapping_options | +| 13554 | information_schema._pg_user_mappings | +| 13554 | information_schema._pg_user_mappings | +| 13554 | information_schema._pg_user_mappings | +| 13554 | information_schema._pg_user_mappings | +| 13554 | information_schema._pg_user_mappings | +| 13554 | information_schema._pg_user_mappings | +| 13559 | information_schema.user_mappings | +| 13559 | information_schema._pg_user_mappings | +| 13559 | information_schema._pg_user_mappings | +| 13559 | information_schema._pg_user_mappings | +| 16407 | pg_stat_statements_info | +| 16418 | pg_stat_statements | +| 16504 | auth.refresh_tokens_id_seq | +| 36106 | story_themes_pkey | +| 36106 | story_themes | +| 36111 | story_subjects_pkey | +| 36111 | story_subjects | +| 16566 | storage.buckets_pkey | +| 16566 | storage.buckets | +| 36116 | story_characters_pkey | +| 36116 | story_characters | +| 29103 | realtime.subscription | +| 36121 | story_settings_pkey | +| 36121 | story_settings | +| 65870 | auth.users_pkey | +| 65870 | auth.users | +| 65875 | interests | +| 65876 | interests | +| 65877 | interests | +| 65877 | interests | +| 65878 | interests | +| 53294 | stories_pkey | +| 53294 | stories | +| 53299 | stories_pkey | +| 16796 | pgsodium.key_key_id_seq | +| 16798 | pgsodium.key | +| 53299 | stories | +| 16857 | pgsodium.key_pkey | +| 16857 | pgsodium.key | +| 29233 | schools_pkey | +| 29233 | schools | +| 16893 | pgsodium.key | +| 16893 | pgsodium.key | +| 16893 | pgsodium.key | +| 16893 | pgsodium.key | +| 29248 | schools_pkey | +| 29248 | schools | +| 16918 | pgsodium.mask_columns | +| 16918 | pgsodium.masking_rule | +| 16918 | pgsodium.masking_rule | +| 16918 | pgsodium.masking_rule | +| 16918 | pgsodium.masking_rule | +| 16918 | pgsodium.masking_rule | +| 16918 | pgsodium.masking_rule | +| 16918 | pgsodium.masking_rule | +| 29265 | classes_pkey | +| 29265 | classes | +| 29279 | teachers_pkey | +| 29279 | teachers | +| 29284 | classes_pkey | +| 29284 | classes | +| 16897 | pgsodium.valid_key | +| 16897 | pgsodium.key | +| 16897 | pgsodium.key | +| 16897 | pgsodium.key | +| 16897 | pgsodium.key | +| 16897 | pgsodium.key | +| 16897 | pgsodium.key | +| 16897 | pgsodium.key | +| 16897 | pgsodium.key | +| 16897 | pgsodium.key | +| 16943 | pgsodium.decrypted_key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16943 | pgsodium.key | +| 16946 | pgsodium.key | +| 16913 | pgsodium.masking_rule | +| 16956 | pgsodium.valid_key | +| 16964 | pgsodium.key_pkey | +| 16964 | pgsodium.key | +| 16973 | vault.decrypted_secrets | +| 16973 | vault.secrets | +| 16973 | vault.secrets | +| 16973 | vault.secrets | +| 16973 | vault.secrets | +| 16973 | vault.secrets | +| 16973 | vault.secrets | +| 16973 | vault.secrets | +| 16973 | vault.secrets | +| 16975 | vault.secrets | +| 36166 | story_themes_pkey | +| 36166 | story_themes | +| 31511 | story_recordings | +| 36171 | story_subjects_pkey | +| 36171 | story_subjects | +| 36176 | story_characters_pkey | +| 36176 | story_characters | +| 36181 | story_settings_pkey | +| 36181 | story_settings | +| 29333 | stories | +| 29338 | students_pkey | +| 29338 | students | +| 29346 | stories | +| 29346 | students | +| 29346 | students | +| 29347 | stories | +| 29347 | students | +| 29347 | students | +| 31552 | auth.users_pkey | +| 31552 | auth.users | +| 31558 | story_recordings | +| 31558 | students | +| 31558 | students | +| 31558 | classes | +| 31558 | classes | +| 31560 | story_recordings | +| 31560 | students | +| 31560 | students | +| 53384 | stories | +| 36241 | story_settings | +| 36241 | story_settings | +| 36241 | story_characters | +| 36241 | story_characters | +| 36241 | story_subjects | +| 36241 | story_subjects | +| 36241 | story_themes | +| 36241 | story_themes | +| 36241 | stories | +| 36241 | stories | +| 36241 | stories | +| 36241 | stories | +| 36241 | stories | +| 75352 | storage.objects | +| 53426 | storage.objects | +| 53426 | storage.objects | +| 29441 | schools | +| 29442 | schools | +| 29442 | schools | +| 53468 | stories | +| 53468 | stories | +| 53468 | storage.objects | +| 53468 | storage.objects | +| 36331 | story_details | +| 36331 | story_settings | +| 36331 | story_settings | +| 36331 | story_settings | +| 36331 | story_settings | +| 36331 | story_characters | +| 36331 | story_characters | +| 36331 | story_characters | +| 36331 | story_characters | +| 36331 | story_subjects | +| 36331 | story_subjects | +| 36331 | story_subjects | +| 36331 | story_subjects | +| 36331 | story_themes | +| 36331 | story_themes | +| 36331 | story_themes | +| 36331 | story_themes | +| 36331 | stories | +| 36331 | stories | +| 36331 | stories | +| 36331 | stories | +| 36331 | stories | +| 36331 | stories | +| 36331 | stories | +| 36331 | stories | +| 36331 | stories | +| 36331 | stories | +| 36331 | stories | +| 36331 | stories | +| 29487 | teachers | +| 29494 | teacher_invites | +| 29501 | schools_pkey | +| 29501 | schools | +| 29509 | teachers | +| 29510 | teachers | +| 29510 | schools | +| 29511 | teacher_invites | +| 29511 | schools | +| 52098 | storage.objects | +| 52099 | storage.objects | +| 29555 | students | +| 29578 | schools_pkey | +| 29578 | schools | +| 29584 | students | +| 74984 | phonics_exercise_types_pkey | +| 74984 | phonics_exercise_types | +| 75008 | phonics_exercises_pkey | +| 75008 | phonics_exercises | +| 75013 | phonics_words_pkey | +| 75013 | phonics_words | +| 75036 | phonics_exercises_pkey | +| 75036 | phonics_exercises | +| 75041 | media_types_pkey | +| 75041 | media_types | +| 75062 | auth.users_pkey | +| 75062 | auth.users | +| 75067 | phonics_exercises_pkey | +| 75067 | phonics_exercises | +| 75079 | auth.users_pkey | +| 75079 | auth.users | +| 75084 | phonics_exercises_pkey | +| 75084 | phonics_exercises | +| 75098 | student_phonics_attempts_pkey | +| 75098 | student_phonics_attempts | +| 75103 | phonics_words_pkey | +| 75103 | phonics_words | +| 75128 | achievement_types_pkey | +| 75128 | achievement_types | +| 75142 | auth.users_pkey | +| 75142 | auth.users | +| 29614 | classes | +| 29615 | classes | +| 29616 | classes | +| 29616 | classes | +| 75147 | phonics_achievements_pkey | +| 75147 | phonics_achievements | +| 29638 | students | +| 29638 | schools | +| 29639 | students | +| 29639 | schools | +| 29709 | students_pkey | +| 29709 | students | +| 29716 | storage.objects | +| 29717 | storage.objects | +| 29748 | story_recordings | +| 29749 | story_recordings | +| 74045 | storage.objects | +| 34119 | net.http_request_queue_id_seq | +| 29823 | auth.users | +| 53921 | story_exercise_words | +| 53928 | stories_pkey | +| 53928 | stories | +| 29937 | students_pkey | +| 29937 | students | +| 29942 | achievements_pkey | +| 29942 | achievements | +| 29997 | students_pkey | +| 29997 | students | +| 30002 | achievements_pkey | +| 30002 | achievements | +| 34428 | story_recordings | +| 34429 | story_recordings | +| 34430 | story_recordings | +| 34431 | story_recordings | +| 30092 | story_recordings | +| 30136 | storage.objects | +| 30136 | storage.objects | +| 43939 | storage.objects | +| 43940 | storage.objects | +| 34950 | story_themes | +| 34951 | story_subjects | +| 34952 | story_characters | +| 34953 | story_settings | +| 37419 | stories_pkey | +| 37419 | stories | +| 37570 | storage.objects | +| 37571 | storage.objects | +| 37572 | storage.objects | +| 37573 | storage.objects | +| 28652 | auth.users | +| 28652 | auth.users | +| 28665 | auth.users | +| 28673 | auth.users_pkey | +| 28673 | auth.users | +| 28701 | auth.users_pkey | +| 28701 | auth.users | +| 28706 | auth.sessions_pkey | +| 28706 | auth.sessions | +| 28738 | auth.users_pkey | +| 28738 | auth.users | +| 28751 | auth.mfa_factors_pkey | +| 28751 | auth.mfa_factors | +| 28763 | auth.sessions_pkey | +| 28763 | auth.sessions | +| 28777 | auth.sso_providers | +| 28786 | auth.sso_domains | +| 28791 | auth.sso_providers_pkey | +| 28791 | auth.sso_providers | +| 28801 | auth.saml_providers | +| 28802 | auth.saml_providers | +| 28803 | auth.saml_providers | +| 28810 | auth.sso_providers_pkey | +| 28810 | auth.sso_providers | +| 28819 | auth.saml_relay_states | +| 28824 | auth.sso_providers_pkey | +| 28824 | auth.sso_providers | +| 28851 | auth.identities | +| 28883 | auth.flow_state_pkey | +| 28883 | auth.flow_state | +| 28924 | auth.one_time_tokens | +| 28929 | auth.users_pkey | +| 28929 | auth.users | +| 28948 | storage.objects | +| 28985 | storage.buckets_pkey | +| 28985 | storage.buckets | +| 29000 | storage.s3_multipart_uploads_pkey | +| 29000 | storage.s3_multipart_uploads | +| 29005 | storage.buckets_pkey | +| 29005 | storage.buckets | \ No newline at end of file diff --git a/supabase/contexts/full_schema.md b/supabase/contexts/full_schema.md new file mode 100644 index 0000000..097d25d --- /dev/null +++ b/supabase/contexts/full_schema.md @@ -0,0 +1,637 @@ +| table_schema | table_name | column_name | data_type | is_nullable | column_default | +| ------------------- | ------------------------------- | --------------------------- | --------------------------- | ----------- | -------------------------------------------------- | +| realtime | subscription | id | bigint | NO | | +| realtime | schema_migrations | inserted_at | timestamp without time zone | YES | | +| public | stories | student_id | uuid | NO | | +| storage | s3_multipart_uploads | upload_signature | text | NO | | +| pgsodium | decrypted_key | key_context | bytea | YES | | +| pgsodium | valid_key | associated_data | text | YES | | +| pgsodium | key | status | USER-DEFINED | YES | 'valid'::pgsodium.key_status | +| auth | audit_log_entries | id | uuid | NO | | +| public | achievement_types | name | character varying | NO | | +| public | student_phonics_attempt_answers | answer_text | text | YES | | +| public | phonics_categories | id | uuid | NO | uuid_generate_v4() | +| public | phonics_exercise_media | order_index | integer | YES | | +| public | phonics_exercise_words | word_id | uuid | YES | | +| storage | migrations | name | character varying | NO | | +| net | _http_response | id | bigint | YES | | +| auth | identities | provider | text | NO | | +| extensions | pg_stat_statements | mean_exec_time | double precision | YES | | +| auth | mfa_factors | secret | text | YES | | +| auth | users | last_sign_in_at | timestamp with time zone | YES | | +| storage | objects | owner_id | text | YES | | +| vault | decrypted_secrets | nonce | bytea | YES | | +| auth | users | phone_confirmed_at | timestamp with time zone | YES | | +| extensions | pg_stat_statements | local_blks_hit | bigint | YES | | +| pgsodium | valid_key | created | timestamp with time zone | YES | | +| public | interests | id | uuid | NO | gen_random_uuid() | +| pgsodium | decrypted_key | associated_data | text | YES | | +| public | phonics_exercises | difficulty_level | integer | NO | | +| realtime | messages | topic | text | NO | | +| supabase_migrations | schema_migrations | statements | ARRAY | YES | | +| public | schools | address | text | YES | | +| auth | sessions | refreshed_at | timestamp without time zone | YES | | +| public | students | nickname | character varying | YES | | +| extensions | pg_stat_statements | queryid | bigint | YES | | +| auth | users | role | character varying | YES | | +| public | story_details | setting_title | text | YES | | +| public | student_phonics_progress | last_score | double precision | YES | 0 | +| public | phonics_exercise_types | id | uuid | NO | uuid_generate_v4() | +| auth | mfa_amr_claims | id | uuid | NO | | +| public | stories | subject_id | uuid | YES | | +| public | stories | setting_id | uuid | YES | | +| pgsodium | key | raw_key | bytea | YES | | +| pgsodium | key | parent_key | uuid | YES | | +| public | teacher_invites | email | text | NO | | +| vault | decrypted_secrets | updated_at | timestamp with time zone | YES | | +| extensions | pg_stat_statements | jit_functions | bigint | YES | | +| realtime | subscription | created_at | timestamp without time zone | NO | timezone('utc'::text, now()) | +| storage | s3_multipart_uploads_parts | created_at | timestamp with time zone | NO | now() | +| realtime | messages | private | boolean | YES | false | +| auth | users | phone | text | YES | NULL::character varying | +| public | schools | updated_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| auth | saml_providers | attribute_mapping | jsonb | YES | | +| extensions | pg_stat_statements | shared_blks_written | bigint | YES | | +| public | phonics_achievements | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | students | school_id | uuid | NO | | +| public | interests | item | text | NO | | +| pgsodium | valid_key | status | USER-DEFINED | YES | | +| storage | s3_multipart_uploads | user_metadata | jsonb | YES | | +| public | story_themes | slug | text | NO | | +| vault | secrets | nonce | bytea | YES | pgsodium.crypto_aead_det_noncegen() | +| storage | objects | user_metadata | jsonb | YES | | +| storage | objects | version | text | YES | | +| public | teacher_invites | status | text | YES | 'pending'::text | +| public | story_subjects | active | boolean | YES | true | +| pgsodium | decrypted_key | comment | text | YES | | +| net | http_request_queue | method | text | NO | | +| extensions | pg_stat_statements | userid | oid | YES | | +| auth | users | instance_id | uuid | YES | | +| public | phonics_exercise_types | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | students | avatar_settings | jsonb | YES | | +| realtime | subscription | claims | jsonb | NO | | +| realtime | messages | inserted_at | timestamp without time zone | NO | now() | +| public | phonics_categories | level | integer | NO | | +| storage | objects | bucket_id | text | YES | | +| public | story_characters | slug | text | NO | | +| public | students | birth_date | date | YES | | +| auth | refresh_tokens | revoked | boolean | YES | | +| storage | s3_multipart_uploads | owner_id | text | YES | | +| public | teachers | updated_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| pgsodium | decrypted_key | created | timestamp with time zone | YES | | +| public | achievements | name | text | YES | | +| storage | s3_multipart_uploads_parts | upload_id | text | NO | | +| auth | flow_state | provider_refresh_token | text | YES | | +| public | student_phonics_achievements | achievement_id | uuid | YES | | +| vault | decrypted_secrets | description | text | YES | | +| public | classes | period | text | YES | | +| pgsodium | key | raw_key_nonce | bytea | YES | | +| public | phonics_words | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | teacher_invites | expires_at | timestamp with time zone | NO | | +| auth | identities | provider_id | text | NO | | +| net | _http_response | headers | jsonb | YES | | +| auth | mfa_challenges | otp_code | text | YES | | +| public | stories | character_id | uuid | YES | | +| public | story_settings | updated_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| auth | flow_state | provider_type | text | NO | | +| public | teacher_invites | name | text | NO | | +| public | classes | updated_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| public | story_exercise_words | phonemes | ARRAY | YES | | +| public | story_settings | active | boolean | YES | true | +| public | story_generations | model_used | text | NO | | +| extensions | pg_stat_statements | toplevel | boolean | YES | | +| auth | users | aud | character varying | YES | | +| realtime | messages | extension | text | NO | | +| public | schools | phone | text | YES | | +| extensions | pg_stat_statements_info | dealloc | bigint | YES | | +| public | teachers | subject | text | YES | | +| pgsodium | masking_rule | priority | integer | YES | | +| extensions | pg_stat_statements | jit_emission_time | double precision | YES | | +| pgsodium | valid_key | id | uuid | YES | | +| vault | secrets | updated_at | timestamp with time zone | NO | CURRENT_TIMESTAMP | +| public | story_details | subject_title | text | YES | | +| auth | users | is_anonymous | boolean | NO | false | +| public | story_subjects | updated_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| public | students | accessibility_settings | jsonb | YES | | +| extensions | pg_stat_statements | wal_bytes | numeric | YES | | +| public | story_recordings | analysis | jsonb | YES | | +| public | student_phonics_achievements | id | uuid | NO | uuid_generate_v4() | +| vault | decrypted_secrets | id | uuid | YES | | +| auth | identities | identity_data | jsonb | NO | | +| net | _http_response | error_msg | text | YES | | +| auth | instances | uuid | uuid | YES | | +| auth | saml_providers | updated_at | timestamp with time zone | YES | | +| public | phonics_categories | updated_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | phonics_exercise_words | is_correct_answer | boolean | YES | false | +| realtime | subscription | entity | regclass | NO | | +| public | student_achievements | student_id | uuid | YES | | +| auth | users | email_change | character varying | YES | | +| pgsodium | masking_rule | attname | name | YES | | +| storage | s3_multipart_uploads | bucket_id | text | NO | | +| extensions | pg_stat_statements | min_exec_time | double precision | YES | | +| public | story_pages | image_path_thumb | text | YES | | +| public | phonics_achievements | icon_url | text | YES | | +| pgsodium | decrypted_key | id | uuid | YES | | +| auth | identities | updated_at | timestamp with time zone | YES | | +| storage | buckets | owner_id | text | YES | | +| public | story_pages | story_id | uuid | YES | | +| extensions | pg_stat_statements | max_plan_time | double precision | YES | | +| net | _http_response | content_type | text | YES | | +| auth | users | confirmation_token | character varying | YES | | +| public | student_phonics_progress | completed_at | timestamp with time zone | YES | | +| public | student_phonics_achievements | earned_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| auth | saml_relay_states | sso_provider_id | uuid | NO | | +| public | students | uppercase_text_preferences | boolean | YES | false | +| vault | decrypted_secrets | secret | text | YES | | +| pgsodium | decrypted_key | expires | timestamp with time zone | YES | | +| storage | s3_multipart_uploads | id | text | NO | | +| auth | one_time_tokens | relates_to | text | NO | | +| public | phonics_categories | description | text | YES | | +| auth | sessions | aal | USER-DEFINED | YES | | +| public | story_details | theme_title | text | YES | | +| pgsodium | mask_columns | nonce_column | text | YES | | +| public | phonics_word_audio | created_at | timestamp with time zone | YES | timezone('utc'::text, now()) | +| public | phonics_exercise_words | id | uuid | NO | uuid_generate_v4() | +| public | phonics_exercises | instructions | text | NO | | +| auth | identities | id | uuid | NO | gen_random_uuid() | +| public | phonics_exercise_types | description | text | YES | | +| auth | mfa_factors | created_at | timestamp with time zone | NO | | +| extensions | pg_stat_statements | total_plan_time | double precision | YES | | +| auth | users | email_confirmed_at | timestamp with time zone | YES | | +| public | student_achievements_old | student_id | uuid | YES | | +| public | teacher_invites | id | uuid | NO | uuid_generate_v4() | +| public | story_pages | image_path_medium | text | YES | | +| public | story_pages | image_url_large | text | YES | | +| pgsodium | valid_key | key_type | USER-DEFINED | YES | | +| storage | buckets | name | text | NO | | +| public | interests | category | text | NO | | +| public | story_details | status | text | YES | | +| public | schools | id | uuid | NO | uuid_generate_v4() | +| public | student_phonics_attempts | time_spent_seconds | integer | YES | | +| pgsodium | masking_rule | associated_columns | text | YES | | +| auth | sessions | updated_at | timestamp with time zone | YES | | +| pgsodium | masking_rule | view_name | text | YES | | +| public | phonics_exercise_media | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | story_generations | story_id | uuid | YES | | +| public | media_types | name | character varying | NO | | +| public | phonics_exercises | points | integer | YES | 10 | +| pgsodium | mask_columns | key_id_column | text | YES | | +| public | phonics_achievements | id | uuid | NO | uuid_generate_v4() | +| pgsodium | decrypted_key | key_id | bigint | YES | | +| public | story_recordings | error_count | integer | YES | | +| public | story_exercise_words | story_id | uuid | YES | | +| public | story_details | setting_id | uuid | YES | | +| public | classes | name | text | NO | | +| vault | decrypted_secrets | key_id | uuid | YES | | +| public | story_recordings | id | uuid | NO | uuid_generate_v4() | +| auth | users | invited_at | timestamp with time zone | YES | | +| auth | mfa_challenges | created_at | timestamp with time zone | NO | | +| public | student_phonics_progress | stars | integer | YES | 0 | +| extensions | pg_stat_statements | min_plan_time | double precision | YES | | +| auth | saml_providers | entity_id | text | NO | | +| public | story_details | character_title | text | YES | | +| public | phonics_exercises | estimated_time_seconds | integer | YES | | +| auth | instances | updated_at | timestamp with time zone | YES | | +| pgsodium | valid_key | key_context | bytea | YES | | +| public | teachers | id | uuid | NO | uuid_generate_v4() | +| public | students | notification_preferences | jsonb | YES | | +| pgsodium | masking_rule | attnum | integer | YES | | +| public | story_subjects | title | text | NO | | +| extensions | pg_stat_statements | blk_write_time | double precision | YES | | +| vault | secrets | description | text | NO | ''::text | +| auth | users | banned_until | timestamp with time zone | YES | | +| auth | flow_state | id | uuid | NO | | +| auth | mfa_factors | factor_type | USER-DEFINED | NO | | +| auth | identities | email | text | YES | | +| auth | users | email_change_token_current | character varying | YES | ''::character varying | +| public | student_phonics_progress | completed | boolean | YES | false | +| public | student_achievements | metadata | jsonb | YES | | +| extensions | pg_stat_statements | temp_blks_written | bigint | YES | | +| public | story_settings | id | uuid | NO | uuid_generate_v4() | +| public | story_details | character_id | uuid | YES | | +| public | teachers | email | text | NO | | +| auth | saml_relay_states | redirect_to | text | YES | | +| public | story_details | context | text | YES | | +| public | story_pages | image_url | text | NO | | +| public | schools | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| auth | saml_providers | created_at | timestamp with time zone | YES | | +| realtime | messages | event | text | YES | | +| public | story_details | character_icon | text | YES | | +| public | phonics_exercises | type_id | uuid | YES | | +| pgsodium | masking_rule | nonce_column | text | YES | | +| public | story_settings | description | text | NO | | +| auth | one_time_tokens | user_id | uuid | NO | | +| public | student_phonics_progress | exercise_id | uuid | YES | | +| auth | mfa_factors | id | uuid | NO | | +| public | students | language | USER-DEFINED | YES | 'pt-BR'::language_enum | +| public | phonics_word_audio | word | text | NO | | +| net | _http_response | created | timestamp with time zone | NO | now() | +| public | teacher_invites | message | text | YES | | +| public | classes | teacher_id | uuid | YES | | +| public | story_subjects | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| vault | secrets | created_at | timestamp with time zone | NO | CURRENT_TIMESTAMP | +| auth | flow_state | code_challenge_method | USER-DEFINED | NO | | +| public | story_recordings | fluency_score | integer | YES | | +| auth | sso_domains | domain | text | NO | | +| auth | sso_providers | resource_id | text | YES | | +| storage | s3_multipart_uploads | version | text | NO | | +| public | student_phonics_progress | correct_answers_count | integer | YES | 0 | +| public | phonics_achievements | description | text | YES | | +| public | student_achievements_old | metadata | jsonb | YES | | +| auth | saml_providers | name_id_format | text | YES | | +| public | phonics_exercise_words | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | story_pages | image_path_large | text | YES | | +| pgsodium | mask_columns | attname | name | YES | | +| public | phonics_exercise_media | media_type_id | uuid | YES | | +| auth | sessions | id | uuid | NO | | +| public | story_recordings | self_corrections | integer | YES | | +| public | story_details | student_id | uuid | YES | | +| auth | mfa_challenges | web_authn_session_data | jsonb | YES | | +| public | student_phonics_attempts | student_id | uuid | YES | | +| public | classes | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| storage | buckets | updated_at | timestamp with time zone | YES | now() | +| public | story_recordings | audio_url | text | YES | | +| auth | audit_log_entries | ip_address | character varying | NO | ''::character varying | +| public | student_phonics_attempt_answers | attempt_id | uuid | YES | | +| pgsodium | key | key_type | USER-DEFINED | YES | | +| auth | mfa_factors | friendly_name | text | YES | | +| public | student_phonics_progress | id | uuid | NO | uuid_generate_v4() | +| public | story_settings | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| public | story_subjects | description | text | NO | | +| public | stories | content | jsonb | NO | | +| auth | flow_state | provider_access_token | text | YES | | +| vault | secrets | secret | text | NO | | +| public | interests | updated_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| public | teachers | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| storage | s3_multipart_uploads | created_at | timestamp with time zone | NO | now() | +| supabase_migrations | seed_files | hash | text | NO | | +| realtime | subscription | claims_role | regrole | NO | | +| auth | saml_providers | metadata_xml | text | NO | | +| public | phonics_exercises | id | uuid | NO | uuid_generate_v4() | +| auth | mfa_challenges | verified_at | timestamp with time zone | YES | | +| pgsodium | key | comment | text | YES | | +| net | _http_response | timed_out | boolean | YES | | +| public | story_recordings | created_at | timestamp with time zone | NO | now() | +| public | classes | grade | text | NO | | +| public | teacher_invites | token | text | NO | | +| public | stories | context | text | YES | | +| auth | flow_state | created_at | timestamp with time zone | YES | | +| auth | sso_domains | id | uuid | NO | | +| public | phonics_achievements | required_count | integer | YES | 1 | +| public | students | dark_mode | boolean | YES | false | +| public | teachers | status | text | YES | 'pending'::text | +| pgsodium | mask_columns | key_id | text | YES | | +| public | phonics_exercise_media | id | uuid | NO | uuid_generate_v4() | +| public | story_details | setting_icon | text | YES | | +| public | schools | director_name | text | NO | 'Não informado'::text | +| auth | sessions | created_at | timestamp with time zone | YES | | +| public | phonics_categories | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| auth | mfa_amr_claims | created_at | timestamp with time zone | NO | | +| realtime | messages | updated_at | timestamp without time zone | NO | now() | +| public | classes | id | uuid | NO | uuid_generate_v4() | +| public | story_recordings | student_id | uuid | YES | | +| public | student_phonics_progress | last_attempt_at | timestamp with time zone | YES | | +| auth | mfa_factors | phone | text | YES | | +| auth | mfa_challenges | id | uuid | NO | | +| auth | identities | created_at | timestamp with time zone | YES | | +| public | students | updated_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| public | students | status | text | NO | 'active'::text | +| public | teacher_classes | teacher_id | uuid | NO | | +| extensions | pg_stat_statements | jit_emission_count | bigint | YES | | +| pgsodium | mask_columns | format_type | text | YES | | +| auth | sessions | not_after | timestamp with time zone | YES | | +| public | phonics_exercise_media | url | text | NO | | +| net | http_request_queue | body | bytea | YES | | +| public | story_themes | icon | text | NO | | +| public | phonics_achievements | name | character varying | NO | | +| auth | sso_domains | created_at | timestamp with time zone | YES | | +| public | students | preferred_themes | ARRAY | YES | | +| pgsodium | valid_key | expires | timestamp with time zone | YES | | +| public | story_subjects | id | uuid | NO | uuid_generate_v4() | +| public | students | class_id | uuid | NO | | +| vault | secrets | id | uuid | NO | gen_random_uuid() | +| extensions | pg_stat_statements | jit_optimization_time | double precision | YES | | +| vault | decrypted_secrets | created_at | timestamp with time zone | YES | | +| auth | refresh_tokens | id | bigint | NO | nextval('auth.refresh_tokens_id_seq'::regclass) | +| auth | flow_state | auth_code | text | NO | | +| auth | users | encrypted_password | character varying | YES | | +| public | student_phonics_progress | attempts | integer | YES | 0 | +| extensions | pg_stat_statements | plans | bigint | YES | | +| auth | mfa_factors | updated_at | timestamp with time zone | NO | | +| public | story_characters | icon | text | NO | | +| storage | objects | created_at | timestamp with time zone | YES | now() | +| auth | users | email_change_confirm_status | smallint | YES | 0 | +| public | story_settings | title | text | NO | | +| extensions | pg_stat_statements | blk_read_time | double precision | YES | | +| public | phonics_exercises | title | character varying | NO | | +| auth | saml_providers | id | uuid | NO | | +| auth | sessions | user_agent | text | YES | | +| public | story_recordings | processed_at | timestamp with time zone | YES | | +| storage | s3_multipart_uploads_parts | bucket_id | text | NO | | +| pgsodium | decrypted_key | name | text | YES | | +| public | phonics_words | word | character varying | NO | | +| public | teachers | name | text | NO | | +| auth | sso_providers | created_at | timestamp with time zone | YES | | +| storage | buckets | file_size_limit | bigint | YES | | +| auth | sso_domains | sso_provider_id | uuid | NO | | +| public | stories | status | text | YES | 'draft'::text | +| public | story_exercise_words | created_at | timestamp with time zone | YES | now() | +| public | student_phonics_progress | xp_earned | integer | YES | 0 | +| public | student_phonics_progress | updated_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | phonics_exercise_media | exercise_id | uuid | YES | | +| pgsodium | key | key_id | bigint | YES | nextval('pgsodium.key_key_id_seq'::regclass) | +| auth | mfa_amr_claims | session_id | uuid | NO | | +| public | teacher_classes | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| public | story_details | title | text | YES | | +| public | student_phonics_attempts | exercise_id | uuid | YES | | +| public | story_recordings | improvements | ARRAY | YES | | +| pgsodium | masking_rule | key_id | text | YES | | +| public | students | preferred_font_size | integer | YES | 16 | +| public | story_recordings | suggestions | text | YES | | +| public | interests | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| public | phonics_exercises | is_active | boolean | YES | true | +| public | phonics_exercises | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | phonics_words | syllables_count | integer | NO | | +| public | story_details | theme_icon | text | YES | | +| supabase_migrations | seed_files | path | text | NO | | +| extensions | pg_stat_statements | jit_optimization_count | bigint | YES | | +| public | phonics_exercises | category_id | uuid | YES | | +| net | _http_response | content | text | YES | | +| public | students | last_active_at | timestamp with time zone | YES | | +| public | story_pages | image_url_thumb | text | YES | | +| public | student_phonics_attempt_answers | id | uuid | NO | uuid_generate_v4() | +| public | phonics_categories | order_index | integer | NO | | +| auth | one_time_tokens | token_type | USER-DEFINED | NO | | +| public | student_phonics_progress | student_id | uuid | YES | | +| public | phonics_word_audio | audio_url | text | NO | | +| pgsodium | masking_rule | col_description | text | YES | | +| auth | refresh_tokens | user_id | character varying | YES | | +| auth | saml_relay_states | updated_at | timestamp with time zone | YES | | +| extensions | pg_stat_statements | max_exec_time | double precision | YES | | +| public | students | email | text | NO | | +| auth | users | email_change_sent_at | timestamp with time zone | YES | | +| auth | saml_providers | sso_provider_id | uuid | NO | | +| auth | identities | last_sign_in_at | timestamp with time zone | YES | | +| auth | users | email_change_token_new | character varying | YES | | +| extensions | pg_stat_statements | total_exec_time | double precision | YES | | +| public | student_phonics_progress | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | students | reading_goals | jsonb | YES | | +| public | phonics_words | id | uuid | NO | uuid_generate_v4() | +| public | story_subjects | slug | text | NO | | +| public | students | id | uuid | NO | uuid_generate_v4() | +| pgsodium | masking_rule | relnamespace | regnamespace | YES | | +| vault | secrets | name | text | YES | | +| public | phonics_exercises | required_score | double precision | YES | 0.7 | +| public | story_themes | active | boolean | YES | true | +| auth | refresh_tokens | instance_id | uuid | YES | | +| public | story_details | subject_id | uuid | YES | | +| net | http_request_queue | timeout_milliseconds | integer | NO | | +| auth | one_time_tokens | updated_at | timestamp without time zone | NO | now() | +| public | student_phonics_attempt_answers | is_correct | boolean | NO | | +| storage | objects | updated_at | timestamp with time zone | YES | now() | +| public | story_characters | active | boolean | YES | true | +| public | story_generations | original_prompt | text | NO | | +| public | teacher_classes | id | uuid | NO | uuid_generate_v4() | +| auth | mfa_amr_claims | authentication_method | text | NO | | +| public | media_types | description | text | YES | | +| auth | users | email | character varying | YES | | +| extensions | pg_stat_statements | query | text | YES | | +| pgsodium | masking_rule | security_invoker | boolean | YES | | +| public | story_exercise_words | word | text | NO | | +| extensions | pg_stat_statements | shared_blks_dirtied | bigint | YES | | +| auth | users | updated_at | timestamp with time zone | YES | | +| public | story_recordings | words_per_minute | integer | YES | | +| public | classes | school_id | uuid | NO | | +| storage | s3_multipart_uploads_parts | key | text | NO | | +| public | story_details | updated_at | timestamp with time zone | YES | | +| auth | mfa_challenges | factor_id | uuid | NO | | +| pgsodium | masking_rule | attrelid | oid | YES | | +| public | students | name | text | NO | | +| storage | s3_multipart_uploads_parts | owner_id | text | YES | | +| pgsodium | decrypted_key | key_type | USER-DEFINED | YES | | +| auth | flow_state | user_id | uuid | YES | | +| auth | refresh_tokens | token | character varying | YES | | +| public | story_details | subject_icon | text | YES | | +| auth | schema_migrations | version | character varying | NO | | +| public | phonics_word_audio | audio_path | text | NO | | +| auth | one_time_tokens | token_hash | text | NO | | +| public | story_settings | slug | text | NO | | +| public | story_recordings | transcription | text | YES | | +| storage | objects | metadata | jsonb | YES | | +| public | story_characters | updated_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| auth | mfa_factors | web_authn_credential | jsonb | YES | | +| public | phonics_words | phonetic_transcription | character varying | YES | | +| public | teachers | school_id | uuid | NO | | +| vault | decrypted_secrets | decrypted_secret | text | YES | | +| public | story_recordings | accuracy_score | integer | YES | | +| public | story_themes | updated_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| public | story_recordings | story_id | uuid | YES | | +| auth | sessions | tag | text | YES | | +| pgsodium | decrypted_key | parent_key | uuid | YES | | +| pgsodium | valid_key | key_id | bigint | YES | | +| extensions | pg_stat_statements | jit_generation_time | double precision | YES | | +| public | student_phonics_attempts | score | double precision | NO | | +| auth | users | is_super_admin | boolean | YES | | +| public | story_details | content | jsonb | YES | | +| public | teachers | class_ids | ARRAY | YES | | +| extensions | pg_stat_statements | shared_blks_hit | bigint | YES | | +| public | story_generations | id | uuid | NO | uuid_generate_v4() | +| public | teacher_classes | class_id | uuid | NO | | +| auth | flow_state | auth_code_issued_at | timestamp with time zone | YES | | +| public | media_types | id | uuid | NO | uuid_generate_v4() | +| public | students | avatar_url | text | YES | | +| auth | flow_state | updated_at | timestamp with time zone | YES | | +| public | phonics_achievements | type_id | uuid | YES | | +| auth | sso_providers | updated_at | timestamp with time zone | YES | | +| public | story_exercise_words | id | uuid | NO | uuid_generate_v4() | +| public | story_details | id | uuid | YES | | +| public | schools | email | text | YES | | +| public | story_pages | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| extensions | pg_stat_statements | local_blks_read | bigint | YES | | +| public | student_phonics_attempts | id | uuid | NO | uuid_generate_v4() | +| auth | users | phone_change | text | YES | ''::character varying | +| realtime | messages | payload | jsonb | YES | | +| public | students | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| auth | refresh_tokens | session_id | uuid | YES | | +| public | story_exercise_words | exercise_type | text | NO | | +| auth | sso_providers | id | uuid | NO | | +| auth | mfa_factors | last_challenged_at | timestamp with time zone | YES | | +| public | teacher_invites | subject | text | YES | | +| auth | mfa_factors | web_authn_aaguid | uuid | YES | | +| public | media_types | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| extensions | pg_stat_statements | temp_blk_write_time | double precision | YES | | +| pgsodium | mask_columns | attrelid | oid | YES | | +| auth | users | reauthentication_sent_at | timestamp with time zone | YES | | +| auth | sessions | user_id | uuid | NO | | +| public | story_generations | ai_response | text | NO | | +| auth | mfa_amr_claims | updated_at | timestamp with time zone | NO | | +| realtime | subscription | filters | ARRAY | NO | '{}'::realtime.user_defined_filter[] | +| public | student_phonics_attempt_answers | word_id | uuid | YES | | +| auth | one_time_tokens | id | uuid | NO | | +| public | phonics_exercise_words | order_index | integer | YES | | +| auth | mfa_factors | user_id | uuid | NO | | +| public | phonics_word_audio | id | uuid | NO | uuid_generate_v4() | +| public | students | guardian_phone | text | YES | | +| pgsodium | masking_rule | relname | name | YES | | +| storage | s3_multipart_uploads | key | text | NO | | +| auth | sessions | ip | inet | YES | | +| auth | refresh_tokens | updated_at | timestamp with time zone | YES | | +| public | story_recordings | pronunciation_score | integer | YES | | +| extensions | pg_stat_statements | jit_inlining_count | bigint | YES | | +| storage | buckets | public | boolean | YES | false | +| public | stories | updated_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| auth | flow_state | authentication_method | text | NO | | +| pgsodium | key | name | text | YES | | +| pgsodium | key | key_context | bytea | YES | '\x7067736f6469756d'::bytea | +| public | story_settings | icon | text | NO | | +| public | story_generations | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| storage | objects | name | text | YES | | +| public | story_characters | title | text | NO | | +| public | student_achievements | id | uuid | NO | uuid_generate_v4() | +| public | story_exercise_words | syllable_pattern | text | YES | | +| auth | flow_state | code_challenge | text | NO | | +| public | stories | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| pgsodium | decrypted_key | status | USER-DEFINED | YES | | +| public | achievements | description | text | YES | | +| public | students | guardian_email | text | YES | | +| storage | s3_multipart_uploads_parts | size | bigint | NO | 0 | +| auth | refresh_tokens | parent | character varying | YES | | +| auth | saml_relay_states | for_email | text | YES | | +| public | student_phonics_achievements | student_id | uuid | YES | | +| public | teachers | phone | text | YES | | +| vault | decrypted_secrets | name | text | YES | | +| auth | instances | id | uuid | NO | | +| public | story_pages | text | text | NO | | +| pgsodium | key | associated_data | text | YES | 'associated'::text | +| extensions | pg_stat_statements | shared_blks_read | bigint | YES | | +| public | story_recordings | pause_count | integer | YES | | +| auth | users | created_at | timestamp with time zone | YES | | +| extensions | pg_stat_statements_info | stats_reset | timestamp with time zone | YES | | +| public | story_recordings | status | text | NO | 'pending_analysis'::text | +| public | stories | theme_id | uuid | YES | | +| storage | buckets | created_at | timestamp with time zone | YES | now() | +| pgsodium | valid_key | name | text | YES | | +| public | student_achievements_old | earned_at | timestamp with time zone | YES | now() | +| public | phonics_achievements | points | integer | YES | 0 | +| public | story_themes | title | text | NO | | +| pgsodium | masking_rule | format_type | text | YES | | +| net | http_request_queue | url | text | NO | | +| pgsodium | decrypted_key | raw_key_nonce | bytea | YES | | +| pgsodium | decrypted_key | raw_key | bytea | YES | | +| storage | buckets | id | text | NO | | +| supabase_migrations | schema_migrations | name | text | YES | | +| storage | objects | path_tokens | ARRAY | YES | | +| public | schools | name | text | NO | | +| pgsodium | mask_columns | associated_columns | text | YES | | +| auth | users | phone_change_sent_at | timestamp with time zone | YES | | +| extensions | pg_stat_statements | local_blks_written | bigint | YES | | +| auth | one_time_tokens | created_at | timestamp without time zone | NO | now() | +| auth | sessions | factor_id | uuid | YES | | +| extensions | pg_stat_statements | local_blks_dirtied | bigint | YES | | +| auth | users | phone_change_token | character varying | YES | ''::character varying | +| storage | s3_multipart_uploads_parts | version | text | NO | | +| public | story_themes | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| public | student_achievements_old | id | uuid | NO | uuid_generate_v4() | +| pgsodium | key | user_data | text | YES | | +| public | teacher_invites | school_id | uuid | NO | | +| public | stories | title | text | NO | | +| storage | s3_multipart_uploads | in_progress_size | bigint | NO | 0 | +| pgsodium | key | created | timestamp with time zone | NO | CURRENT_TIMESTAMP | +| public | achievement_types | description | text | YES | | +| realtime | subscription | subscription_id | uuid | NO | | +| public | student_achievements | earned_at | timestamp with time zone | YES | now() | +| auth | audit_log_entries | payload | json | YES | | +| storage | objects | last_accessed_at | timestamp with time zone | YES | now() | +| public | phonics_exercise_words | exercise_id | uuid | YES | | +| public | teacher_invites | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| public | story_characters | created_at | timestamp with time zone | NO | timezone('utc'::text, now()) | +| auth | mfa_factors | status | USER-DEFINED | NO | | +| pgsodium | decrypted_key | decrypted_raw_key | bytea | YES | | +| auth | instances | created_at | timestamp with time zone | YES | | +| storage | migrations | hash | character varying | NO | | +| public | story_recordings | error_message | text | YES | | +| public | story_pages | id | uuid | NO | uuid_generate_v4() | +| public | student_phonics_attempts | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | story_details | created_at | timestamp with time zone | YES | | +| extensions | pg_stat_statements | temp_blks_read | bigint | YES | | +| auth | saml_relay_states | id | uuid | NO | | +| storage | s3_multipart_uploads_parts | etag | text | NO | | +| auth | users | confirmed_at | timestamp with time zone | YES | | +| realtime | messages | id | uuid | NO | gen_random_uuid() | +| public | phonics_exercise_media | alt_text | text | YES | | +| net | http_request_queue | headers | jsonb | NO | | +| public | phonics_exercise_types | name | character varying | NO | | +| public | story_details | theme_id | uuid | YES | | +| public | student_phonics_attempt_answers | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | phonics_exercises | updated_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| public | story_recordings | strengths | ARRAY | YES | | +| auth | sso_domains | updated_at | timestamp with time zone | YES | | +| public | student_achievements_old | achievement_id | uuid | YES | | +| public | story_themes | description | text | NO | | +| auth | users | recovery_token | character varying | YES | | +| storage | buckets | owner | uuid | YES | | +| extensions | pg_stat_statements | stddev_plan_time | double precision | YES | | +| extensions | pg_stat_statements | jit_inlining_time | double precision | YES | | +| public | interests | student_id | uuid | NO | | +| supabase_migrations | schema_migrations | version | text | NO | | +| public | student_phonics_progress | total_time_spent_seconds | integer | YES | 0 | +| storage | migrations | id | integer | NO | | +| auth | users | reauthentication_token | character varying | YES | ''::character varying | +| public | story_pages | page_number | integer | NO | | +| extensions | pg_stat_statements | temp_blk_read_time | double precision | YES | | +| net | _http_response | status_code | integer | YES | | +| public | phonics_exercises | description | text | YES | | +| auth | saml_relay_states | request_id | text | NO | | +| storage | s3_multipart_uploads_parts | part_number | integer | NO | | +| realtime | schema_migrations | version | bigint | NO | | +| public | stories | id | uuid | NO | uuid_generate_v4() | +| extensions | pg_stat_statements | wal_records | bigint | YES | | +| auth | users | is_sso_user | boolean | NO | false | +| pgsodium | key | id | uuid | NO | gen_random_uuid() | +| public | story_characters | description | text | NO | | +| storage | objects | owner | uuid | YES | | +| auth | audit_log_entries | instance_id | uuid | YES | | +| public | phonics_categories | name | character varying | NO | | +| public | achievement_types | id | uuid | NO | uuid_generate_v4() | +| auth | users | raw_app_meta_data | jsonb | YES | | +| extensions | pg_stat_statements | stddev_exec_time | double precision | YES | | +| public | student_phonics_progress | best_score | double precision | YES | 0 | +| auth | saml_relay_states | created_at | timestamp with time zone | YES | | +| public | achievements | id | uuid | NO | uuid_generate_v4() | +| pgsodium | masking_rule | key_id_column | text | YES | | +| storage | s3_multipart_uploads_parts | id | uuid | NO | gen_random_uuid() | +| auth | identities | user_id | uuid | NO | | +| public | story_pages | image_path | text | YES | | +| auth | saml_providers | metadata_url | text | YES | | +| auth | instances | raw_base_config | text | YES | | +| storage | migrations | executed_at | timestamp without time zone | YES | CURRENT_TIMESTAMP | +| extensions | pg_stat_statements | rows | bigint | YES | | +| auth | users | raw_user_meta_data | jsonb | YES | | +| pgsodium | key | expires | timestamp with time zone | YES | | +| public | student_achievements | achievement_id | uuid | YES | | +| public | achievement_types | created_at | timestamp with time zone | YES | CURRENT_TIMESTAMP | +| storage | objects | id | uuid | NO | gen_random_uuid() | +| auth | audit_log_entries | created_at | timestamp with time zone | YES | | +| public | story_characters | id | uuid | NO | uuid_generate_v4() | +| vault | secrets | key_id | uuid | YES | (pgsodium.create_key()).id | +| auth | users | deleted_at | timestamp with time zone | YES | | +| public | story_subjects | icon | text | NO | | +| storage | buckets | allowed_mime_types | ARRAY | YES | | +| extensions | pg_stat_statements | wal_fpi | bigint | YES | | +| auth | users | recovery_sent_at | timestamp with time zone | YES | | +| extensions | pg_stat_statements | mean_plan_time | double precision | YES | | +| extensions | pg_stat_statements | calls | bigint | YES | | +| auth | users | confirmation_sent_at | timestamp with time zone | YES | | +| auth | refresh_tokens | created_at | timestamp with time zone | YES | | +| public | story_recordings | comprehension_score | integer | YES | | +| auth | saml_relay_states | flow_state_id | uuid | YES | | +| public | story_themes | id | uuid | NO | uuid_generate_v4() | +| public | student_phonics_progress | total_answers_count | integer | YES | 0 | +| public | students | guardian_name | text | YES | | +| public | story_pages | image_url_medium | text | YES | | +| net | http_request_queue | id | bigint | NO | nextval('net.http_request_queue_id_seq'::regclass) | +| extensions | pg_stat_statements | dbid | oid | YES | | +| auth | users | id | uuid | NO | | +| auth | mfa_challenges | ip_address | inet | NO | | +| storage | buckets | avif_autodetection | boolean | YES | false | +| public | classes | year | integer | NO | | \ No newline at end of file diff --git a/supabase/contexts/functions.md b/supabase/contexts/functions.md new file mode 100644 index 0000000..9a3eaf6 --- /dev/null +++ b/supabase/contexts/functions.md @@ -0,0 +1,1084 @@ +| schema | function_name | definition | +| -------------- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| auth | email | CREATE OR REPLACE FUNCTION auth.email() + RETURNS text + LANGUAGE sql + STABLE +AS $function$ + select + coalesce( + nullif(current_setting('request.jwt.claim.email', true), ''), + (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'email') + )::text +$function$ + | +| auth | jwt | CREATE OR REPLACE FUNCTION auth.jwt() + RETURNS jsonb + LANGUAGE sql + STABLE +AS $function$ + select + coalesce( + nullif(current_setting('request.jwt.claim', true), ''), + nullif(current_setting('request.jwt.claims', true), '') + )::jsonb +$function$ + | +| auth | role | CREATE OR REPLACE FUNCTION auth.role() + RETURNS text + LANGUAGE sql + STABLE +AS $function$ + select + coalesce( + nullif(current_setting('request.jwt.claim.role', true), ''), + (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'role') + )::text +$function$ + | +| auth | uid | CREATE OR REPLACE FUNCTION auth.uid() + RETURNS uuid + LANGUAGE sql + STABLE +AS $function$ + select + coalesce( + nullif(current_setting('request.jwt.claim.sub', true), ''), + (nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub') + )::uuid +$function$ + | +| extensions | algorithm_sign | CREATE OR REPLACE FUNCTION extensions.algorithm_sign(signables text, secret text, algorithm text) + RETURNS text + LANGUAGE sql + IMMUTABLE +AS $function$ +WITH + alg AS ( + SELECT CASE + WHEN algorithm = 'HS256' THEN 'sha256' + WHEN algorithm = 'HS384' THEN 'sha384' + WHEN algorithm = 'HS512' THEN 'sha512' + ELSE '' END AS id) -- hmac throws error +SELECT extensions.url_encode(extensions.hmac(signables, secret, alg.id)) FROM alg; +$function$ + | +| extensions | armor | CREATE OR REPLACE FUNCTION extensions.armor(bytea, text[], text[]) + RETURNS text + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_armor$function$ + | +| extensions | armor | CREATE OR REPLACE FUNCTION extensions.armor(bytea) + RETURNS text + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_armor$function$ + | +| extensions | bytea_to_text | CREATE OR REPLACE FUNCTION extensions.bytea_to_text(data bytea) + RETURNS text + LANGUAGE c + IMMUTABLE STRICT +AS '$libdir/http', $function$bytea_to_text$function$ + | +| extensions | crypt | CREATE OR REPLACE FUNCTION extensions.crypt(text, text) + RETURNS text + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_crypt$function$ + | +| extensions | dearmor | CREATE OR REPLACE FUNCTION extensions.dearmor(text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_dearmor$function$ + | +| extensions | decrypt | CREATE OR REPLACE FUNCTION extensions.decrypt(bytea, bytea, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_decrypt$function$ + | +| extensions | decrypt_iv | CREATE OR REPLACE FUNCTION extensions.decrypt_iv(bytea, bytea, bytea, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_decrypt_iv$function$ + | +| extensions | digest | CREATE OR REPLACE FUNCTION extensions.digest(bytea, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_digest$function$ + | +| extensions | digest | CREATE OR REPLACE FUNCTION extensions.digest(text, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_digest$function$ + | +| extensions | encrypt | CREATE OR REPLACE FUNCTION extensions.encrypt(bytea, bytea, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_encrypt$function$ + | +| extensions | encrypt_iv | CREATE OR REPLACE FUNCTION extensions.encrypt_iv(bytea, bytea, bytea, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_encrypt_iv$function$ + | +| extensions | gen_random_bytes | CREATE OR REPLACE FUNCTION extensions.gen_random_bytes(integer) + RETURNS bytea + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_random_bytes$function$ + | +| extensions | gen_random_uuid | CREATE OR REPLACE FUNCTION extensions.gen_random_uuid() + RETURNS uuid + LANGUAGE c + PARALLEL SAFE +AS '$libdir/pgcrypto', $function$pg_random_uuid$function$ + | +| extensions | gen_salt | CREATE OR REPLACE FUNCTION extensions.gen_salt(text) + RETURNS text + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_gen_salt$function$ + | +| extensions | gen_salt | CREATE OR REPLACE FUNCTION extensions.gen_salt(text, integer) + RETURNS text + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_gen_salt_rounds$function$ + | +| extensions | grant_pg_cron_access | CREATE OR REPLACE FUNCTION extensions.grant_pg_cron_access() + RETURNS event_trigger + LANGUAGE plpgsql +AS $function$ +BEGIN + IF EXISTS ( + SELECT + FROM pg_event_trigger_ddl_commands() AS ev + JOIN pg_extension AS ext + ON ev.objid = ext.oid + WHERE ext.extname = 'pg_cron' + ) + THEN + grant usage on schema cron to postgres with grant option; + + alter default privileges in schema cron grant all on tables to postgres with grant option; + alter default privileges in schema cron grant all on functions to postgres with grant option; + alter default privileges in schema cron grant all on sequences to postgres with grant option; + + alter default privileges for user supabase_admin in schema cron grant all + on sequences to postgres with grant option; + alter default privileges for user supabase_admin in schema cron grant all + on tables to postgres with grant option; + alter default privileges for user supabase_admin in schema cron grant all + on functions to postgres with grant option; + + grant all privileges on all tables in schema cron to postgres with grant option; + revoke all on table cron.job from postgres; + grant select on table cron.job to postgres with grant option; + END IF; +END; +$function$ + | +| extensions | grant_pg_graphql_access | CREATE OR REPLACE FUNCTION extensions.grant_pg_graphql_access() + RETURNS event_trigger + LANGUAGE plpgsql +AS $function$ +DECLARE + func_is_graphql_resolve bool; +BEGIN + func_is_graphql_resolve = ( + SELECT n.proname = 'resolve' + FROM pg_event_trigger_ddl_commands() AS ev + LEFT JOIN pg_catalog.pg_proc AS n + ON ev.objid = n.oid + ); + + IF func_is_graphql_resolve + THEN + -- Update public wrapper to pass all arguments through to the pg_graphql resolve func + DROP FUNCTION IF EXISTS graphql_public.graphql; + create or replace function graphql_public.graphql( + "operationName" text default null, + query text default null, + variables jsonb default null, + extensions jsonb default null + ) + returns jsonb + language sql + as $$ + select graphql.resolve( + query := query, + variables := coalesce(variables, '{}'), + "operationName" := "operationName", + extensions := extensions + ); + $$; + + -- This hook executes when `graphql.resolve` is created. That is not necessarily the last + -- function in the extension so we need to grant permissions on existing entities AND + -- update default permissions to any others that are created after `graphql.resolve` + grant usage on schema graphql to postgres, anon, authenticated, service_role; + grant select on all tables in schema graphql to postgres, anon, authenticated, service_role; + grant execute on all functions in schema graphql to postgres, anon, authenticated, service_role; + grant all on all sequences in schema graphql to postgres, anon, authenticated, service_role; + alter default privileges in schema graphql grant all on tables to postgres, anon, authenticated, service_role; + alter default privileges in schema graphql grant all on functions to postgres, anon, authenticated, service_role; + alter default privileges in schema graphql grant all on sequences to postgres, anon, authenticated, service_role; + + -- Allow postgres role to allow granting usage on graphql and graphql_public schemas to custom roles + grant usage on schema graphql_public to postgres with grant option; + grant usage on schema graphql to postgres with grant option; + END IF; + +END; +$function$ + | +| extensions | grant_pg_net_access | CREATE OR REPLACE FUNCTION extensions.grant_pg_net_access() + RETURNS event_trigger + LANGUAGE plpgsql +AS $function$ +BEGIN + IF EXISTS ( + SELECT 1 + FROM pg_event_trigger_ddl_commands() AS ev + JOIN pg_extension AS ext + ON ev.objid = ext.oid + WHERE ext.extname = 'pg_net' + ) + THEN + IF NOT EXISTS ( + SELECT 1 + FROM pg_roles + WHERE rolname = 'supabase_functions_admin' + ) + THEN + CREATE USER supabase_functions_admin NOINHERIT CREATEROLE LOGIN NOREPLICATION; + END IF; + + GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role; + + ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; + ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; + + ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; + ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; + + REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; + REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; + + GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; + GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; + END IF; +END; +$function$ + | +| extensions | hmac | CREATE OR REPLACE FUNCTION extensions.hmac(bytea, bytea, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_hmac$function$ + | +| extensions | hmac | CREATE OR REPLACE FUNCTION extensions.hmac(text, text, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pg_hmac$function$ + | +| extensions | http | CREATE OR REPLACE FUNCTION extensions.http(request http_request) + RETURNS http_response + LANGUAGE c +AS '$libdir/http', $function$http_request$function$ + | +| extensions | http_delete | CREATE OR REPLACE FUNCTION extensions.http_delete(uri character varying, content character varying, content_type character varying) + RETURNS http_response + LANGUAGE sql +AS $function$ SELECT extensions.http(('DELETE', $1, NULL, $3, $2)::extensions.http_request) $function$ + | +| extensions | http_delete | CREATE OR REPLACE FUNCTION extensions.http_delete(uri character varying) + RETURNS http_response + LANGUAGE sql +AS $function$ SELECT extensions.http(('DELETE', $1, NULL, NULL, NULL)::extensions.http_request) $function$ + | +| extensions | http_get | CREATE OR REPLACE FUNCTION extensions.http_get(uri character varying, data jsonb) + RETURNS http_response + LANGUAGE sql +AS $function$ + SELECT extensions.http(('GET', $1 || '?' || extensions.urlencode($2), NULL, NULL, NULL)::extensions.http_request) + $function$ + | +| extensions | http_get | CREATE OR REPLACE FUNCTION extensions.http_get(uri character varying) + RETURNS http_response + LANGUAGE sql +AS $function$ SELECT extensions.http(('GET', $1, NULL, NULL, NULL)::extensions.http_request) $function$ + | +| extensions | http_head | CREATE OR REPLACE FUNCTION extensions.http_head(uri character varying) + RETURNS http_response + LANGUAGE sql +AS $function$ SELECT extensions.http(('HEAD', $1, NULL, NULL, NULL)::extensions.http_request) $function$ + | +| extensions | http_header | CREATE OR REPLACE FUNCTION extensions.http_header(field character varying, value character varying) + RETURNS http_header + LANGUAGE sql +AS $function$ SELECT $1, $2 $function$ + | +| extensions | http_list_curlopt | CREATE OR REPLACE FUNCTION extensions.http_list_curlopt() + RETURNS TABLE(curlopt text, value text) + LANGUAGE c +AS '$libdir/http', $function$http_list_curlopt$function$ + | +| extensions | http_patch | CREATE OR REPLACE FUNCTION extensions.http_patch(uri character varying, content character varying, content_type character varying) + RETURNS http_response + LANGUAGE sql +AS $function$ SELECT extensions.http(('PATCH', $1, NULL, $3, $2)::extensions.http_request) $function$ + | +| extensions | http_post | CREATE OR REPLACE FUNCTION extensions.http_post(uri character varying, content character varying, content_type character varying) + RETURNS http_response + LANGUAGE sql +AS $function$ SELECT extensions.http(('POST', $1, NULL, $3, $2)::extensions.http_request) $function$ + | +| extensions | http_post | CREATE OR REPLACE FUNCTION extensions.http_post(uri character varying, data jsonb) + RETURNS http_response + LANGUAGE sql +AS $function$ + SELECT extensions.http(('POST', $1, NULL, 'application/x-www-form-urlencoded', extensions.urlencode($2))::extensions.http_request) + $function$ + | +| extensions | http_put | CREATE OR REPLACE FUNCTION extensions.http_put(uri character varying, content character varying, content_type character varying) + RETURNS http_response + LANGUAGE sql +AS $function$ SELECT extensions.http(('PUT', $1, NULL, $3, $2)::extensions.http_request) $function$ + | +| extensions | http_reset_curlopt | CREATE OR REPLACE FUNCTION extensions.http_reset_curlopt() + RETURNS boolean + LANGUAGE c +AS '$libdir/http', $function$http_reset_curlopt$function$ + | +| extensions | http_set_curlopt | CREATE OR REPLACE FUNCTION extensions.http_set_curlopt(curlopt character varying, value character varying) + RETURNS boolean + LANGUAGE c +AS '$libdir/http', $function$http_set_curlopt$function$ + | +| extensions | pg_stat_statements | CREATE OR REPLACE FUNCTION extensions.pg_stat_statements(showtext boolean, OUT userid oid, OUT dbid oid, OUT toplevel boolean, OUT queryid bigint, OUT query text, OUT plans bigint, OUT total_plan_time double precision, OUT min_plan_time double precision, OUT max_plan_time double precision, OUT mean_plan_time double precision, OUT stddev_plan_time double precision, OUT calls bigint, OUT total_exec_time double precision, OUT min_exec_time double precision, OUT max_exec_time double precision, OUT mean_exec_time double precision, OUT stddev_exec_time double precision, OUT rows bigint, OUT shared_blks_hit bigint, OUT shared_blks_read bigint, OUT shared_blks_dirtied bigint, OUT shared_blks_written bigint, OUT local_blks_hit bigint, OUT local_blks_read bigint, OUT local_blks_dirtied bigint, OUT local_blks_written bigint, OUT temp_blks_read bigint, OUT temp_blks_written bigint, OUT blk_read_time double precision, OUT blk_write_time double precision, OUT temp_blk_read_time double precision, OUT temp_blk_write_time double precision, OUT wal_records bigint, OUT wal_fpi bigint, OUT wal_bytes numeric, OUT jit_functions bigint, OUT jit_generation_time double precision, OUT jit_inlining_count bigint, OUT jit_inlining_time double precision, OUT jit_optimization_count bigint, OUT jit_optimization_time double precision, OUT jit_emission_count bigint, OUT jit_emission_time double precision) + RETURNS SETOF record + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pg_stat_statements', $function$pg_stat_statements_1_10$function$ + | +| extensions | pg_stat_statements_info | CREATE OR REPLACE FUNCTION extensions.pg_stat_statements_info(OUT dealloc bigint, OUT stats_reset timestamp with time zone) + RETURNS record + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pg_stat_statements', $function$pg_stat_statements_info$function$ + | +| extensions | pg_stat_statements_reset | CREATE OR REPLACE FUNCTION extensions.pg_stat_statements_reset(userid oid DEFAULT 0, dbid oid DEFAULT 0, queryid bigint DEFAULT 0) + RETURNS void + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pg_stat_statements', $function$pg_stat_statements_reset_1_7$function$ + | +| extensions | pgp_armor_headers | CREATE OR REPLACE FUNCTION extensions.pgp_armor_headers(text, OUT key text, OUT value text) + RETURNS SETOF record + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_armor_headers$function$ + | +| extensions | pgp_key_id | CREATE OR REPLACE FUNCTION extensions.pgp_key_id(bytea) + RETURNS text + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_key_id_w$function$ + | +| extensions | pgp_pub_decrypt | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text, text) + RETURNS text + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_text$function$ + | +| extensions | pgp_pub_decrypt | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt(bytea, bytea) + RETURNS text + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_text$function$ + | +| extensions | pgp_pub_decrypt | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt(bytea, bytea, text) + RETURNS text + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_text$function$ + | +| extensions | pgp_pub_decrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_bytea$function$ + | +| extensions | pgp_pub_decrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_bytea$function$ + | +| extensions | pgp_pub_decrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_pub_decrypt_bytea(bytea, bytea, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_pub_decrypt_bytea$function$ + | +| extensions | pgp_pub_encrypt | CREATE OR REPLACE FUNCTION extensions.pgp_pub_encrypt(text, bytea) + RETURNS bytea + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_pub_encrypt_text$function$ + | +| extensions | pgp_pub_encrypt | CREATE OR REPLACE FUNCTION extensions.pgp_pub_encrypt(text, bytea, text) + RETURNS bytea + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_pub_encrypt_text$function$ + | +| extensions | pgp_pub_encrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea, text) + RETURNS bytea + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_pub_encrypt_bytea$function$ + | +| extensions | pgp_pub_encrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_pub_encrypt_bytea(bytea, bytea) + RETURNS bytea + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_pub_encrypt_bytea$function$ + | +| extensions | pgp_sym_decrypt | CREATE OR REPLACE FUNCTION extensions.pgp_sym_decrypt(bytea, text) + RETURNS text + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_sym_decrypt_text$function$ + | +| extensions | pgp_sym_decrypt | CREATE OR REPLACE FUNCTION extensions.pgp_sym_decrypt(bytea, text, text) + RETURNS text + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_sym_decrypt_text$function$ + | +| extensions | pgp_sym_decrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_sym_decrypt_bytea$function$ + | +| extensions | pgp_sym_decrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_sym_decrypt_bytea(bytea, text) + RETURNS bytea + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_sym_decrypt_bytea$function$ + | +| extensions | pgp_sym_encrypt | CREATE OR REPLACE FUNCTION extensions.pgp_sym_encrypt(text, text, text) + RETURNS bytea + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_sym_encrypt_text$function$ + | +| extensions | pgp_sym_encrypt | CREATE OR REPLACE FUNCTION extensions.pgp_sym_encrypt(text, text) + RETURNS bytea + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_sym_encrypt_text$function$ + | +| extensions | pgp_sym_encrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text, text) + RETURNS bytea + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_sym_encrypt_bytea$function$ + | +| extensions | pgp_sym_encrypt_bytea | CREATE OR REPLACE FUNCTION extensions.pgp_sym_encrypt_bytea(bytea, text) + RETURNS bytea + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/pgcrypto', $function$pgp_sym_encrypt_bytea$function$ + | +| extensions | pgrst_ddl_watch | CREATE OR REPLACE FUNCTION extensions.pgrst_ddl_watch() + RETURNS event_trigger + LANGUAGE plpgsql +AS $function$ +DECLARE + cmd record; +BEGIN + FOR cmd IN SELECT * FROM pg_event_trigger_ddl_commands() + LOOP + IF cmd.command_tag IN ( + 'CREATE SCHEMA', 'ALTER SCHEMA' + , 'CREATE TABLE', 'CREATE TABLE AS', 'SELECT INTO', 'ALTER TABLE' + , 'CREATE FOREIGN TABLE', 'ALTER FOREIGN TABLE' + , 'CREATE VIEW', 'ALTER VIEW' + , 'CREATE MATERIALIZED VIEW', 'ALTER MATERIALIZED VIEW' + , 'CREATE FUNCTION', 'ALTER FUNCTION' + , 'CREATE TRIGGER' + , 'CREATE TYPE', 'ALTER TYPE' + , 'CREATE RULE' + , 'COMMENT' + ) + -- don't notify in case of CREATE TEMP table or other objects created on pg_temp + AND cmd.schema_name is distinct from 'pg_temp' + THEN + NOTIFY pgrst, 'reload schema'; + END IF; + END LOOP; +END; $function$ + | +| extensions | pgrst_drop_watch | CREATE OR REPLACE FUNCTION extensions.pgrst_drop_watch() + RETURNS event_trigger + LANGUAGE plpgsql +AS $function$ +DECLARE + obj record; +BEGIN + FOR obj IN SELECT * FROM pg_event_trigger_dropped_objects() + LOOP + IF obj.object_type IN ( + 'schema' + , 'table' + , 'foreign table' + , 'view' + , 'materialized view' + , 'function' + , 'trigger' + , 'type' + , 'rule' + ) + AND obj.is_temporary IS false -- no pg_temp objects + THEN + NOTIFY pgrst, 'reload schema'; + END IF; + END LOOP; +END; $function$ + | +| extensions | set_graphql_placeholder | CREATE OR REPLACE FUNCTION extensions.set_graphql_placeholder() + RETURNS event_trigger + LANGUAGE plpgsql +AS $function$ + DECLARE + graphql_is_dropped bool; + BEGIN + graphql_is_dropped = ( + SELECT ev.schema_name = 'graphql_public' + FROM pg_event_trigger_dropped_objects() AS ev + WHERE ev.schema_name = 'graphql_public' + ); + + IF graphql_is_dropped + THEN + create or replace function graphql_public.graphql( + "operationName" text default null, + query text default null, + variables jsonb default null, + extensions jsonb default null + ) + returns jsonb + language plpgsql + as $$ + DECLARE + server_version float; + BEGIN + server_version = (SELECT (SPLIT_PART((select version()), ' ', 2))::float); + + IF server_version >= 14 THEN + RETURN jsonb_build_object( + 'errors', jsonb_build_array( + jsonb_build_object( + 'message', 'pg_graphql extension is not enabled.' + ) + ) + ); + ELSE + RETURN jsonb_build_object( + 'errors', jsonb_build_array( + jsonb_build_object( + 'message', 'pg_graphql is only available on projects running Postgres 14 onwards.' + ) + ) + ); + END IF; + END; + $$; + END IF; + + END; +$function$ + | +| extensions | sign | CREATE OR REPLACE FUNCTION extensions.sign(payload json, secret text, algorithm text DEFAULT 'HS256'::text) + RETURNS text + LANGUAGE sql + IMMUTABLE +AS $function$ +WITH + header AS ( + SELECT extensions.url_encode(convert_to('{"alg":"' || algorithm || '","typ":"JWT"}', 'utf8')) AS data + ), + payload AS ( + SELECT extensions.url_encode(convert_to(payload::text, 'utf8')) AS data + ), + signables AS ( + SELECT header.data || '.' || payload.data AS data FROM header, payload + ) +SELECT + signables.data || '.' || + extensions.algorithm_sign(signables.data, secret, algorithm) FROM signables; +$function$ + | +| extensions | text_to_bytea | CREATE OR REPLACE FUNCTION extensions.text_to_bytea(data text) + RETURNS bytea + LANGUAGE c + IMMUTABLE STRICT +AS '$libdir/http', $function$text_to_bytea$function$ + | +| extensions | try_cast_double | CREATE OR REPLACE FUNCTION extensions.try_cast_double(inp text) + RETURNS double precision + LANGUAGE plpgsql + IMMUTABLE +AS $function$ + BEGIN + BEGIN + RETURN inp::double precision; + EXCEPTION + WHEN OTHERS THEN RETURN NULL; + END; + END; +$function$ + | +| extensions | url_decode | CREATE OR REPLACE FUNCTION extensions.url_decode(data text) + RETURNS bytea + LANGUAGE sql + IMMUTABLE +AS $function$ +WITH t AS (SELECT translate(data, '-_', '+/') AS trans), + rem AS (SELECT length(t.trans) % 4 AS remainder FROM t) -- compute padding size + SELECT decode( + t.trans || + CASE WHEN rem.remainder > 0 + THEN repeat('=', (4 - rem.remainder)) + ELSE '' END, + 'base64') FROM t, rem; +$function$ + | +| extensions | url_encode | CREATE OR REPLACE FUNCTION extensions.url_encode(data bytea) + RETURNS text + LANGUAGE sql + IMMUTABLE +AS $function$ + SELECT translate(encode(data, 'base64'), E'+/=\n', '-_'); +$function$ + | +| extensions | urlencode | CREATE OR REPLACE FUNCTION extensions.urlencode(string character varying) + RETURNS text + LANGUAGE c + IMMUTABLE STRICT +AS '$libdir/http', $function$urlencode$function$ + | +| extensions | urlencode | CREATE OR REPLACE FUNCTION extensions.urlencode(data jsonb) + RETURNS text + LANGUAGE c + IMMUTABLE STRICT +AS '$libdir/http', $function$urlencode_jsonb$function$ + | +| extensions | urlencode | CREATE OR REPLACE FUNCTION extensions.urlencode(string bytea) + RETURNS text + LANGUAGE c + IMMUTABLE STRICT +AS '$libdir/http', $function$urlencode$function$ + | +| extensions | uuid_generate_v1 | CREATE OR REPLACE FUNCTION extensions.uuid_generate_v1() + RETURNS uuid + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_generate_v1$function$ + | +| extensions | uuid_generate_v1mc | CREATE OR REPLACE FUNCTION extensions.uuid_generate_v1mc() + RETURNS uuid + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_generate_v1mc$function$ + | +| extensions | uuid_generate_v3 | CREATE OR REPLACE FUNCTION extensions.uuid_generate_v3(namespace uuid, name text) + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_generate_v3$function$ + | +| extensions | uuid_generate_v4 | CREATE OR REPLACE FUNCTION extensions.uuid_generate_v4() + RETURNS uuid + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_generate_v4$function$ + | +| extensions | uuid_generate_v5 | CREATE OR REPLACE FUNCTION extensions.uuid_generate_v5(namespace uuid, name text) + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_generate_v5$function$ + | +| extensions | uuid_nil | CREATE OR REPLACE FUNCTION extensions.uuid_nil() + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_nil$function$ + | +| extensions | uuid_ns_dns | CREATE OR REPLACE FUNCTION extensions.uuid_ns_dns() + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_ns_dns$function$ + | +| extensions | uuid_ns_oid | CREATE OR REPLACE FUNCTION extensions.uuid_ns_oid() + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_ns_oid$function$ + | +| extensions | uuid_ns_url | CREATE OR REPLACE FUNCTION extensions.uuid_ns_url() + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_ns_url$function$ + | +| extensions | uuid_ns_x500 | CREATE OR REPLACE FUNCTION extensions.uuid_ns_x500() + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_ns_x500$function$ + | +| extensions | verify | CREATE OR REPLACE FUNCTION extensions.verify(token text, secret text, algorithm text DEFAULT 'HS256'::text) + RETURNS TABLE(header json, payload json, valid boolean) + LANGUAGE sql + IMMUTABLE +AS $function$ + SELECT + jwt.header AS header, + jwt.payload AS payload, + jwt.signature_ok AND tstzrange( + to_timestamp(extensions.try_cast_double(jwt.payload->>'nbf')), + to_timestamp(extensions.try_cast_double(jwt.payload->>'exp')) + ) @> CURRENT_TIMESTAMP AS valid + FROM ( + SELECT + convert_from(extensions.url_decode(r[1]), 'utf8')::json AS header, + convert_from(extensions.url_decode(r[2]), 'utf8')::json AS payload, + r[3] = extensions.algorithm_sign(r[1] || '.' || r[2], secret, algorithm) AS signature_ok + FROM regexp_split_to_array(token, '\.') r + ) jwt +$function$ + | +| graphql | _internal_resolve | CREATE OR REPLACE FUNCTION graphql._internal_resolve(query text, variables jsonb DEFAULT '{}'::jsonb, "operationName" text DEFAULT NULL::text, extensions jsonb DEFAULT NULL::jsonb) + RETURNS jsonb + LANGUAGE c +AS '$libdir/pg_graphql', $function$resolve_wrapper$function$ + | +| graphql | comment_directive | CREATE OR REPLACE FUNCTION graphql.comment_directive(comment_ text) + RETURNS jsonb + LANGUAGE sql + IMMUTABLE +AS $function$ + /* + comment on column public.account.name is '@graphql.name: myField' + */ + select + coalesce( + ( + regexp_match( + comment_, + '@graphql\((.+)\)' + ) + )[1]::jsonb, + jsonb_build_object() + ) +$function$ + | +| graphql | exception | CREATE OR REPLACE FUNCTION graphql.exception(message text) + RETURNS text + LANGUAGE plpgsql +AS $function$ +begin + raise exception using errcode='22000', message=message; +end; +$function$ + | +| graphql | get_schema_version | CREATE OR REPLACE FUNCTION graphql.get_schema_version() + RETURNS integer + LANGUAGE sql + SECURITY DEFINER +AS $function$ + select last_value from graphql.seq_schema_version; +$function$ + | +| graphql | increment_schema_version | CREATE OR REPLACE FUNCTION graphql.increment_schema_version() + RETURNS event_trigger + LANGUAGE plpgsql + SECURITY DEFINER +AS $function$ +begin + perform nextval('graphql.seq_schema_version'); +end; +$function$ + | +| graphql | resolve | CREATE OR REPLACE FUNCTION graphql.resolve(query text, variables jsonb DEFAULT '{}'::jsonb, "operationName" text DEFAULT NULL::text, extensions jsonb DEFAULT NULL::jsonb) + RETURNS jsonb + LANGUAGE plpgsql +AS $function$ +declare + res jsonb; + message_text text; +begin + begin + select graphql._internal_resolve("query" := "query", + "variables" := "variables", + "operationName" := "operationName", + "extensions" := "extensions") into res; + return res; + exception + when others then + get stacked diagnostics message_text = message_text; + return + jsonb_build_object('data', null, + 'errors', jsonb_build_array(jsonb_build_object('message', message_text))); + end; +end; +$function$ + | +| graphql_public | graphql | CREATE OR REPLACE FUNCTION graphql_public.graphql("operationName" text DEFAULT NULL::text, query text DEFAULT NULL::text, variables jsonb DEFAULT NULL::jsonb, extensions jsonb DEFAULT NULL::jsonb) + RETURNS jsonb + LANGUAGE sql +AS $function$ + select graphql.resolve( + query := query, + variables := coalesce(variables, '{}'), + "operationName" := "operationName", + extensions := extensions + ); + $function$ + | +| net | _await_response | CREATE OR REPLACE FUNCTION net._await_response(request_id bigint) + RETURNS boolean + LANGUAGE plpgsql + PARALLEL SAFE STRICT +AS $function$ +declare + rec net._http_response; +begin + while rec is null loop + select * + into rec + from net._http_response + where id = request_id; + + if rec is null then + -- Wait 50 ms before checking again + perform pg_sleep(0.05); + end if; + end loop; + + return true; +end; +$function$ + | +| net | _encode_url_with_params_array | CREATE OR REPLACE FUNCTION net._encode_url_with_params_array(url text, params_array text[]) + RETURNS text + LANGUAGE c + IMMUTABLE STRICT +AS 'pg_net', $function$_encode_url_with_params_array$function$ + | +| net | _http_collect_response | CREATE OR REPLACE FUNCTION net._http_collect_response(request_id bigint, async boolean DEFAULT true) + RETURNS net.http_response_result + LANGUAGE plpgsql + PARALLEL SAFE STRICT +AS $function$ +declare + rec net._http_response; + req_exists boolean; +begin + + if not async then + perform net._await_response(request_id); + end if; + + select * + into rec + from net._http_response + where id = request_id; + + if rec is null or rec.error_msg is not null then + -- The request is either still processing or the request_id provided does not exist + + -- TODO: request in progress is indistinguishable from request that doesn't exist + + -- No request matching request_id found + return ( + 'ERROR', + coalesce(rec.error_msg, 'request matching request_id not found'), + null + )::net.http_response_result; + + end if; + + -- Return a valid, populated http_response_result + return ( + 'SUCCESS', + 'ok', + ( + rec.status_code, + rec.headers, + rec.content + )::net.http_response + )::net.http_response_result; +end; +$function$ + | +| net | _urlencode_string | CREATE OR REPLACE FUNCTION net._urlencode_string(string character varying) + RETURNS text + LANGUAGE c + IMMUTABLE STRICT +AS 'pg_net', $function$_urlencode_string$function$ + | +| net | check_worker_is_up | CREATE OR REPLACE FUNCTION net.check_worker_is_up() + RETURNS void + LANGUAGE plpgsql +AS $function$ +begin + if not exists (select pid from pg_stat_activity where backend_type ilike '%pg_net%') then + raise exception using + message = 'the pg_net background worker is not up' + , detail = 'the pg_net background worker is down due to an internal error and cannot process requests' + , hint = 'make sure that you didn''t modify any of pg_net internal tables'; + end if; +end +$function$ + | +| net | http_collect_response | CREATE OR REPLACE FUNCTION net.http_collect_response(request_id bigint, async boolean DEFAULT true) + RETURNS net.http_response_result + LANGUAGE plpgsql + PARALLEL SAFE STRICT +AS $function$ +begin + raise notice 'The net.http_collect_response function is deprecated.'; + select net._http_collect_response(request_id, async); +end; +$function$ + | +| net | http_delete | CREATE OR REPLACE FUNCTION net.http_delete(url text, params jsonb DEFAULT '{}'::jsonb, headers jsonb DEFAULT '{}'::jsonb, timeout_milliseconds integer DEFAULT 5000) + RETURNS bigint + LANGUAGE plpgsql + PARALLEL SAFE STRICT +AS $function$ +declare + request_id bigint; + params_array text[]; +begin + select coalesce(array_agg(net._urlencode_string(key) || '=' || net._urlencode_string(value)), '{}') + into params_array + from jsonb_each_text(params); + + -- Add to the request queue + insert into net.http_request_queue(method, url, headers, timeout_milliseconds) + values ( + 'DELETE', + net._encode_url_with_params_array(url, params_array), + headers, + timeout_milliseconds + ) + returning id + into request_id; + + return request_id; +end +$function$ + | +| net | http_get | CREATE OR REPLACE FUNCTION net.http_get(url text, params jsonb DEFAULT '{}'::jsonb, headers jsonb DEFAULT '{}'::jsonb, timeout_milliseconds integer DEFAULT 5000) + RETURNS bigint + LANGUAGE plpgsql + PARALLEL SAFE STRICT SECURITY DEFINER + SET search_path TO 'net' +AS $function$ +declare + request_id bigint; + params_array text[]; +begin + select coalesce(array_agg(net._urlencode_string(key) || '=' || net._urlencode_string(value)), '{}') + into params_array + from jsonb_each_text(params); + + -- Add to the request queue + insert into net.http_request_queue(method, url, headers, timeout_milliseconds) + values ( + 'GET', + net._encode_url_with_params_array(url, params_array), + headers, + timeout_milliseconds + ) + returning id + into request_id; + + return request_id; +end +$function$ + | +| net | http_post | CREATE OR REPLACE FUNCTION net.http_post(url text, body jsonb DEFAULT '{}'::jsonb, params jsonb DEFAULT '{}'::jsonb, headers jsonb DEFAULT '{"Content-Type": "application/json"}'::jsonb, timeout_milliseconds integer DEFAULT 5000) + RETURNS bigint + LANGUAGE plpgsql + PARALLEL SAFE SECURITY DEFINER + SET search_path TO 'net' +AS $function$ +declare + request_id bigint; + params_array text[]; + content_type text; +begin + + -- Exctract the content_type from headers + select + header_value into content_type + from + jsonb_each_text(coalesce(headers, '{}'::jsonb)) r(header_name, header_value) + where + lower(header_name) = 'content-type' + limit + 1; + + -- If the user provided new headers and omitted the content type + -- add it back in automatically + if content_type is null then + select headers || '{"Content-Type": "application/json"}'::jsonb into headers; + end if; + + -- Confirm that the content-type is set as "application/json" + if content_type <> 'application/json' then + raise exception 'Content-Type header must be "application/json"'; + end if; + + select + coalesce(array_agg(net._urlencode_string(key) || '=' || net._urlencode_string(value)), '{}') + into + params_array + from + jsonb_each_text(params); + + -- Add to the request queue + insert into net.http_request_queue(method, url, headers, body, timeout_milliseconds) + values ( + 'POST', + net._encode_url_with_params_array(url, params_array), + headers, + convert_to(body::text, 'UTF8'), + timeout_milliseconds + ) + returning id + into request_id; + + return request_id; +end +$function$ + | \ No newline at end of file diff --git a/supabase/contexts/policies.md b/supabase/contexts/policies.md new file mode 100644 index 0000000..efec9bd --- /dev/null +++ b/supabase/contexts/policies.md @@ -0,0 +1,91 @@ +| policy_id | schema_name | table_name | policy_name | command | policy_using | policy_check | +| --------- | ----------- | ---------------------- | ------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| 29823 | auth | users | Validate user metadata | * | (((raw_user_meta_data ->> 'role'::text))::user_role IS NOT NULL) | | +| 29615 | public | classes | Schools can create classes | a | | (school_id = auth.uid()) | +| 29616 | public | classes | Schools can update their classes | w | (school_id = auth.uid()) | (school_id = auth.uid()) | +| 29614 | public | classes | Schools can view their classes | r | (school_id = auth.uid()) | | +| 29301 | public | classes | Turmas visíveis para usuários autenticados | r | true | | +| 65878 | public | interests | Students can delete their own interests | d | (auth.uid() = student_id) | | +| 65876 | public | interests | Students can insert their own interests | a | | (auth.uid() = student_id) | +| 65877 | public | interests | Students can update their own interests | w | (auth.uid() = student_id) | (auth.uid() = student_id) | +| 65875 | public | interests | Students can view their own interests | r | (auth.uid() = student_id) | | +| 79931 | public | phonics_categories | Permitir leitura de categorias fonéticas para usuários autent | r | true | | +| 79932 | public | phonics_exercise_types | Permitir leitura de tipos de exercícios fonéticos para usuár | r | true | | +| 79934 | public | phonics_exercise_words | Permitir leitura de relações exercício-palavra para usuário | r | true | | +| 79930 | public | phonics_exercises | Permitir leitura de exercícios fonéticos para usuários auten | r | true | | +| 79933 | public | phonics_words | Permitir leitura de palavras fonéticas para usuários autentic | r | true | | +| 29440 | public | schools | Enable insert for registration | a | | true | +| 29299 | public | schools | Escolas visíveis para usuários autenticados | r | true | | +| 29442 | public | schools | Schools can update own data | w | (auth.uid() = id) | (auth.uid() = id) | +| 29441 | public | schools | Schools can view own data | r | (auth.uid() = id) | | +| 29347 | public | stories | Alunos podem atualizar suas próprias histórias | w | (student_id IN ( SELECT students.id + FROM students + WHERE (students.email = auth.email()))) | | +| 29346 | public | stories | Alunos podem criar suas próprias histórias | a | | (student_id IN ( SELECT students.id + FROM students + WHERE (students.email = auth.email()))) | +| 36241 | public | stories | Estudantes podem ver suas próprias histórias | r | ((auth.uid() = student_id) AND (EXISTS ( SELECT 1 + FROM story_themes + WHERE ((story_themes.id = stories.theme_id) AND (story_themes.active = true)))) AND (EXISTS ( SELECT 1 + FROM story_subjects + WHERE ((story_subjects.id = stories.subject_id) AND (story_subjects.active = true)))) AND (EXISTS ( SELECT 1 + FROM story_characters + WHERE ((story_characters.id = stories.character_id) AND (story_characters.active = true)))) AND (EXISTS ( SELECT 1 + FROM story_settings + WHERE ((story_settings.id = stories.setting_id) AND (story_settings.active = true))))) | | +| 29345 | public | stories | Histórias visíveis para usuários autenticados | r | true | | +| 53384 | public | stories | Permitir deleção pelo dono | d | (auth.uid() = student_id) | | +| 34952 | public | story_characters | Permitir leitura pública dos personagens | r | (active = true) | | +| 53955 | public | story_exercise_words | Apenas sistema pode inserir | a | | (auth.role() = 'service_role'::text) | +| 53954 | public | story_exercise_words | Leitura pública das palavras | r | true | | +| 37664 | public | story_generations | Apenas service_role pode inserir metadados | a | | true | +| 37663 | public | story_generations | Metadados são visíveis para todos | r | true | | +| 37662 | public | story_pages | Apenas service_role pode inserir páginas | a | | true | +| 37661 | public | story_pages | Páginas são visíveis para todos | r | true | | +| 31560 | public | story_recordings | Escolas podem ver todas as gravações | r | (EXISTS ( SELECT 1 + FROM students s + WHERE ((s.id = story_recordings.student_id) AND (s.school_id = auth.uid())))) | | +| 30092 | public | story_recordings | Estudantes podem gravar áudios | a | | (auth.uid() = student_id) | +| 31511 | public | story_recordings | Estudantes podem ver suas próprias gravações | r | (auth.uid() = student_id) | | +| 31558 | public | story_recordings | Professores podem ver gravações de seus alunos | r | (EXISTS ( SELECT 1 + FROM (classes c + JOIN students s ON ((s.class_id = c.id))) + WHERE ((s.id = story_recordings.student_id) AND (c.teacher_id = auth.uid())))) | | +| 29748 | public | story_recordings | Students can insert their own recordings | a | | (auth.uid() = student_id) | +| 29749 | public | story_recordings | Students can view their own recordings | r | (auth.uid() = student_id) | | +| 34953 | public | story_settings | Permitir leitura pública dos cenários | r | (active = true) | | +| 34951 | public | story_subjects | Permitir leitura pública das disciplinas | r | (active = true) | | +| 34950 | public | story_themes | Permitir leitura pública das categorias | r | (active = true) | | +| 29302 | public | students | Alunos visíveis para usuários autenticados | r | true | | +| 29638 | public | students | Escolas podem inserir seus próprios alunos | a | | (auth.uid() IN ( SELECT schools.id + FROM schools + WHERE (schools.id = students.school_id))) | +| 29639 | public | students | Escolas podem ver seus próprios alunos | r | (auth.uid() IN ( SELECT schools.id + FROM schools + WHERE (schools.id = students.school_id))) | | +| 29584 | public | students | Schools can view their students | r | (school_id = auth.uid()) | | +| 29511 | public | teacher_invites | Schools can invite teachers | a | | (school_id IN ( SELECT schools.id + FROM schools + WHERE (schools.id = auth.uid()))) | +| 29300 | public | teachers | Professores visíveis para usuários autenticados | r | true | | +| 29510 | public | teachers | Schools can view their teachers | r | (school_id IN ( SELECT schools.id + FROM schools + WHERE (schools.id = auth.uid()))) | | +| 29509 | public | teachers | Teachers can view own data | r | (auth.uid() = id) | | +| 29717 | storage | objects | Anyone can read recordings | r | (bucket_id = 'recordings'::text) | | +| 30136 | storage | objects | Estudantes podem fazer upload de áudios | a | | ((bucket_id = 'recordings'::text) AND ((auth.uid())::text = (storage.foldername(name))[1])) | +| 75352 | storage | objects | Imagens são publicamente acessíveis | r | (bucket_id = 'story-images'::text) | | +| 43940 | storage | objects | Permitir acesso da Edge Function | r | ((bucket_id = 'recordings'::text) AND ((auth.jwt() ->> 'role'::text) = 'service_role'::text)) | | +| 52098 | storage | objects | Permitir acesso público para leitura | r | (bucket_id = 'recordings'::text) | | +| 37570 | storage | objects | Permitir acesso público para leitura de imagens de histórias | r | (bucket_id = 'story-images'::text) | | +| 37573 | storage | objects | Permitir delete pela edge function | d | (bucket_id = 'story-images'::text) | | +| 53468 | storage | objects | Permitir deleção de imagens pelo dono da história | d | ((bucket_id = 'story-images'::text) AND (EXISTS ( SELECT 1 + FROM stories s + WHERE ((s.id = ((storage.foldername(objects.name))[1])::uuid) AND (s.student_id = auth.uid()))))) | | +| 53426 | storage | objects | Permitir deleção pelo dono do arquivo | d | ((bucket_id = 'recordings'::text) AND ((storage.foldername(name))[1] = (auth.uid())::text)) | | +| 52099 | storage | objects | Permitir download público | r | (bucket_id = 'recordings'::text) | | +| 37572 | storage | objects | Permitir update pela edge function | w | (bucket_id = 'story-images'::text) | | +| 43939 | storage | objects | Permitir upload de áudios autenticado | a | | ((bucket_id = 'recordings'::text) AND (auth.role() = 'authenticated'::text)) | +| 37571 | storage | objects | Permitir upload pela edge function | a | | (bucket_id = 'story-images'::text) | +| 29716 | storage | objects | Students can upload their recordings | a | | ((bucket_id = 'recordings'::text) AND (auth.role() = 'student'::text)) | +| 74045 | storage | objects | Áudios públicos | r | (bucket_id = 'phonics-audio'::text) | | \ No newline at end of file