From 1716487c20bc157e13fd6b6a106d3d713abf9da9 Mon Sep 17 00:00:00 2001 From: Juan Andrade <78118656+Dosbodoke@users.noreply.github.com> Date: Thu, 6 Feb 2025 17:59:13 -0300 Subject: [PATCH] New DB schema and Privacy policy (#51) * Enable static rendering for festival and home page * Bump to Next 15 and React 19 * Update React to stable version * Added animation to map toggle * Animate trigger * Fix marker animation * Pill animation * Update to work with new databas schema * Added privacy policy --- .../[id]/_components/HighlineHeader.tsx | 2 +- app/[locale]/[id]/_components/Info.tsx | 4 +- app/[locale]/_components/Highline.tsx | 2 +- .../festival/_components/timeline.tsx | 118 -- app/[locale]/privacy/page.tsx | 66 + .../[username]/_components/LastWalks.tsx | 2 +- components/CreateHighline.tsx | 12 +- components/Map/LocationPicker.tsx | 2 +- components/Map/Selected.tsx | 2 +- messages/en.json | 37 + messages/pt.json | 37 + .../20230708122900_remote_commit.sql | 203 --- .../20230719130300_entry_cadena_number.sql | 41 - .../migrations/20231029094600_profile.sql | 79 - .../20231030152535_auth_trigger.sql | 4 - .../20231030163000_auth_policies.sql | 72 - .../20231031140730_profile_picture.sql | 3 - .../20240126152956_remote_schema.sql | 22 - .../20240226160441_favorite_highline.sql | 47 - .../20240329190725_highline_anchor_b.sql | 15 - .../20240331164414_get_highline.sql | 39 - .../20240404125731_update_highline_rls.sql | 9 - ...40417183631_entry_with_profile_picture.sql | 70 - ...4_fix_entry_whitout_associated_profile.sql | 64 - ...240520004328_multiple_highline_ranking.sql | 70 - .../20240522132228_get_multiple_highline.sql | 43 - ...20240522152724_ranking_with_date_range.sql | 84 - .../20250206202200_remote_schema.sql | 627 +++++++ utils/supabase/database.types.ts | 1603 +++++++++-------- 29 files changed, 1657 insertions(+), 1722 deletions(-) delete mode 100644 app/[locale]/festival/_components/timeline.tsx create mode 100644 app/[locale]/privacy/page.tsx delete mode 100644 supabase/migrations/20230708122900_remote_commit.sql delete mode 100644 supabase/migrations/20230719130300_entry_cadena_number.sql delete mode 100644 supabase/migrations/20231029094600_profile.sql delete mode 100644 supabase/migrations/20231030152535_auth_trigger.sql delete mode 100644 supabase/migrations/20231030163000_auth_policies.sql delete mode 100644 supabase/migrations/20231031140730_profile_picture.sql delete mode 100644 supabase/migrations/20240126152956_remote_schema.sql delete mode 100644 supabase/migrations/20240226160441_favorite_highline.sql delete mode 100644 supabase/migrations/20240329190725_highline_anchor_b.sql delete mode 100644 supabase/migrations/20240331164414_get_highline.sql delete mode 100644 supabase/migrations/20240404125731_update_highline_rls.sql delete mode 100644 supabase/migrations/20240417183631_entry_with_profile_picture.sql delete mode 100644 supabase/migrations/20240417190644_fix_entry_whitout_associated_profile.sql delete mode 100644 supabase/migrations/20240520004328_multiple_highline_ranking.sql delete mode 100644 supabase/migrations/20240522132228_get_multiple_highline.sql delete mode 100644 supabase/migrations/20240522152724_ranking_with_date_range.sql create mode 100644 supabase/migrations/20250206202200_remote_schema.sql diff --git a/app/[locale]/[id]/_components/HighlineHeader.tsx b/app/[locale]/[id]/_components/HighlineHeader.tsx index 5ad627d..86b93f9 100644 --- a/app/[locale]/[id]/_components/HighlineHeader.tsx +++ b/app/[locale]/[id]/_components/HighlineHeader.tsx @@ -58,7 +58,7 @@ export const HighlineHeader = ({ highline }: { highline: Highline }) => {
); } diff --git a/app/[locale]/_components/Highline.tsx b/app/[locale]/_components/Highline.tsx index 0a70b29..9aa6ea4 100644 --- a/app/[locale]/_components/Highline.tsx +++ b/app/[locale]/_components/Highline.tsx @@ -45,7 +45,7 @@ export function Highline({ highline, classname }: Props) {
{" "} - {highline.lenght.toFixed(0)}m + {highline.length.toFixed(0)}m
diff --git a/app/[locale]/festival/_components/timeline.tsx b/app/[locale]/festival/_components/timeline.tsx deleted file mode 100644 index c943f54..0000000 --- a/app/[locale]/festival/_components/timeline.tsx +++ /dev/null @@ -1,118 +0,0 @@ -import { ClockIcon } from "lucide-react"; -import React from "react"; - -export const timeline = () => {}; - -// import { AvatarImage, AvatarFallback, Avatar } from "@/components/ui/avatar" - -export const Timeline = () => { - return ( -
-
-
-
-
-
Ínicio de festival
-
- - 9:00 AM -
-
-
- Abertura oficila das vias de Highline -
-
-
-
-
-
Oficina de resgate
-
- - 11:00 AM -
-
-
- Ministrada por ..., você vai aprender tudo sobre resgate -
-
- {/* Sponsor Logo */} -
-
Pessoa XXX
-
- Highliner -
-
-
-
-
-
-
-
Panel Discussion
-
- - 2:00 PM -
-
-
- Join our panel of experts for an insightful discussion on the future - of the industry. -
-
- {/* - - JS - */} -
-
Jane Smith
-
- Industry Analyst -
-
-
-
-
-
-
-
Networking Reception
-
- - 5:00 PM -
-
-
- Join us for drinks and hors oeuvres to network with other attendees. -
-
- {/* Sponsor Logo */} -
-
Globex Corporation
-
- Gold Sponsor -
-
-
-
-
-
- ); -}; diff --git a/app/[locale]/privacy/page.tsx b/app/[locale]/privacy/page.tsx new file mode 100644 index 0000000..77a6584 --- /dev/null +++ b/app/[locale]/privacy/page.tsx @@ -0,0 +1,66 @@ +import type { Metadata } from "next"; +import { getTranslations } from "next-intl/server"; + +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; + +export const revalidate = 0; + +export const metadata: Metadata = { + title: "Privacy Policy", + description: "Our commitment to protecting your privacy", +}; + +export default async function PrivacyPolicyPage() { + const t = await getTranslations("privacyPolicy"); + + return ( +
+ + + {t("title")} + + +

{t("intro")}

+ +

+ {t("collectionUse.title")} +

+

{t("collectionUse.p1")}

+

{t("collectionUse.p2")}

+

{t("collectionUse.p3")}

+ +

{t("cookies.title")}

+

{t("cookies.p1")}

+

{t("cookies.p2")}

+

{t("cookies.p3")}

+ +

+ {t("externalLinks.title")} +

+

{t("externalLinks.content")}

+ +

+ {t("rightOfRefusal.title")} +

+

{t("rightOfRefusal.p1")}

+

{t("rightOfRefusal.p2")}

+ +

+ {t("userCommitment.title")} +

+

{t("userCommitment.intro")}

+
    +
  • {t("userCommitment.a")}
  • +
  • {t("userCommitment.b")}
  • +
  • {t("userCommitment.c")}
  • +
+ +

{t("moreInfo.title")}

+

{t("moreInfo.content")}

+ +

{t("effectiveDate")}

+
+
+
+ ); +} diff --git a/app/[locale]/profile/[username]/_components/LastWalks.tsx b/app/[locale]/profile/[username]/_components/LastWalks.tsx index 9c8abe9..965492d 100644 --- a/app/[locale]/profile/[username]/_components/LastWalks.tsx +++ b/app/[locale]/profile/[username]/_components/LastWalks.tsx @@ -121,7 +121,7 @@ function LastWalksContent({ entries }: ContentProps) { {t("popover.height")}: {entry.highline?.height}m

- {t("popover.length")}: {entry.highline?.lenght}m + {t("popover.length")}: {entry.highline?.length}m

diff --git a/messages/en.json b/messages/en.json index 55924ab..296df9d 100644 --- a/messages/en.json +++ b/messages/en.json @@ -264,5 +264,42 @@ "festival": { "cardSubTitle": "Follow the festival ranking in real time", "pageSubTitle": "The biggest Highline festival in Brazil" + }, + "privacyPolicy": { + "title": "Privacy Policy", + "intro": "Your privacy is important to us. It is ChooseLife's policy to respect your privacy regarding any information we may collect from you across our website, ChooseLife, and other sites we own and operate.", + "collectionUse": { + "title": "Information Collection and Use", + "p1": "We only ask for personal information when we truly need it to provide a service to you. We collect it by fair and lawful means, with your knowledge and consent. We also let you know why we're collecting it and how it will be used.", + "p2": "We only retain collected information for as long as necessary to provide you with your requested service. What data we store, we'll protect within commercially acceptable means to prevent loss and theft, as well as unauthorized access, disclosure, copying, use or modification.", + "p3": "We don't share any personally identifying information publicly or with third-parties, except when required to by law." + }, + "cookies": { + "title": "Use of Cookies", + "p1": "We use cookies to improve your experience on our site. Specifically, we use cookies for authentication purposes with Supabase, our backend provider. These cookies are essential for the website's functionality and to keep you logged in during your session.", + "p2": "Authentication cookies securely store session information, allowing you to browse the site without having to log in repeatedly. They do not collect any personal information beyond what is necessary for this function.", + "p3": "You can choose to disable cookies through your browser settings. However, this may affect the functionality of the site, especially regarding authentication and staying logged in." + }, + "externalLinks": { + "title": "External Links", + "content": "Our website may link to external sites that are not operated by us. Please be aware that we have no control over the content and practices of these sites, and cannot accept responsibility or liability for their respective privacy policies." + }, + "rightOfRefusal": { + "title": "Your Right of Refusal", + "p1": "You are free to refuse our request for your personal information, with the understanding that we may be unable to provide you with some of your desired services.", + "p2": "Your continued use of our website will be regarded as acceptance of our practices around privacy and personal information. If you have any questions about how we handle user data and personal information, feel free to contact us." + }, + "userCommitment": { + "title": "User Commitment", + "intro": "The user commits to properly use the contents and information that ChooseLife offers on the website and with enunciative, but not limiting, character:", + "a": "A) Not to engage in activities that are illegal or contrary to good faith and public order;", + "b": "B) Not to spread propaganda or content of a racist, xenophobic nature, or any type of illegal pornography, terrorist advocacy, or against human rights;", + "c": "C) Not to cause damage to the physical (hardware) and logical (software) systems of ChooseLife, its suppliers or third parties, to introduce or spread computer viruses or any other hardware or software systems that are capable of causing the aforementioned damages." + }, + "moreInfo": { + "title": "More Information", + "content": "Hopefully, this has clarified things for you and as was previously mentioned if there is something that you aren't sure whether you need or not it's usually safer to leave cookies enabled in case it does interact with one of the features you use on our site." + }, + "effectiveDate": "This policy is effective as of February 6, 2025." } } diff --git a/messages/pt.json b/messages/pt.json index 40f9ff6..be293a8 100644 --- a/messages/pt.json +++ b/messages/pt.json @@ -264,5 +264,42 @@ "festival": { "cardSubTitle": "Acompanhe o ranking do festival em tempo real", "pageSubTitle": "O maior festival de Highline do Brasil" + }, + "privacyPolicy": { + "title": "Política de Privacidade", + "intro": "A sua privacidade é importante para nós. É política do ChooseLife respeitar a sua privacidade em relação a qualquer informação sua que possamos coletar no site ChooseLife, e outros sites que possuímos e operamos.", + "collectionUse": { + "title": "Coleta e Uso de Informações", + "p1": "Solicitamos informações pessoais apenas quando realmente precisamos delas para lhe fornecer um serviço. Fazemo-lo por meios justos e legais, com o seu conhecimento e consentimento. Também informamos por que estamos coletando e como será usado.", + "p2": "Apenas retemos as informações coletadas pelo tempo necessário para fornecer o serviço solicitado. Quando armazenamos dados, protegemos dentro de meios comercialmente aceitáveis para evitar perdas e roubos, bem como acesso, divulgação, cópia, uso ou modificação não autorizados.", + "p3": "Não compartilhamos informações de identificação pessoal publicamente ou com terceiros, exceto quando exigido por lei." + }, + "cookies": { + "title": "Uso de Cookies", + "p1": "Utilizamos cookies para melhorar a sua experiência em nosso site. Especificamente, usamos cookies para fins de autenticação com o Supabase, nosso provedor de backend. Estes cookies são essenciais para o funcionamento do site e para manter você conectado durante a sua sessão.", + "p2": "Os cookies de autenticação armazenam informações de sessão de forma segura, permitindo que você navegue pelo site sem precisar fazer login repetidamente. Eles não coletam nenhuma informação pessoal além do necessário para esta função.", + "p3": "Você pode optar por desativar os cookies através das configurações do seu navegador. No entanto, isso pode afetar a funcionalidade do site, especialmente no que diz respeito à autenticação e à permanência do login." + }, + "externalLinks": { + "title": "Links Externos", + "content": "O nosso site pode ter links para sites externos que não são operados por nós. Esteja ciente de que não temos controle sobre o conteúdo e práticas desses sites e não podemos aceitar responsabilidade por suas respectivas políticas de privacidade." + }, + "rightOfRefusal": { + "title": "Seu Direito de Recusa", + "p1": "Você é livre para recusar a nossa solicitação de informações pessoais, entendendo que talvez não possamos fornecer alguns dos serviços desejados.", + "p2": "O uso continuado de nosso site será considerado como aceitação de nossas práticas em torno de privacidade e informações pessoais. Se você tiver alguma dúvida sobre como lidamos com dados do usuário e informações pessoais, entre em contato conosco." + }, + "userCommitment": { + "title": "Compromisso do Usuário", + "intro": "O usuário se compromete a fazer uso adequado dos conteúdos e da informação que o ChooseLife oferece no site e com caráter enunciativo, mas não limitativo:", + "a": "A) Não se envolver em atividades que sejam ilegais ou contrárias à boa fé a à ordem pública;", + "b": "B) Não difundir propaganda ou conteúdo de natureza racista, xenofóbica, de azar, qualquer tipo de pornografia ilegal, de apologia ao terrorismo ou contra os direitos humanos;", + "c": "C) Não causar danos aos sistemas físicos (hardwares) e lógicos (softwares) do ChooseLife, de seus fornecedores ou terceiros, para introduzir ou disseminar vírus informáticos ou quaisquer outros sistemas de hardware ou software que sejam capazes de causar danos anteriormente mencionados." + }, + "moreInfo": { + "title": "Mais informações", + "content": "Esperamos que esteja esclarecido e, como mencionado anteriormente, se houver algo que você não tem certeza se precisa ou não, geralmente é mais seguro deixar os cookies ativados, caso interaja com um dos recursos que você usa em nosso site." + }, + "effectiveDate": "Esta política é efetiva a partir de 6 de fevereiro de 2025." } } diff --git a/supabase/migrations/20230708122900_remote_commit.sql b/supabase/migrations/20230708122900_remote_commit.sql deleted file mode 100644 index 305ca0d..0000000 --- a/supabase/migrations/20230708122900_remote_commit.sql +++ /dev/null @@ -1,203 +0,0 @@ - -SET statement_timeout = 0; -SET lock_timeout = 0; -SET idle_in_transaction_session_timeout = 0; -SET client_encoding = 'UTF8'; -SET standard_conforming_strings = on; -SELECT pg_catalog.set_config('search_path', '', false); -SET check_function_bodies = false; -SET xmloption = content; -SET client_min_messages = warning; -SET row_security = off; - -CREATE EXTENSION IF NOT EXISTS "pgsodium" WITH SCHEMA "pgsodium"; - -CREATE EXTENSION IF NOT EXISTS "pg_graphql" WITH SCHEMA "graphql"; - -CREATE EXTENSION IF NOT EXISTS "pg_stat_statements" WITH SCHEMA "extensions"; - -CREATE EXTENSION IF NOT EXISTS "pgcrypto" WITH SCHEMA "extensions"; - -CREATE EXTENSION IF NOT EXISTS "pgjwt" WITH SCHEMA "extensions"; - -CREATE EXTENSION IF NOT EXISTS "supabase_vault" WITH SCHEMA "vault"; - -CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA "extensions"; - -CREATE FUNCTION "public"."get_total_cadenas"("highline_id" "uuid", "page_number" integer, "page_size" integer) RETURNS TABLE("instagram" "text", "total_cadenas" integer) - LANGUAGE "sql" - AS $$ - SELECT instagram, COUNT(*) AS total_cadenas - FROM entry - WHERE highline_id = get_total_cadenas.highline_id AND is_cadena = true - GROUP BY instagram - ORDER BY total_cadenas DESC - OFFSET (get_total_cadenas.page_number - 1) * page_size - LIMIT page_size; -$$; - -ALTER FUNCTION "public"."get_total_cadenas"("highline_id" "uuid", "page_number" integer, "page_size" integer) OWNER TO "postgres"; - -CREATE FUNCTION "public"."get_total_full_lines"("highline_id" "uuid", "page_number" integer, "page_size" integer) RETURNS TABLE("instagram" "text", "total_full_lines" integer) - LANGUAGE "sql" - AS $$ - SELECT instagram, COUNT(*) AS total_full_lines - FROM entry - WHERE highline_id = get_total_full_lines.highline_id AND is_full_line = true - GROUP BY instagram - ORDER BY total_full_lines DESC - OFFSET (get_total_full_lines.page_number - 1) * page_size - LIMIT page_size; -$$; - -ALTER FUNCTION "public"."get_total_full_lines"("highline_id" "uuid", "page_number" integer, "page_size" integer) OWNER TO "postgres"; - -CREATE FUNCTION "public"."get_total_walked"("highline_id" "uuid", "page_number" integer, "page_size" integer) RETURNS TABLE("instagram" "text", "total_distance_walked" integer) - LANGUAGE "sql" - AS $$ - SELECT instagram, SUM(distance_walked) AS total_distance_walked - FROM entry - WHERE highline_id = get_total_walked.highline_id - AND distance_walked IS NOT NULL - GROUP BY instagram - ORDER BY total_distance_walked DESC - OFFSET (get_total_walked.page_number - 1) * get_total_walked.page_size - LIMIT page_size; -$$; - -ALTER FUNCTION "public"."get_total_walked"("highline_id" "uuid", "page_number" integer, "page_size" integer) OWNER TO "postgres"; - -SET default_tablespace = ''; - -SET default_table_access_method = "heap"; - -CREATE TABLE "public"."entry" ( - "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "created_at" timestamp with time zone DEFAULT "now"() NOT NULL, - "instagram" "text" NOT NULL, - "is_highliner" boolean NOT NULL, - "is_full_line" boolean, - "is_cadena" boolean, - "distance_walked" numeric, - "highline_id" "uuid" NOT NULL, - "witness" "text"[], - "crossing_time" numeric, - "comment" "text" -); - -ALTER TABLE "public"."entry" OWNER TO "postgres"; - -CREATE TABLE "public"."highline" ( - "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "created_at" timestamp with time zone DEFAULT "now"() NOT NULL, - "name" "text" NOT NULL, - "height" numeric NOT NULL, - "lenght" numeric NOT NULL, - "main_webbing" "text" DEFAULT ''::"text" NOT NULL, - "backup_webbing" "text" DEFAULT ''::"text" NOT NULL, - "description" "text", - "sector_id" bigint, - "cover_image" "text", - "riggers" "text"[] -); - -ALTER TABLE "public"."highline" OWNER TO "postgres"; - -CREATE TABLE "public"."sector" ( - "id" bigint NOT NULL, - "created_at" timestamp with time zone DEFAULT "now"(), - "description" "text", - "name" "text" NOT NULL -); - -ALTER TABLE "public"."sector" OWNER TO "postgres"; - -ALTER TABLE "public"."sector" ALTER COLUMN "id" ADD GENERATED BY DEFAULT AS IDENTITY ( - SEQUENCE NAME "public"."sector_id_seq" - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1 -); - -ALTER TABLE ONLY "public"."entry" - ADD CONSTRAINT "entry_pkey" PRIMARY KEY ("id"); - -ALTER TABLE ONLY "public"."highline" - ADD CONSTRAINT "highline_pkey" PRIMARY KEY ("id"); - -ALTER TABLE ONLY "public"."sector" - ADD CONSTRAINT "sector_pkey" PRIMARY KEY ("id"); - -ALTER TABLE ONLY "public"."entry" - ADD CONSTRAINT "entry_highline_id_fkey" FOREIGN KEY ("highline_id") REFERENCES "public"."highline"("id"); - -ALTER TABLE ONLY "public"."highline" - ADD CONSTRAINT "highline_sector_id_fkey" FOREIGN KEY ("sector_id") REFERENCES "public"."sector"("id"); - -CREATE POLICY "Enable insert for everyone" ON "public"."entry" FOR INSERT WITH CHECK (true); - -CREATE POLICY "Enable read access for all users" ON "public"."entry" FOR SELECT USING (true); - -CREATE POLICY "Enable read access for all users" ON "public"."highline" FOR SELECT USING (true); - -CREATE POLICY "Enable read access for all users" ON "public"."sector" FOR SELECT USING (true); - -ALTER TABLE "public"."entry" ENABLE ROW LEVEL SECURITY; - -ALTER TABLE "public"."highline" ENABLE ROW LEVEL SECURITY; - -CREATE POLICY "public_insert" ON "public"."highline" FOR INSERT TO "anon" WITH CHECK (true); - -ALTER TABLE "public"."sector" ENABLE ROW LEVEL SECURITY; - -GRANT USAGE ON SCHEMA "public" TO "postgres"; -GRANT USAGE ON SCHEMA "public" TO "anon"; -GRANT USAGE ON SCHEMA "public" TO "authenticated"; -GRANT USAGE ON SCHEMA "public" TO "service_role"; - -GRANT ALL ON FUNCTION "public"."get_total_cadenas"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "anon"; -GRANT ALL ON FUNCTION "public"."get_total_cadenas"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "authenticated"; -GRANT ALL ON FUNCTION "public"."get_total_cadenas"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "service_role"; - -GRANT ALL ON FUNCTION "public"."get_total_full_lines"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "anon"; -GRANT ALL ON FUNCTION "public"."get_total_full_lines"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "authenticated"; -GRANT ALL ON FUNCTION "public"."get_total_full_lines"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "service_role"; - -GRANT ALL ON FUNCTION "public"."get_total_walked"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "anon"; -GRANT ALL ON FUNCTION "public"."get_total_walked"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "authenticated"; -GRANT ALL ON FUNCTION "public"."get_total_walked"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "service_role"; - -GRANT ALL ON TABLE "public"."entry" TO "anon"; -GRANT ALL ON TABLE "public"."entry" TO "authenticated"; -GRANT ALL ON TABLE "public"."entry" TO "service_role"; - -GRANT ALL ON TABLE "public"."highline" TO "anon"; -GRANT ALL ON TABLE "public"."highline" TO "authenticated"; -GRANT ALL ON TABLE "public"."highline" TO "service_role"; - -GRANT ALL ON TABLE "public"."sector" TO "anon"; -GRANT ALL ON TABLE "public"."sector" TO "authenticated"; -GRANT ALL ON TABLE "public"."sector" TO "service_role"; - -GRANT ALL ON SEQUENCE "public"."sector_id_seq" TO "anon"; -GRANT ALL ON SEQUENCE "public"."sector_id_seq" TO "authenticated"; -GRANT ALL ON SEQUENCE "public"."sector_id_seq" TO "service_role"; - -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES TO "postgres"; -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES TO "anon"; -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES TO "authenticated"; -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES TO "service_role"; - -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "postgres"; -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "anon"; -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "authenticated"; -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "service_role"; - -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "postgres"; -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "anon"; -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "authenticated"; -ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "service_role"; - -RESET ALL; diff --git a/supabase/migrations/20230719130300_entry_cadena_number.sql b/supabase/migrations/20230719130300_entry_cadena_number.sql deleted file mode 100644 index fe21f23..0000000 --- a/supabase/migrations/20230719130300_entry_cadena_number.sql +++ /dev/null @@ -1,41 +0,0 @@ -ALTER TABLE "public"."entry" ADD COLUMN "cadenas" integer DEFAULT 0; -UPDATE "public"."entry" SET "cadenas" = CASE WHEN "is_cadena" = TRUE THEN 1 ELSE 0 END; - -ALTER TABLE "public"."entry" ADD COLUMN "full_lines" integer DEFAULT 0; -UPDATE "public"."entry" SET "full_lines" = CASE WHEN "is_full_line" = TRUE THEN 1 ELSE 0 END; - -ALTER TABLE "public"."entry" DROP COLUMN "is_cadena"; - -ALTER TABLE "public"."entry" DROP column "is_full_line"; - -set check_function_bodies = off; - -CREATE OR REPLACE FUNCTION public.get_total_cadenas(highline_id uuid, page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_cadenas integer) - LANGUAGE sql -AS $function$ SELECT instagram, SUM(cadenas) AS total_cadenas - FROM entry - WHERE highline_id = get_total_cadenas.highline_id - GROUP BY instagram - HAVING SUM(cadenas) > 0 - ORDER BY total_cadenas DESC - OFFSET (get_total_cadenas.page_number - 1) * get_total_cadenas.page_size - LIMIT get_total_cadenas.page_size; -$function$ -; - -CREATE OR REPLACE FUNCTION public.get_total_full_lines(highline_id uuid, page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_full_lines integer) - LANGUAGE sql -AS $function$ SELECT instagram, SUM(full_lines) AS total_full_lines - FROM entry - WHERE highline_id = get_total_full_lines.highline_id - GROUP BY instagram - HAVING SUM(full_lines) > 0 - ORDER BY total_full_lines DESC - OFFSET (get_total_full_lines.page_number - 1) * get_total_full_lines.page_size - LIMIT get_total_full_lines.page_size; -$function$ -; - - diff --git a/supabase/migrations/20231029094600_profile.sql b/supabase/migrations/20231029094600_profile.sql deleted file mode 100644 index f112d53..0000000 --- a/supabase/migrations/20231029094600_profile.sql +++ /dev/null @@ -1,79 +0,0 @@ -create table "public"."profiles" ( - "id" uuid not null, - "name" character varying, - "description" character varying, - "birthday" date, - "username" character varying -); - - -alter table "public"."profiles" enable row level security; - -CREATE UNIQUE INDEX profiles_pkey ON public.profiles USING btree (id); - -CREATE UNIQUE INDEX profiles_username_key ON public.profiles USING btree (username); - -alter table "public"."profiles" add constraint "profiles_pkey" PRIMARY KEY using index "profiles_pkey"; - -alter table "public"."profiles" add constraint "profiles_id_fkey" FOREIGN KEY (id) REFERENCES auth.users(id) ON DELETE CASCADE not valid; - -alter table "public"."profiles" validate constraint "profiles_id_fkey"; - -alter table "public"."profiles" add constraint "profiles_username_key" UNIQUE using index "profiles_username_key"; - -set check_function_bodies = off; - -CREATE OR REPLACE FUNCTION public.handle_new_user() - RETURNS trigger - LANGUAGE plpgsql - SECURITY DEFINER - SET search_path TO 'public' -AS $function$ -begin - insert into public.profiles (id) - values (new.id); - return new; -end; -$function$ -; - -CREATE OR REPLACE FUNCTION public.profile_stats(username text) - RETURNS TABLE(total_distance_walked numeric, total_cadenas integer, total_full_lines integer) - LANGUAGE sql -AS $function$ - SELECT - sum(distance_walked) as total_distance_walked, - sum(cadenas) as total_cadenas, - sum(full_lines) as total_full_lines - FROM entry - WHERE - instagram = username; -$function$ -; - -create policy "Public profiles are viewable by everyone." -on "public"."profiles" -as permissive -for select -to public -using (true); - - -create policy "Users can insert their own profile." -on "public"."profiles" -as permissive -for insert -to public -with check ((auth.uid() = id)); - - -create policy "Users can update own profile." -on "public"."profiles" -as permissive -for update -to public -using ((auth.uid() = id)); - - - - diff --git a/supabase/migrations/20231030152535_auth_trigger.sql b/supabase/migrations/20231030152535_auth_trigger.sql deleted file mode 100644 index baae3d6..0000000 --- a/supabase/migrations/20231030152535_auth_trigger.sql +++ /dev/null @@ -1,4 +0,0 @@ --- trigger the function every time a user is created -create trigger on_auth_user_created - after insert on auth.users - for each row execute procedure public.handle_new_user(); \ No newline at end of file diff --git a/supabase/migrations/20231030163000_auth_policies.sql b/supabase/migrations/20231030163000_auth_policies.sql deleted file mode 100644 index e240f40..0000000 --- a/supabase/migrations/20231030163000_auth_policies.sql +++ /dev/null @@ -1,72 +0,0 @@ -drop policy "Enable insert for everyone" on "public"."entry"; - -drop policy "Enable read access for all users" on "public"."entry"; - -drop policy "Enable read access for all users" on "public"."highline"; - -drop policy "public_insert" on "public"."highline"; - -drop policy "Public profiles are viewable by everyone." on "public"."profiles"; - -drop policy "Users can update own profile." on "public"."profiles"; - -drop policy "Enable read access for all users" on "public"."sector"; - -create policy "Enable insert for everyone" -on "public"."entry" -as permissive -for insert -to anon, authenticated -with check (true); - - -create policy "Enable read access for all users" -on "public"."entry" -as permissive -for select -to anon, authenticated -using (true); - - -create policy "Enable read access for all users" -on "public"."highline" -as permissive -for select -to anon, authenticated -using (true); - - -create policy "public_insert" -on "public"."highline" -as permissive -for insert -to anon, authenticated -with check (true); - - -create policy "Public profiles are viewable by everyone." -on "public"."profiles" -as permissive -for select -to anon, authenticated -using (true); - - -create policy "Users can update own profile." -on "public"."profiles" -as permissive -for update -to authenticated -using ((auth.uid() = id)); - - -create policy "Enable read access for all users" -on "public"."sector" -as permissive -for select -to anon, authenticated -using (true); - - - - diff --git a/supabase/migrations/20231031140730_profile_picture.sql b/supabase/migrations/20231031140730_profile_picture.sql deleted file mode 100644 index 4888376..0000000 --- a/supabase/migrations/20231031140730_profile_picture.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table "public"."profiles" add column "profile_picture" text; - - diff --git a/supabase/migrations/20240126152956_remote_schema.sql b/supabase/migrations/20240126152956_remote_schema.sql deleted file mode 100644 index e4ce416..0000000 --- a/supabase/migrations/20240126152956_remote_schema.sql +++ /dev/null @@ -1,22 +0,0 @@ -create extension if not exists "postgis" with schema "extensions"; - - -alter table "public"."highline" add column "anchor_a" geography(Point,4326) default NULL::geography; - -alter table "public"."highline" add column "anchor_b" geography(Point,4326) default NULL::geography; - -CREATE INDEX highlines_geo_index ON public.highline USING gist (anchor_a); - -set check_function_bodies = off; - -CREATE OR REPLACE FUNCTION public.highlines_in_view(min_lat double precision, min_long double precision, max_lat double precision, max_long double precision) - RETURNS TABLE(id uuid, name text, lat double precision, long double precision) - LANGUAGE sql -AS $function$ - select id, name, st_y(anchor_a::geometry) as lat, st_x(anchor_a::geometry) as long - from public.highline - where anchor_a && ST_SetSRID(ST_MakeBox2D(ST_Point(min_long, min_lat), ST_Point(max_long, max_lat)), 4326) -$function$ -; - - diff --git a/supabase/migrations/20240226160441_favorite_highline.sql b/supabase/migrations/20240226160441_favorite_highline.sql deleted file mode 100644 index 1807e83..0000000 --- a/supabase/migrations/20240226160441_favorite_highline.sql +++ /dev/null @@ -1,47 +0,0 @@ -create table "public"."favorite_highline" ( - "id" uuid not null default gen_random_uuid(), - "created_at" timestamp with time zone not null default now(), - "highline_id" uuid not null, - "profile_id" uuid not null -); - - -alter table "public"."favorite_highline" enable row level security; - -CREATE UNIQUE INDEX favorite_highline_pkey ON public.favorite_highline USING btree (id); - -alter table "public"."favorite_highline" add constraint "favorite_highline_pkey" PRIMARY KEY using index "favorite_highline_pkey"; - -alter table "public"."favorite_highline" add constraint "favorite_highline_highline_id_fkey" FOREIGN KEY (highline_id) REFERENCES highline(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; - -alter table "public"."favorite_highline" validate constraint "favorite_highline_highline_id_fkey"; - -alter table "public"."favorite_highline" add constraint "favorite_highline_profile_id_fkey" FOREIGN KEY (profile_id) REFERENCES profiles(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; - -alter table "public"."favorite_highline" validate constraint "favorite_highline_profile_id_fkey"; - -create policy "Enable delete for users based on profile_id" -on "public"."favorite_highline" -as permissive -for delete -to public -using ((auth.uid() = profile_id)); - - -create policy "Enable insert for users based on profile_id" -on "public"."favorite_highline" -as permissive -for insert -to public -with check ((auth.uid() = profile_id)); - - -create policy "Enable read users based on profile_id" -on "public"."favorite_highline" -as permissive -for select -to public -using ((auth.uid() = profile_id)); - - - diff --git a/supabase/migrations/20240329190725_highline_anchor_b.sql b/supabase/migrations/20240329190725_highline_anchor_b.sql deleted file mode 100644 index 4779b87..0000000 --- a/supabase/migrations/20240329190725_highline_anchor_b.sql +++ /dev/null @@ -1,15 +0,0 @@ -drop function if exists "public"."highlines_in_view"(min_lat double precision, min_long double precision, max_lat double precision, max_long double precision); - -set check_function_bodies = off; - -CREATE OR REPLACE FUNCTION public.highlines_in_view(min_lat double precision, min_long double precision, max_lat double precision, max_long double precision) - RETURNS TABLE(id uuid, name text, anchor_a_lat double precision, anchor_a_long double precision, anchor_b_lat double precision, anchor_b_long double precision) - LANGUAGE sql -AS $function$ - select id, name, st_y(anchor_a::geometry) as anchor_a_lat, st_x(anchor_a::geometry) as anchor_b_long, st_y(anchor_b::geometry) as anchor_b_lat, st_x(anchor_b::geometry) as anchor_b_long - from public.highline - where anchor_a && ST_SetSRID(ST_MakeBox2D(ST_Point(min_long, min_lat), ST_Point(max_long, max_lat)), 4326) -$function$ -; - - diff --git a/supabase/migrations/20240331164414_get_highline.sql b/supabase/migrations/20240331164414_get_highline.sql deleted file mode 100644 index 99eb102..0000000 --- a/supabase/migrations/20240331164414_get_highline.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE OR REPLACE FUNCTION public.get_highline(searchid uuid DEFAULT NULL::uuid, searchname text DEFAULT ''::text, pagesize integer DEFAULT NULL::integer, pageparam integer DEFAULT NULL::integer, userid uuid DEFAULT NULL::uuid) - RETURNS TABLE(id uuid, created_at timestamp with time zone, name text, height numeric, lenght numeric, main_webbing text, backup_webbing text, description text, sector_id bigint, cover_image text, riggers text[], anchor_a_long double precision, anchor_a_lat double precision, anchor_b_long double precision, anchor_b_lat double precision, is_favorite boolean) - LANGUAGE plpgsql -AS $function$ -BEGIN - RETURN QUERY - SELECT - h.id, - h.created_at, - h.name, - h.height, - h.lenght, - h.main_webbing, - h.backup_webbing, - h.description, - h.sector_id, - h.cover_image, - h.riggers, - st_x(anchor_a::geometry) as anchor_a_long, - st_y(anchor_a::geometry) as anchor_a_lat, - st_x(anchor_b::geometry) as anchor_b_long, - st_y(anchor_b::geometry) as anchor_b_lat, - EXISTS ( - SELECT 1 - FROM public.favorite_highline fh - WHERE fh.highline_id = h.id - AND fh.profile_id = userId - ) as is_favorite - FROM - public.highline h - WHERE - (searchId IS NULL OR h.id = searchId) - AND (searchName = '' OR h.name ilike '%' || searchName || '%') - LIMIT pageSize OFFSET (pageParam - 1) * pageSize; -END; -$function$ -; - - diff --git a/supabase/migrations/20240404125731_update_highline_rls.sql b/supabase/migrations/20240404125731_update_highline_rls.sql deleted file mode 100644 index 26a5bb4..0000000 --- a/supabase/migrations/20240404125731_update_highline_rls.sql +++ /dev/null @@ -1,9 +0,0 @@ -create policy "Enable update for all users" -on "public"."highline" -as permissive -for update -to public -using (true); - - - diff --git a/supabase/migrations/20240417183631_entry_with_profile_picture.sql b/supabase/migrations/20240417183631_entry_with_profile_picture.sql deleted file mode 100644 index 17f1bc9..0000000 --- a/supabase/migrations/20240417183631_entry_with_profile_picture.sql +++ /dev/null @@ -1,70 +0,0 @@ -drop function if exists "public"."get_total_cadenas"(highline_id uuid, page_number integer, page_size integer); - -drop function if exists "public"."get_total_full_lines"(highline_id uuid, page_number integer, page_size integer); - -drop function if exists "public"."get_total_walked"(highline_id uuid, page_number integer, page_size integer); - -set check_function_bodies = off; - -CREATE OR REPLACE FUNCTION public.get_crossing_time(highline_id uuid, page_number integer, page_size integer) - RETURNS TABLE(instagram text, crossing_time integer, profile_picture text) - LANGUAGE sql -AS $function$ - select e.instagram, e.crossing_time, p.profile_picture - from entry e - JOIN profiles p on e.instagram = p.username - where highline_id = get_crossing_time.highline_id - order by e.crossing_time asc - OFFSET (get_crossing_time.page_number - 1) * get_crossing_time.page_size - LIMIT get_crossing_time.page_size; -$function$ -; - -CREATE OR REPLACE FUNCTION public.get_total_cadenas(highline_id uuid, page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_cadenas integer, profile_picture text) - LANGUAGE sql -AS $function$ SELECT e.instagram, SUM(e.cadenas) AS total_cadenas, p.profile_picture - FROM entry e - JOIN profiles p on e.instagram = p.username - WHERE highline_id = get_total_cadenas.highline_id - GROUP BY e.instagram, p.profile_picture - HAVING SUM(e.cadenas) > 0 - ORDER BY total_cadenas DESC - OFFSET (get_total_cadenas.page_number - 1) * get_total_cadenas.page_size - LIMIT get_total_cadenas.page_size; -$function$ -; - -CREATE OR REPLACE FUNCTION public.get_total_full_lines(highline_id uuid, page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_full_lines integer, profile_picture text) - LANGUAGE sql -AS $function$ - SELECT e.instagram, SUM(e.full_lines) AS total_full_lines, p.profile_picture - FROM entry e - JOIN profiles p ON e.instagram = p.username - WHERE e.highline_id = get_total_full_lines.highline_id - GROUP BY e.instagram, p.profile_picture - HAVING SUM(e.full_lines) > 0 - ORDER BY total_full_lines DESC - OFFSET (get_total_full_lines.page_number - 1) * get_total_full_lines.page_size - LIMIT get_total_full_lines.page_size; -$function$ -; - -CREATE OR REPLACE FUNCTION public.get_total_walked(highline_id uuid, page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_distance_walked integer, profile_picture text) - LANGUAGE sql -AS $function$ - SELECT e.instagram, SUM(e.distance_walked) AS total_distance_walked, p.profile_picture - FROM entry e - JOIN profiles p on e.instagram = p.username - WHERE highline_id = get_total_walked.highline_id - AND distance_walked IS NOT NULL - GROUP BY e.instagram, p.profile_picture - ORDER BY total_distance_walked DESC - OFFSET (get_total_walked.page_number - 1) * get_total_walked.page_size - LIMIT page_size; -$function$ -; - - diff --git a/supabase/migrations/20240417190644_fix_entry_whitout_associated_profile.sql b/supabase/migrations/20240417190644_fix_entry_whitout_associated_profile.sql deleted file mode 100644 index 54de4ca..0000000 --- a/supabase/migrations/20240417190644_fix_entry_whitout_associated_profile.sql +++ /dev/null @@ -1,64 +0,0 @@ -set check_function_bodies = off; - -CREATE OR REPLACE FUNCTION public.get_crossing_time(highline_id uuid, page_number integer, page_size integer) - RETURNS TABLE(instagram text, crossing_time integer, profile_picture text) - LANGUAGE sql -AS $function$ - select e.instagram, e.crossing_time, COALESCE(p.profile_picture, '') AS profile_picture - from entry e - LEFT JOIN profiles p on e.instagram = p.username - where highline_id = get_crossing_time.highline_id - order by e.crossing_time asc - OFFSET (get_crossing_time.page_number - 1) * get_crossing_time.page_size - LIMIT get_crossing_time.page_size; -$function$ -; - -CREATE OR REPLACE FUNCTION public.get_total_cadenas(highline_id uuid, page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_cadenas integer, profile_picture text) - LANGUAGE sql -AS $function$ SELECT e.instagram, SUM(e.cadenas) AS total_cadenas, COALESCE(p.profile_picture, '') AS profile_picture - FROM entry e - LEFT JOIN profiles p on e.instagram = p.username - WHERE highline_id = get_total_cadenas.highline_id - GROUP BY e.instagram, p.profile_picture - HAVING SUM(e.cadenas) > 0 - ORDER BY total_cadenas DESC - OFFSET (get_total_cadenas.page_number - 1) * get_total_cadenas.page_size - LIMIT get_total_cadenas.page_size; -$function$ -; - -CREATE OR REPLACE FUNCTION public.get_total_full_lines(highline_id uuid, page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_full_lines integer, profile_picture text) - LANGUAGE sql -AS $function$ - SELECT e.instagram, SUM(e.full_lines) AS total_full_lines, COALESCE(p.profile_picture, '') AS profile_picture - FROM entry e - LEFT JOIN profiles p ON e.instagram = p.username - WHERE e.highline_id = get_total_full_lines.highline_id - GROUP BY e.instagram, p.profile_picture - HAVING SUM(e.full_lines) > 0 - ORDER BY total_full_lines DESC - OFFSET (get_total_full_lines.page_number - 1) * get_total_full_lines.page_size - LIMIT get_total_full_lines.page_size; -$function$ -; - -CREATE OR REPLACE FUNCTION public.get_total_walked(highline_id uuid, page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_distance_walked integer, profile_picture text) - LANGUAGE sql -AS $function$ - SELECT e.instagram, SUM(e.distance_walked) AS total_distance_walked, COALESCE(p.profile_picture, '') AS profile_picture - FROM entry e - LEFT JOIN profiles p on e.instagram = p.username - WHERE e.highline_id = get_total_walked.highline_id - AND e.distance_walked IS NOT NULL - GROUP BY e.instagram, p.profile_picture - ORDER BY total_distance_walked DESC - OFFSET (get_total_walked.page_number - 1) * get_total_walked.page_size - LIMIT page_size; -$function$ -; - - diff --git a/supabase/migrations/20240520004328_multiple_highline_ranking.sql b/supabase/migrations/20240520004328_multiple_highline_ranking.sql deleted file mode 100644 index ef03785..0000000 --- a/supabase/migrations/20240520004328_multiple_highline_ranking.sql +++ /dev/null @@ -1,70 +0,0 @@ -set check_function_bodies = off; - -DROP FUNCTION IF EXISTS public.get_total_cadenas ( - highline_id UUID, - page_number INTEGER, - page_size INTEGER -); - -CREATE OR REPLACE FUNCTION public.get_total_cadenas(highline_ids uuid[], page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_cadenas integer, profile_picture text) - LANGUAGE sql -AS $function$ -SELECT e.instagram, SUM(e.cadenas) AS total_cadenas, COALESCE(p.profile_picture, '') AS profile_picture -FROM entry e -LEFT JOIN profiles p ON e.instagram = p.username -WHERE e.highline_id = ANY(get_total_cadenas.highline_ids) -GROUP BY e.instagram, p.profile_picture -HAVING SUM(e.cadenas) > 0 -ORDER BY total_cadenas DESC -OFFSET (get_total_cadenas.page_number - 1) * get_total_cadenas.page_size -LIMIT get_total_cadenas.page_size; -$function$ -; - - -DROP FUNCTION IF EXISTS public.get_total_full_lines ( - highline_id UUID, - page_number INTEGER, - page_size INTEGER -); - -CREATE OR REPLACE FUNCTION public.get_total_full_lines(highline_ids uuid[], page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_full_lines integer, profile_picture text) - LANGUAGE sql -AS $function$ -SELECT e.instagram, SUM(e.full_lines) AS total_full_lines, COALESCE(p.profile_picture, '') AS profile_picture -FROM entry e -LEFT JOIN profiles p ON e.instagram = p.username -WHERE e.highline_id = ANY(get_total_full_lines.highline_ids) -GROUP BY e.instagram, p.profile_picture -HAVING SUM(e.full_lines) > 0 -ORDER BY total_full_lines DESC -OFFSET (get_total_full_lines.page_number - 1) * get_total_full_lines.page_size -LIMIT get_total_full_lines.page_size; -$function$ -; - -DROP FUNCTION IF EXISTS public.get_total_walked ( - highline_id UUID, - page_number INTEGER, - page_size INTEGER -); - -CREATE OR REPLACE FUNCTION public.get_total_walked(highline_ids uuid[], page_number integer, page_size integer) - RETURNS TABLE(instagram text, total_distance_walked integer, profile_picture text) - LANGUAGE sql -AS $function$ -SELECT e.instagram, SUM(e.distance_walked) AS total_distance_walked, COALESCE(p.profile_picture, '') AS profile_picture -FROM entry e -LEFT JOIN profiles p ON e.instagram = p.username -WHERE e.highline_id = ANY(get_total_walked.highline_ids) -AND e.distance_walked IS NOT NULL -GROUP BY e.instagram, p.profile_picture -ORDER BY total_distance_walked DESC -OFFSET (get_total_walked.page_number - 1) * get_total_walked.page_size -LIMIT page_size; -$function$ -; - - diff --git a/supabase/migrations/20240522132228_get_multiple_highline.sql b/supabase/migrations/20240522132228_get_multiple_highline.sql deleted file mode 100644 index f7c0372..0000000 --- a/supabase/migrations/20240522132228_get_multiple_highline.sql +++ /dev/null @@ -1,43 +0,0 @@ -drop function if exists "public"."get_highline"(searchid uuid, searchname text, pagesize integer, pageparam integer, userid uuid); - -set check_function_bodies = off; - -CREATE OR REPLACE FUNCTION public.get_highline(searchid uuid[] DEFAULT NULL::uuid[], searchname text DEFAULT ''::text, pagesize integer DEFAULT NULL::integer, pageparam integer DEFAULT NULL::integer, userid uuid DEFAULT NULL::uuid) - RETURNS TABLE(id uuid, created_at timestamp with time zone, name text, height numeric, lenght numeric, main_webbing text, backup_webbing text, description text, sector_id bigint, cover_image text, riggers text[], anchor_a_long double precision, anchor_a_lat double precision, anchor_b_long double precision, anchor_b_lat double precision, is_favorite boolean) - LANGUAGE plpgsql -AS $function$ -BEGIN - RETURN QUERY - SELECT - h.id, - h.created_at, - h.name, - h.height, - h.lenght, - h.main_webbing, - h.backup_webbing, - h.description, - h.sector_id, - h.cover_image, - h.riggers, - st_x(anchor_a::geometry) as anchor_a_long, - st_y(anchor_a::geometry) as anchor_a_lat, - st_x(anchor_b::geometry) as anchor_b_long, - st_y(anchor_b::geometry) as anchor_b_lat, - EXISTS ( - SELECT 1 - FROM public.favorite_highline fh - WHERE fh.highline_id = h.id - AND fh.profile_id = userId - ) as is_favorite - FROM - public.highline h - WHERE - (searchId IS NULL OR h.id = ANY(searchId)) - AND (searchName = '' OR h.name ilike '%' || searchName || '%') - LIMIT pageSize OFFSET (pageParam - 1) * pageSize; -END; -$function$ -; - - diff --git a/supabase/migrations/20240522152724_ranking_with_date_range.sql b/supabase/migrations/20240522152724_ranking_with_date_range.sql deleted file mode 100644 index 1dc75b8..0000000 --- a/supabase/migrations/20240522152724_ranking_with_date_range.sql +++ /dev/null @@ -1,84 +0,0 @@ -set check_function_bodies = off; - -DROP FUNCTION IF EXISTS public.get_total_cadenas ( - highline_ids UUID[], - page_number INTEGER, - page_size INTEGER -); - -CREATE OR REPLACE FUNCTION public.get_total_cadenas(highline_ids uuid[], page_number integer, page_size integer, start_date timestamp with time zone DEFAULT NULL::timestamp with time zone, end_date timestamp with time zone DEFAULT NULL::timestamp with time zone) - RETURNS TABLE(instagram text, total_cadenas integer, profile_picture text) - LANGUAGE plpgsql -AS $function$ -BEGIN -RETURN QUERY -SELECT e.instagram, SUM(e.cadenas)::integer AS total_cadenas, COALESCE(p.profile_picture, '') AS profile_picture -FROM public.entry e -LEFT JOIN public.profiles p ON e.instagram = p.username -WHERE e.highline_id = ANY(get_total_cadenas.highline_ids) -AND (e.created_at >= COALESCE(start_date, '1970-01-01'::timestamp) OR start_date IS NULL) -AND (e.created_at <= COALESCE(end_date, now()) OR end_date IS NULL) -GROUP BY e.instagram, p.profile_picture -HAVING SUM(e.cadenas) > 0 -ORDER BY total_cadenas DESC -OFFSET (get_total_cadenas.page_number - 1) * get_total_cadenas.page_size -LIMIT get_total_cadenas.page_size; -END; -$function$ -; - -DROP FUNCTION IF EXISTS public.get_total_full_lines ( - highline_ids UUID[], - page_number INTEGER, - page_size INTEGER -); - -CREATE OR REPLACE FUNCTION public.get_total_full_lines(highline_ids uuid[], page_number integer, page_size integer, start_date timestamp with time zone DEFAULT NULL::timestamp with time zone, end_date timestamp with time zone DEFAULT NULL::timestamp with time zone) - RETURNS TABLE(instagram text, total_full_lines integer, profile_picture text) - LANGUAGE plpgsql -AS $function$ -BEGIN -RETURN QUERY -SELECT e.instagram, SUM(e.full_lines)::integer AS total_full_lines, COALESCE(p.profile_picture, '') AS profile_picture -FROM public.entry e -LEFT JOIN public.profiles p ON e.instagram = p.username -WHERE e.highline_id = ANY(get_total_full_lines.highline_ids) -AND (e.created_at >= COALESCE(start_date, '1970-01-01'::timestamp) OR start_date IS NULL) -AND (e.created_at <= COALESCE(end_date, now()) OR end_date IS NULL) -GROUP BY e.instagram, p.profile_picture -HAVING SUM(e.full_lines) > 0 -ORDER BY total_full_lines DESC -OFFSET (get_total_full_lines.page_number - 1) * get_total_full_lines.page_size -LIMIT get_total_full_lines.page_size; -END; -$function$ -; - -DROP FUNCTION IF EXISTS public.get_total_walked ( - highline_ids UUID[], - page_number INTEGER, - page_size INTEGER -); - -CREATE OR REPLACE FUNCTION public.get_total_walked(highline_ids uuid[], page_number integer, page_size integer, start_date timestamp with time zone DEFAULT NULL::timestamp with time zone, end_date timestamp with time zone DEFAULT NULL::timestamp with time zone) - RETURNS TABLE(instagram text, total_distance_walked integer, profile_picture text) - LANGUAGE plpgsql -AS $function$ -BEGIN -RETURN QUERY -SELECT e.instagram, SUM(e.distance_walked)::integer AS total_distance_walked, COALESCE(p.profile_picture, '') AS profile_picture -FROM public.entry e -LEFT JOIN public.profiles p ON e.instagram = p.username -WHERE e.highline_id = ANY(get_total_walked.highline_ids) -AND (e.created_at >= COALESCE(start_date, '1970-01-01'::timestamp) OR start_date IS NULL) -AND (e.created_at <= COALESCE(end_date, now()) OR end_date IS NULL) -AND e.distance_walked IS NOT NULL -GROUP BY e.instagram, p.profile_picture -ORDER BY total_distance_walked DESC -OFFSET (get_total_walked.page_number - 1) * get_total_walked.page_size -LIMIT page_size; -END; -$function$ -; - - diff --git a/supabase/migrations/20250206202200_remote_schema.sql b/supabase/migrations/20250206202200_remote_schema.sql new file mode 100644 index 0000000..3d261be --- /dev/null +++ b/supabase/migrations/20250206202200_remote_schema.sql @@ -0,0 +1,627 @@ + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +CREATE SCHEMA IF NOT EXISTS "gis"; + +ALTER SCHEMA "gis" OWNER TO "postgres"; + +CREATE EXTENSION IF NOT EXISTS "pgsodium" WITH SCHEMA "pgsodium"; + +COMMENT ON SCHEMA "public" IS 'standard public schema'; + +CREATE EXTENSION IF NOT EXISTS "pg_graphql" WITH SCHEMA "graphql"; + +CREATE EXTENSION IF NOT EXISTS "pg_stat_statements" WITH SCHEMA "extensions"; + +CREATE EXTENSION IF NOT EXISTS "pgcrypto" WITH SCHEMA "extensions"; + +CREATE EXTENSION IF NOT EXISTS "pgjwt" WITH SCHEMA "extensions"; + +CREATE EXTENSION IF NOT EXISTS "postgis" WITH SCHEMA "extensions"; + +CREATE EXTENSION IF NOT EXISTS "supabase_vault" WITH SCHEMA "vault"; + +CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA "extensions"; + +CREATE TYPE "public"."material_enum" AS ENUM ( + 'nylon', + 'dyneema', + 'polyester' +); + +ALTER TYPE "public"."material_enum" OWNER TO "postgres"; + +CREATE TYPE "public"."weave_enum" AS ENUM ( + 'flat', + 'tubular' +); + +ALTER TYPE "public"."weave_enum" OWNER TO "postgres"; + +CREATE TYPE "public"."webbing_type" AS ENUM ( + 'main', + 'backup' +); + +ALTER TYPE "public"."webbing_type" OWNER TO "postgres"; + +CREATE OR REPLACE FUNCTION "public"."get_crossing_time"("highline_id" "uuid", "page_number" integer, "page_size" integer) RETURNS TABLE("instagram" "text", "crossing_time" integer, "profile_picture" "text") + LANGUAGE "sql" + AS $$ + select e.instagram, e.crossing_time, COALESCE(p.profile_picture, '') AS profile_picture + from entry e + LEFT JOIN profiles p on e.instagram = p.username + where highline_id = get_crossing_time.highline_id + order by e.crossing_time asc + OFFSET (get_crossing_time.page_number - 1) * get_crossing_time.page_size + LIMIT get_crossing_time.page_size; +$$; + +ALTER FUNCTION "public"."get_crossing_time"("highline_id" "uuid", "page_number" integer, "page_size" integer) OWNER TO "postgres"; + +CREATE OR REPLACE FUNCTION "public"."get_highline"("searchid" "uuid"[] DEFAULT NULL::"uuid"[], "searchname" "text" DEFAULT ''::"text", "pagesize" integer DEFAULT NULL::integer, "pageparam" integer DEFAULT NULL::integer, "userid" "uuid" DEFAULT NULL::"uuid") RETURNS TABLE("id" "uuid", "created_at" timestamp with time zone, "name" "text", "height" numeric, "length" numeric, "description" "text", "sector_id" bigint, "cover_image" "text", "anchor_a_long" double precision, "anchor_a_lat" double precision, "anchor_b_long" double precision, "anchor_b_lat" double precision, "is_favorite" boolean, "status" "text") + LANGUAGE "plpgsql" SECURITY DEFINER + SET "search_path" TO '' + AS $$ +BEGIN + RETURN QUERY + SELECT + h.id, + h.created_at, + h.name, + h.height, + h.length, + h.description, + h.sector_id, + h.cover_image, + extensions.st_x(anchor_a::extensions.geometry) as anchor_a_long, + extensions.st_y(anchor_a::extensions.geometry) as anchor_a_lat, + extensions.st_x(anchor_b::extensions.geometry) as anchor_b_long, + extensions.st_y(anchor_b::extensions.geometry) as anchor_b_lat, + EXISTS ( + SELECT 1 + FROM public.favorite_highline fh + WHERE fh.highline_id = h.id + AND fh.profile_id = userid + ) as is_favorite, + CASE + WHEN r.rig_date IS NOT NULL AND r.is_rigged = false THEN 'planned' + WHEN r.rig_date IS NOT NULL AND r.is_rigged = true THEN 'rigged' + ELSE 'unrigged' + END as status + FROM + public.highline h + LEFT JOIN ( + SELECT rig_date, unrigged_at, is_rigged, highline_id + FROM public.rig_setup + ORDER BY rig_date DESC + LIMIT 1 + ) r ON r.highline_id = h.id + WHERE + (searchid IS NULL OR h.id = ANY(searchid)) + AND (searchname = '' OR h.name ILIKE '%' || searchname || '%') + LIMIT pagesize OFFSET (pageparam - 1) * pagesize; +END; +$$; + +ALTER FUNCTION "public"."get_highline"("searchid" "uuid"[], "searchname" "text", "pagesize" integer, "pageparam" integer, "userid" "uuid") OWNER TO "postgres"; + +CREATE OR REPLACE FUNCTION "public"."get_total_cadenas"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone DEFAULT NULL::timestamp with time zone, "end_date" timestamp with time zone DEFAULT NULL::timestamp with time zone) RETURNS TABLE("instagram" "text", "total_cadenas" integer, "profile_picture" "text") + LANGUAGE "plpgsql" + AS $$ +BEGIN +RETURN QUERY +SELECT e.instagram, SUM(e.cadenas)::integer AS total_cadenas, COALESCE(p.profile_picture, '') AS profile_picture +FROM public.entry e +LEFT JOIN public.profiles p ON e.instagram = p.username +WHERE e.highline_id = ANY(get_total_cadenas.highline_ids) +AND (e.created_at >= COALESCE(start_date, '1970-01-01'::timestamp) OR start_date IS NULL) +AND (e.created_at <= COALESCE(end_date, now()) OR end_date IS NULL) +GROUP BY e.instagram, p.profile_picture +HAVING SUM(e.cadenas) > 0 +ORDER BY total_cadenas DESC +OFFSET (get_total_cadenas.page_number - 1) * get_total_cadenas.page_size +LIMIT get_total_cadenas.page_size; +END; +$$; + +ALTER FUNCTION "public"."get_total_cadenas"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) OWNER TO "postgres"; + +CREATE OR REPLACE FUNCTION "public"."get_total_full_lines"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone DEFAULT NULL::timestamp with time zone, "end_date" timestamp with time zone DEFAULT NULL::timestamp with time zone) RETURNS TABLE("instagram" "text", "total_full_lines" integer, "profile_picture" "text") + LANGUAGE "plpgsql" + AS $$ +BEGIN +RETURN QUERY +SELECT e.instagram, SUM(e.full_lines)::integer AS total_full_lines, COALESCE(p.profile_picture, '') AS profile_picture +FROM public.entry e +LEFT JOIN public.profiles p ON e.instagram = p.username +WHERE e.highline_id = ANY(get_total_full_lines.highline_ids) +AND (e.created_at >= COALESCE(start_date, '1970-01-01'::timestamp) OR start_date IS NULL) +AND (e.created_at <= COALESCE(end_date, now()) OR end_date IS NULL) +GROUP BY e.instagram, p.profile_picture +HAVING SUM(e.full_lines) > 0 +ORDER BY total_full_lines DESC +OFFSET (get_total_full_lines.page_number - 1) * get_total_full_lines.page_size +LIMIT get_total_full_lines.page_size; +END; +$$; + +ALTER FUNCTION "public"."get_total_full_lines"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) OWNER TO "postgres"; + +CREATE OR REPLACE FUNCTION "public"."get_total_walked"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone DEFAULT NULL::timestamp with time zone, "end_date" timestamp with time zone DEFAULT NULL::timestamp with time zone) RETURNS TABLE("instagram" "text", "total_distance_walked" integer, "profile_picture" "text") + LANGUAGE "plpgsql" + AS $$ +BEGIN +RETURN QUERY +SELECT e.instagram, SUM(e.distance_walked)::integer AS total_distance_walked, COALESCE(p.profile_picture, '') AS profile_picture +FROM public.entry e +LEFT JOIN public.profiles p ON e.instagram = p.username +WHERE e.highline_id = ANY(get_total_walked.highline_ids) +AND (e.created_at >= COALESCE(start_date, '1970-01-01'::timestamp) OR start_date IS NULL) +AND (e.created_at <= COALESCE(end_date, now()) OR end_date IS NULL) +AND e.distance_walked IS NOT NULL +GROUP BY e.instagram, p.profile_picture +ORDER BY total_distance_walked DESC +OFFSET (get_total_walked.page_number - 1) * get_total_walked.page_size +LIMIT page_size; +END; +$$; + +ALTER FUNCTION "public"."get_total_walked"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) OWNER TO "postgres"; + +CREATE OR REPLACE FUNCTION "public"."handle_new_user"() RETURNS "trigger" + LANGUAGE "plpgsql" SECURITY DEFINER + SET "search_path" TO 'public' + AS $$ +begin + insert into public.profiles (id) + values (new.id); + return new; +end; +$$; + +ALTER FUNCTION "public"."handle_new_user"() OWNER TO "postgres"; + +CREATE OR REPLACE FUNCTION "public"."highlines_in_view"("min_lat" double precision, "min_long" double precision, "max_lat" double precision, "max_long" double precision) RETURNS TABLE("id" "uuid", "name" "text", "anchor_a_lat" double precision, "anchor_a_long" double precision, "anchor_b_lat" double precision, "anchor_b_long" double precision) + LANGUAGE "sql" + AS $$ + select id, name, st_y(anchor_a::geometry) as anchor_a_lat, st_x(anchor_a::geometry) as anchor_b_long, st_y(anchor_b::geometry) as anchor_b_lat, st_x(anchor_b::geometry) as anchor_b_long + from public.highline + where anchor_a && ST_SetSRID(ST_MakeBox2D(ST_Point(min_long, min_lat), ST_Point(max_long, max_lat)), 4326) +$$; + +ALTER FUNCTION "public"."highlines_in_view"("min_lat" double precision, "min_long" double precision, "max_lat" double precision, "max_long" double precision) OWNER TO "postgres"; + +CREATE OR REPLACE FUNCTION "public"."profile_stats"("username" "text") RETURNS TABLE("total_distance_walked" numeric, "total_cadenas" integer, "total_full_lines" integer) + LANGUAGE "sql" + AS $$ + SELECT + sum(distance_walked) as total_distance_walked, + sum(cadenas) as total_cadenas, + sum(full_lines) as total_full_lines + FROM entry + WHERE + instagram = username; +$$; + +ALTER FUNCTION "public"."profile_stats"("username" "text") OWNER TO "postgres"; + +SET default_tablespace = ''; + +SET default_table_access_method = "heap"; + +CREATE TABLE IF NOT EXISTS "public"."entry" ( + "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, + "created_at" timestamp with time zone DEFAULT "now"() NOT NULL, + "instagram" "text" NOT NULL, + "is_highliner" boolean NOT NULL, + "distance_walked" numeric, + "highline_id" "uuid" NOT NULL, + "witness" "text"[], + "crossing_time" numeric, + "comment" "text", + "cadenas" integer DEFAULT 0, + "full_lines" integer DEFAULT 0 +); + +ALTER TABLE "public"."entry" OWNER TO "postgres"; + +CREATE TABLE IF NOT EXISTS "public"."favorite_highline" ( + "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, + "created_at" timestamp with time zone DEFAULT "now"() NOT NULL, + "highline_id" "uuid" NOT NULL, + "profile_id" "uuid" NOT NULL +); + +ALTER TABLE "public"."favorite_highline" OWNER TO "postgres"; + +CREATE TABLE IF NOT EXISTS "public"."highline" ( + "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, + "created_at" timestamp with time zone DEFAULT "now"() NOT NULL, + "name" "text" NOT NULL, + "height" numeric NOT NULL, + "length" numeric NOT NULL, + "description" "text", + "sector_id" bigint, + "cover_image" "text", + "anchor_a" "extensions"."geography"(Point,4326) DEFAULT NULL::"extensions"."geography", + "anchor_b" "extensions"."geography"(Point,4326) DEFAULT NULL::"extensions"."geography" +); + +ALTER TABLE "public"."highline" OWNER TO "postgres"; + +COMMENT ON COLUMN "public"."highline"."description" IS 'Descrição da fita'; + +COMMENT ON COLUMN "public"."highline"."sector_id" IS 'Wich sector it belongs'; + +COMMENT ON COLUMN "public"."highline"."cover_image" IS 'Card image cover'; + +CREATE TABLE IF NOT EXISTS "public"."profiles" ( + "id" "uuid" NOT NULL, + "name" character varying, + "description" character varying, + "birthday" "date", + "username" character varying, + "profile_picture" "text" +); + +ALTER TABLE "public"."profiles" OWNER TO "postgres"; + +CREATE TABLE IF NOT EXISTS "public"."rig_setup" ( + "id" bigint NOT NULL, + "highline_id" "uuid" NOT NULL, + "riggers" "uuid"[] NOT NULL, + "rig_date" timestamp with time zone NOT NULL, + "unrigged_at" timestamp with time zone, + "is_rigged" boolean NOT NULL +); + +ALTER TABLE "public"."rig_setup" OWNER TO "postgres"; + +ALTER TABLE "public"."rig_setup" ALTER COLUMN "id" ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME "public"."rig_setup_id_seq" + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE IF NOT EXISTS "public"."rig_setup_webbing" ( + "id" bigint NOT NULL, + "setup_id" bigint NOT NULL, + "webbing_id" bigint, + "length" numeric NOT NULL, + "left_loop" boolean NOT NULL, + "right_loop" boolean NOT NULL, + "description" "text", + "webbing_type" "public"."webbing_type" NOT NULL +); + +ALTER TABLE "public"."rig_setup_webbing" OWNER TO "postgres"; + +ALTER TABLE "public"."rig_setup_webbing" ALTER COLUMN "id" ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME "public"."rig_setup_webbing_id_seq" + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE IF NOT EXISTS "public"."sector" ( + "id" bigint NOT NULL, + "created_at" timestamp with time zone DEFAULT "now"(), + "description" "text", + "name" "text" NOT NULL +); + +ALTER TABLE "public"."sector" OWNER TO "postgres"; + +COMMENT ON TABLE "public"."sector" IS 'Setor de Highlines'; + +ALTER TABLE "public"."sector" ALTER COLUMN "id" ADD GENERATED BY DEFAULT AS IDENTITY ( + SEQUENCE NAME "public"."sector_id_seq" + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE IF NOT EXISTS "public"."webbing" ( + "id" bigint NOT NULL, + "user_id" "uuid" NOT NULL, + "length" numeric NOT NULL, + "left_loop" boolean NOT NULL, + "right_loop" boolean NOT NULL, + "model" bigint, + "tag_name" "text", + "description" "text" +); + +ALTER TABLE "public"."webbing" OWNER TO "postgres"; + +ALTER TABLE "public"."webbing" ALTER COLUMN "id" ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME "public"."webbing_id_seq" + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE IF NOT EXISTS "public"."webbing_model" ( + "id" bigint NOT NULL, + "name" "text" NOT NULL, + "material" "public"."material_enum" NOT NULL, + "weave" "public"."weave_enum" NOT NULL +); + +ALTER TABLE "public"."webbing_model" OWNER TO "postgres"; + +ALTER TABLE "public"."webbing_model" ALTER COLUMN "id" ADD GENERATED ALWAYS AS IDENTITY ( + SEQUENCE NAME "public"."webbing_model_id_seq" + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +ALTER TABLE ONLY "public"."entry" + ADD CONSTRAINT "entry_pkey" PRIMARY KEY ("id"); + +ALTER TABLE ONLY "public"."favorite_highline" + ADD CONSTRAINT "favorite_highline_pkey" PRIMARY KEY ("id"); + +ALTER TABLE ONLY "public"."highline" + ADD CONSTRAINT "highline_pkey" PRIMARY KEY ("id"); + +ALTER TABLE ONLY "public"."profiles" + ADD CONSTRAINT "profiles_pkey" PRIMARY KEY ("id"); + +ALTER TABLE ONLY "public"."profiles" + ADD CONSTRAINT "profiles_username_key" UNIQUE ("username"); + +ALTER TABLE ONLY "public"."rig_setup" + ADD CONSTRAINT "rig_setup_pkey" PRIMARY KEY ("id"); + +ALTER TABLE ONLY "public"."rig_setup_webbing" + ADD CONSTRAINT "rig_setup_webbing_pkey" PRIMARY KEY ("id"); + +ALTER TABLE ONLY "public"."sector" + ADD CONSTRAINT "sector_pkey" PRIMARY KEY ("id"); + +ALTER TABLE ONLY "public"."webbing_model" + ADD CONSTRAINT "webbing_model_pkey" PRIMARY KEY ("id"); + +ALTER TABLE ONLY "public"."webbing" + ADD CONSTRAINT "webbing_pkey" PRIMARY KEY ("id"); + +CREATE INDEX "highlines_geo_index" ON "public"."highline" USING "gist" ("anchor_a"); + +CREATE INDEX "idx_rig_setup_highline_id" ON "public"."rig_setup" USING "btree" ("highline_id"); + +CREATE INDEX "idx_rig_setup_webbing_setup_id" ON "public"."rig_setup_webbing" USING "btree" ("setup_id"); + +CREATE INDEX "idx_webbings_model" ON "public"."webbing" USING "btree" ("model"); + +CREATE INDEX "idx_webbings_user_id" ON "public"."webbing" USING "btree" ("user_id"); + +ALTER TABLE ONLY "public"."entry" + ADD CONSTRAINT "entry_highline_id_fkey" FOREIGN KEY ("highline_id") REFERENCES "public"."highline"("id"); + +ALTER TABLE ONLY "public"."favorite_highline" + ADD CONSTRAINT "favorite_highline_highline_id_fkey" FOREIGN KEY ("highline_id") REFERENCES "public"."highline"("id") ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY "public"."favorite_highline" + ADD CONSTRAINT "favorite_highline_profile_id_fkey" FOREIGN KEY ("profile_id") REFERENCES "public"."profiles"("id") ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE ONLY "public"."highline" + ADD CONSTRAINT "highline_sector_id_fkey" FOREIGN KEY ("sector_id") REFERENCES "public"."sector"("id"); + +ALTER TABLE ONLY "public"."profiles" + ADD CONSTRAINT "profiles_id_fkey" FOREIGN KEY ("id") REFERENCES "auth"."users"("id") ON DELETE CASCADE; + +ALTER TABLE ONLY "public"."rig_setup" + ADD CONSTRAINT "rig_setup_highline_id_fkey" FOREIGN KEY ("highline_id") REFERENCES "public"."highline"("id") ON DELETE CASCADE; + +ALTER TABLE ONLY "public"."rig_setup_webbing" + ADD CONSTRAINT "rig_setup_webbing_setup_id_fkey" FOREIGN KEY ("setup_id") REFERENCES "public"."rig_setup"("id") ON DELETE CASCADE; + +ALTER TABLE ONLY "public"."rig_setup_webbing" + ADD CONSTRAINT "rig_setup_webbing_webbing_id_fkey" FOREIGN KEY ("webbing_id") REFERENCES "public"."webbing"("id") ON DELETE SET NULL; + +ALTER TABLE ONLY "public"."webbing" + ADD CONSTRAINT "webbing_model_fkey" FOREIGN KEY ("model") REFERENCES "public"."webbing_model"("id") ON DELETE SET NULL; + +ALTER TABLE ONLY "public"."webbing" + ADD CONSTRAINT "webbing_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "auth"."users"("id") ON DELETE CASCADE; + +CREATE POLICY "Allow authenticated users to insert webbing" ON "public"."webbing" FOR INSERT TO "authenticated" WITH CHECK (true); + +CREATE POLICY "Allow users to delete their own webbing" ON "public"."webbing" FOR DELETE TO "authenticated" USING ((( SELECT "auth"."uid"() AS "uid") = "user_id")); + +CREATE POLICY "Allow users to read their own webbing" ON "public"."webbing" FOR SELECT USING (true); + +CREATE POLICY "Allow users to read webbing models" ON "public"."webbing_model" FOR SELECT USING (true); + +CREATE POLICY "Allow users to update their own webbing" ON "public"."webbing" FOR UPDATE TO "authenticated" USING ((( SELECT "auth"."uid"() AS "uid") = "user_id")) WITH CHECK ((( SELECT "auth"."uid"() AS "uid") = "user_id")); + +CREATE POLICY "Anyone can read rig_setup" ON "public"."rig_setup" FOR SELECT TO "anon", "authenticated" USING (true); + +CREATE POLICY "Anyone can read rig_setup_webbing" ON "public"."rig_setup_webbing" FOR SELECT TO "anon", "authenticated" USING (true); + +CREATE POLICY "Authenticated users can delete rig_setup_webbing" ON "public"."rig_setup_webbing" FOR DELETE TO "authenticated" USING (true); + +CREATE POLICY "Authenticated users can insert rig_setup" ON "public"."rig_setup" FOR INSERT TO "authenticated" WITH CHECK (true); + +CREATE POLICY "Authenticated users can insert rig_setup_webbing" ON "public"."rig_setup_webbing" FOR INSERT TO "authenticated" WITH CHECK (true); + +CREATE POLICY "Authenticated users can update rig_setup" ON "public"."rig_setup" FOR UPDATE TO "authenticated" USING (true) WITH CHECK (true); + +CREATE POLICY "Authenticated users can update rig_setup_webbing" ON "public"."rig_setup_webbing" FOR UPDATE TO "authenticated" USING (true) WITH CHECK (true); + +CREATE POLICY "Enable delete for users based on profile_id" ON "public"."favorite_highline" FOR DELETE USING (("auth"."uid"() = "profile_id")); + +CREATE POLICY "Enable insert for everyone" ON "public"."entry" FOR INSERT TO "anon", "authenticated" WITH CHECK (true); + +CREATE POLICY "Enable insert for users based on profile_id" ON "public"."favorite_highline" FOR INSERT WITH CHECK (("auth"."uid"() = "profile_id")); + +CREATE POLICY "Enable read access for all users" ON "public"."entry" FOR SELECT TO "anon", "authenticated" USING (true); + +CREATE POLICY "Enable read access for all users" ON "public"."highline" FOR SELECT TO "anon", "authenticated" USING (true); + +CREATE POLICY "Enable read access for all users" ON "public"."sector" FOR SELECT TO "anon", "authenticated" USING (true); + +CREATE POLICY "Enable read users based on profile_id" ON "public"."favorite_highline" FOR SELECT USING (("auth"."uid"() = "profile_id")); + +CREATE POLICY "Enable update for all users" ON "public"."highline" FOR UPDATE USING (true); + +CREATE POLICY "Public profiles are viewable by everyone." ON "public"."profiles" FOR SELECT TO "anon", "authenticated" USING (true); + +CREATE POLICY "Users can insert their own profile." ON "public"."profiles" FOR INSERT WITH CHECK (("auth"."uid"() = "id")); + +CREATE POLICY "Users can update own profile." ON "public"."profiles" FOR UPDATE TO "authenticated" USING (("auth"."uid"() = "id")); + +ALTER TABLE "public"."entry" ENABLE ROW LEVEL SECURITY; + +ALTER TABLE "public"."favorite_highline" ENABLE ROW LEVEL SECURITY; + +ALTER TABLE "public"."highline" ENABLE ROW LEVEL SECURITY; + +ALTER TABLE "public"."profiles" ENABLE ROW LEVEL SECURITY; + +CREATE POLICY "public_insert" ON "public"."highline" FOR INSERT TO "anon", "authenticated" WITH CHECK (true); + +ALTER TABLE "public"."rig_setup" ENABLE ROW LEVEL SECURITY; + +ALTER TABLE "public"."rig_setup_webbing" ENABLE ROW LEVEL SECURITY; + +ALTER TABLE "public"."sector" ENABLE ROW LEVEL SECURITY; + +ALTER TABLE "public"."webbing" ENABLE ROW LEVEL SECURITY; + +ALTER TABLE "public"."webbing_model" ENABLE ROW LEVEL SECURITY; + +ALTER PUBLICATION "supabase_realtime" OWNER TO "postgres"; + +GRANT USAGE ON SCHEMA "public" TO "postgres"; +GRANT USAGE ON SCHEMA "public" TO "anon"; +GRANT USAGE ON SCHEMA "public" TO "authenticated"; +GRANT USAGE ON SCHEMA "public" TO "service_role"; + +GRANT ALL ON FUNCTION "public"."get_crossing_time"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "anon"; +GRANT ALL ON FUNCTION "public"."get_crossing_time"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "authenticated"; +GRANT ALL ON FUNCTION "public"."get_crossing_time"("highline_id" "uuid", "page_number" integer, "page_size" integer) TO "service_role"; + +GRANT ALL ON FUNCTION "public"."get_highline"("searchid" "uuid"[], "searchname" "text", "pagesize" integer, "pageparam" integer, "userid" "uuid") TO "anon"; +GRANT ALL ON FUNCTION "public"."get_highline"("searchid" "uuid"[], "searchname" "text", "pagesize" integer, "pageparam" integer, "userid" "uuid") TO "authenticated"; +GRANT ALL ON FUNCTION "public"."get_highline"("searchid" "uuid"[], "searchname" "text", "pagesize" integer, "pageparam" integer, "userid" "uuid") TO "service_role"; + +GRANT ALL ON FUNCTION "public"."get_total_cadenas"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) TO "anon"; +GRANT ALL ON FUNCTION "public"."get_total_cadenas"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) TO "authenticated"; +GRANT ALL ON FUNCTION "public"."get_total_cadenas"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) TO "service_role"; + +GRANT ALL ON FUNCTION "public"."get_total_full_lines"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) TO "anon"; +GRANT ALL ON FUNCTION "public"."get_total_full_lines"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) TO "authenticated"; +GRANT ALL ON FUNCTION "public"."get_total_full_lines"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) TO "service_role"; + +GRANT ALL ON FUNCTION "public"."get_total_walked"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) TO "anon"; +GRANT ALL ON FUNCTION "public"."get_total_walked"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) TO "authenticated"; +GRANT ALL ON FUNCTION "public"."get_total_walked"("highline_ids" "uuid"[], "page_number" integer, "page_size" integer, "start_date" timestamp with time zone, "end_date" timestamp with time zone) TO "service_role"; + +GRANT ALL ON FUNCTION "public"."handle_new_user"() TO "anon"; +GRANT ALL ON FUNCTION "public"."handle_new_user"() TO "authenticated"; +GRANT ALL ON FUNCTION "public"."handle_new_user"() TO "service_role"; + +GRANT ALL ON FUNCTION "public"."highlines_in_view"("min_lat" double precision, "min_long" double precision, "max_lat" double precision, "max_long" double precision) TO "anon"; +GRANT ALL ON FUNCTION "public"."highlines_in_view"("min_lat" double precision, "min_long" double precision, "max_lat" double precision, "max_long" double precision) TO "authenticated"; +GRANT ALL ON FUNCTION "public"."highlines_in_view"("min_lat" double precision, "min_long" double precision, "max_lat" double precision, "max_long" double precision) TO "service_role"; + +GRANT ALL ON FUNCTION "public"."profile_stats"("username" "text") TO "anon"; +GRANT ALL ON FUNCTION "public"."profile_stats"("username" "text") TO "authenticated"; +GRANT ALL ON FUNCTION "public"."profile_stats"("username" "text") TO "service_role"; + +GRANT ALL ON TABLE "public"."entry" TO "anon"; +GRANT ALL ON TABLE "public"."entry" TO "authenticated"; +GRANT ALL ON TABLE "public"."entry" TO "service_role"; + +GRANT ALL ON TABLE "public"."favorite_highline" TO "anon"; +GRANT ALL ON TABLE "public"."favorite_highline" TO "authenticated"; +GRANT ALL ON TABLE "public"."favorite_highline" TO "service_role"; + +GRANT ALL ON TABLE "public"."highline" TO "anon"; +GRANT ALL ON TABLE "public"."highline" TO "authenticated"; +GRANT ALL ON TABLE "public"."highline" TO "service_role"; + +GRANT ALL ON TABLE "public"."profiles" TO "anon"; +GRANT ALL ON TABLE "public"."profiles" TO "authenticated"; +GRANT ALL ON TABLE "public"."profiles" TO "service_role"; + +GRANT ALL ON TABLE "public"."rig_setup" TO "anon"; +GRANT ALL ON TABLE "public"."rig_setup" TO "authenticated"; +GRANT ALL ON TABLE "public"."rig_setup" TO "service_role"; + +GRANT ALL ON SEQUENCE "public"."rig_setup_id_seq" TO "anon"; +GRANT ALL ON SEQUENCE "public"."rig_setup_id_seq" TO "authenticated"; +GRANT ALL ON SEQUENCE "public"."rig_setup_id_seq" TO "service_role"; + +GRANT ALL ON TABLE "public"."rig_setup_webbing" TO "anon"; +GRANT ALL ON TABLE "public"."rig_setup_webbing" TO "authenticated"; +GRANT ALL ON TABLE "public"."rig_setup_webbing" TO "service_role"; + +GRANT ALL ON SEQUENCE "public"."rig_setup_webbing_id_seq" TO "anon"; +GRANT ALL ON SEQUENCE "public"."rig_setup_webbing_id_seq" TO "authenticated"; +GRANT ALL ON SEQUENCE "public"."rig_setup_webbing_id_seq" TO "service_role"; + +GRANT ALL ON TABLE "public"."sector" TO "anon"; +GRANT ALL ON TABLE "public"."sector" TO "authenticated"; +GRANT ALL ON TABLE "public"."sector" TO "service_role"; + +GRANT ALL ON SEQUENCE "public"."sector_id_seq" TO "anon"; +GRANT ALL ON SEQUENCE "public"."sector_id_seq" TO "authenticated"; +GRANT ALL ON SEQUENCE "public"."sector_id_seq" TO "service_role"; + +GRANT ALL ON TABLE "public"."webbing" TO "anon"; +GRANT ALL ON TABLE "public"."webbing" TO "authenticated"; +GRANT ALL ON TABLE "public"."webbing" TO "service_role"; + +GRANT ALL ON SEQUENCE "public"."webbing_id_seq" TO "anon"; +GRANT ALL ON SEQUENCE "public"."webbing_id_seq" TO "authenticated"; +GRANT ALL ON SEQUENCE "public"."webbing_id_seq" TO "service_role"; + +GRANT ALL ON TABLE "public"."webbing_model" TO "anon"; +GRANT ALL ON TABLE "public"."webbing_model" TO "authenticated"; +GRANT ALL ON TABLE "public"."webbing_model" TO "service_role"; + +GRANT ALL ON SEQUENCE "public"."webbing_model_id_seq" TO "anon"; +GRANT ALL ON SEQUENCE "public"."webbing_model_id_seq" TO "authenticated"; +GRANT ALL ON SEQUENCE "public"."webbing_model_id_seq" TO "service_role"; + +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES TO "postgres"; +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES TO "anon"; +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES TO "authenticated"; +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES TO "service_role"; + +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "postgres"; +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "anon"; +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "authenticated"; +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "service_role"; + +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "postgres"; +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "anon"; +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "authenticated"; +ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "service_role"; + +RESET ALL; diff --git a/utils/supabase/database.types.ts b/utils/supabase/database.types.ts index 47e5b14..c9a9a9e 100644 --- a/utils/supabase/database.types.ts +++ b/utils/supabase/database.types.ts @@ -1,725 +1,878 @@ -// Command used to generate the types -// npx supabase gen types typescript --local --schema storage,public,functions > utils/supabase/database.types.ts - -export type Functions = Database["public"]["Functions"]; -// Supabase does not generate types for non defaul SQL data types, this type represent a postgis POINT -// Notice that it should be called as POINT(longitude latitude) -export type Point = `POINT(${number} ${number})`; - -export type Json = - | string - | number - | boolean - | null - | { [key: string]: Json | undefined } - | Json[]; - -export type Database = { - public: { - Tables: { - entry: { - Row: { - cadenas: number | null; - comment: string | null; - created_at: string; - crossing_time: number | null; - distance_walked: number | null; - full_lines: number | null; - highline_id: string; - id: string; - instagram: string; - is_highliner: boolean; - witness: string[] | null; - }; - Insert: { - cadenas?: number | null; - comment?: string | null; - created_at?: string; - crossing_time?: number | null; - distance_walked?: number | null; - full_lines?: number | null; - highline_id: string; - id?: string; - instagram: string; - is_highliner: boolean; - witness?: string[] | null; - }; - Update: { - cadenas?: number | null; - comment?: string | null; - created_at?: string; - crossing_time?: number | null; - distance_walked?: number | null; - full_lines?: number | null; - highline_id?: string; - id?: string; - instagram?: string; - is_highliner?: boolean; - witness?: string[] | null; - }; - Relationships: [ - { - foreignKeyName: "entry_highline_id_fkey"; - columns: ["highline_id"]; - isOneToOne: false; - referencedRelation: "highline"; - referencedColumns: ["id"]; - } - ]; - }; - favorite_highline: { - Row: { - created_at: string; - highline_id: string; - id: string; - profile_id: string; - }; - Insert: { - created_at?: string; - highline_id: string; - id?: string; - profile_id: string; - }; - Update: { - created_at?: string; - highline_id?: string; - id?: string; - profile_id?: string; - }; - Relationships: [ - { - foreignKeyName: "favorite_highline_highline_id_fkey"; - columns: ["highline_id"]; - isOneToOne: false; - referencedRelation: "highline"; - referencedColumns: ["id"]; - }, - { - foreignKeyName: "favorite_highline_profile_id_fkey"; - columns: ["profile_id"]; - isOneToOne: false; - referencedRelation: "profiles"; - referencedColumns: ["id"]; - } - ]; - }; - highline: { - Row: { - anchor_a: unknown | null; - anchor_b: unknown | null; - backup_webbing: string; - cover_image: string | null; - created_at: string; - description: string | null; - height: number; - id: string; - lenght: number; - main_webbing: string; - name: string; - riggers: string[] | null; - sector_id: number | null; - }; - Insert: { - anchor_a?: unknown | null; - anchor_b?: unknown | null; - backup_webbing?: string; - cover_image?: string | null; - created_at?: string; - description?: string | null; - height: number; - id?: string; - lenght: number; - main_webbing?: string; - name: string; - riggers?: string[] | null; - sector_id?: number | null; - }; - Update: { - anchor_a?: unknown | null; - anchor_b?: unknown | null; - backup_webbing?: string; - cover_image?: string | null; - created_at?: string; - description?: string | null; - height?: number; - id?: string; - lenght?: number; - main_webbing?: string; - name?: string; - riggers?: string[] | null; - sector_id?: number | null; - }; - Relationships: [ - { - foreignKeyName: "highline_sector_id_fkey"; - columns: ["sector_id"]; - isOneToOne: false; - referencedRelation: "sector"; - referencedColumns: ["id"]; - } - ]; - }; - profiles: { - Row: { - birthday: string | null; - description: string | null; - id: string; - name: string | null; - profile_picture: string | null; - username: string | null; - }; - Insert: { - birthday?: string | null; - description?: string | null; - id: string; - name?: string | null; - profile_picture?: string | null; - username?: string | null; - }; - Update: { - birthday?: string | null; - description?: string | null; - id?: string; - name?: string | null; - profile_picture?: string | null; - username?: string | null; - }; - Relationships: [ - { - foreignKeyName: "profiles_id_fkey"; - columns: ["id"]; - isOneToOne: true; - referencedRelation: "users"; - referencedColumns: ["id"]; - } - ]; - }; - sector: { - Row: { - created_at: string | null; - description: string | null; - id: number; - name: string; - }; - Insert: { - created_at?: string | null; - description?: string | null; - id?: number; - name: string; - }; - Update: { - created_at?: string | null; - description?: string | null; - id?: number; - name?: string; - }; - Relationships: []; - }; - }; - Views: { - [_ in never]: never; - }; - Functions: { - get_crossing_time: { - Args: { - highline_id: string; - page_number: number; - page_size: number; - }; - Returns: { - instagram: string; - crossing_time: number; - profile_picture: string; - }[]; - }; - get_highline: { - Args: { - searchid?: string[]; - searchname?: string; - pagesize?: number; - pageparam?: number; - userid?: string; - }; - Returns: { - id: string; - created_at: string; - name: string; - height: number; - lenght: number; - main_webbing: string; - backup_webbing: string; - description: string; - sector_id: number; - cover_image: string; - riggers: string[]; - anchor_a_long: number; - anchor_a_lat: number; - anchor_b_long: number; - anchor_b_lat: number; - is_favorite: boolean; - }[]; - }; - get_total_cadenas: { - Args: { - highline_ids: string[]; - page_number: number; - page_size: number; - start_date?: string; - end_date?: string; - }; - Returns: { - instagram: string; - total_cadenas: number; - profile_picture: string; - }[]; - }; - get_total_full_lines: { - Args: { - highline_ids: string[]; - page_number: number; - page_size: number; - start_date?: string; - end_date?: string; - }; - Returns: { - instagram: string; - total_full_lines: number; - profile_picture: string; - }[]; - }; - get_total_walked: { - Args: { - highline_ids: string[]; - page_number: number; - page_size: number; - start_date?: string; - end_date?: string; - }; - Returns: { - instagram: string; - total_distance_walked: number; - profile_picture: string; - }[]; - }; - highlines_in_view: { - Args: { - min_lat: number; - min_long: number; - max_lat: number; - max_long: number; - }; - Returns: { - id: string; - name: string; - anchor_a_lat: number; - anchor_a_long: number; - anchor_b_lat: number; - anchor_b_long: number; - }[]; - }; - profile_stats: { - Args: { - username: string; - }; - Returns: { - total_distance_walked: number; - total_cadenas: number; - total_full_lines: number; - }[]; - }; - }; - Enums: { - [_ in never]: never; - }; - CompositeTypes: { - [_ in never]: never; - }; - }; - storage: { - Tables: { - buckets: { - Row: { - allowed_mime_types: string[] | null; - avif_autodetection: boolean | null; - created_at: string | null; - file_size_limit: number | null; - id: string; - name: string; - owner: string | null; - owner_id: string | null; - public: boolean | null; - updated_at: string | null; - }; - Insert: { - allowed_mime_types?: string[] | null; - avif_autodetection?: boolean | null; - created_at?: string | null; - file_size_limit?: number | null; - id: string; - name: string; - owner?: string | null; - owner_id?: string | null; - public?: boolean | null; - updated_at?: string | null; - }; - Update: { - allowed_mime_types?: string[] | null; - avif_autodetection?: boolean | null; - created_at?: string | null; - file_size_limit?: number | null; - id?: string; - name?: string; - owner?: string | null; - owner_id?: string | null; - public?: boolean | null; - updated_at?: string | null; - }; - Relationships: []; - }; - migrations: { - Row: { - executed_at: string | null; - hash: string; - id: number; - name: string; - }; - Insert: { - executed_at?: string | null; - hash: string; - id: number; - name: string; - }; - Update: { - executed_at?: string | null; - hash?: string; - id?: number; - name?: string; - }; - Relationships: []; - }; - objects: { - Row: { - bucket_id: string | null; - created_at: string | null; - id: string; - last_accessed_at: string | null; - metadata: Json | null; - name: string | null; - owner: string | null; - owner_id: string | null; - path_tokens: string[] | null; - updated_at: string | null; - version: string | null; - }; - Insert: { - bucket_id?: string | null; - created_at?: string | null; - id?: string; - last_accessed_at?: string | null; - metadata?: Json | null; - name?: string | null; - owner?: string | null; - owner_id?: string | null; - path_tokens?: string[] | null; - updated_at?: string | null; - version?: string | null; - }; - Update: { - bucket_id?: string | null; - created_at?: string | null; - id?: string; - last_accessed_at?: string | null; - metadata?: Json | null; - name?: string | null; - owner?: string | null; - owner_id?: string | null; - path_tokens?: string[] | null; - updated_at?: string | null; - version?: string | null; - }; - Relationships: [ - { - foreignKeyName: "objects_bucketId_fkey"; - columns: ["bucket_id"]; - isOneToOne: false; - referencedRelation: "buckets"; - referencedColumns: ["id"]; - } - ]; - }; - s3_multipart_uploads: { - Row: { - bucket_id: string; - created_at: string; - id: string; - in_progress_size: number; - key: string; - owner_id: string | null; - upload_signature: string; - version: string; - }; - Insert: { - bucket_id: string; - created_at?: string; - id: string; - in_progress_size?: number; - key: string; - owner_id?: string | null; - upload_signature: string; - version: string; - }; - Update: { - bucket_id?: string; - created_at?: string; - id?: string; - in_progress_size?: number; - key?: string; - owner_id?: string | null; - upload_signature?: string; - version?: string; - }; - Relationships: [ - { - foreignKeyName: "s3_multipart_uploads_bucket_id_fkey"; - columns: ["bucket_id"]; - isOneToOne: false; - referencedRelation: "buckets"; - referencedColumns: ["id"]; - } - ]; - }; - s3_multipart_uploads_parts: { - Row: { - bucket_id: string; - created_at: string; - etag: string; - id: string; - key: string; - owner_id: string | null; - part_number: number; - size: number; - upload_id: string; - version: string; - }; - Insert: { - bucket_id: string; - created_at?: string; - etag: string; - id?: string; - key: string; - owner_id?: string | null; - part_number: number; - size?: number; - upload_id: string; - version: string; - }; - Update: { - bucket_id?: string; - created_at?: string; - etag?: string; - id?: string; - key?: string; - owner_id?: string | null; - part_number?: number; - size?: number; - upload_id?: string; - version?: string; - }; - Relationships: [ - { - foreignKeyName: "s3_multipart_uploads_parts_bucket_id_fkey"; - columns: ["bucket_id"]; - isOneToOne: false; - referencedRelation: "buckets"; - referencedColumns: ["id"]; - }, - { - foreignKeyName: "s3_multipart_uploads_parts_upload_id_fkey"; - columns: ["upload_id"]; - isOneToOne: false; - referencedRelation: "s3_multipart_uploads"; - referencedColumns: ["id"]; - } - ]; - }; - }; - Views: { - [_ in never]: never; - }; - Functions: { - can_insert_object: { - Args: { - bucketid: string; - name: string; - owner: string; - metadata: Json; - }; - Returns: undefined; - }; - extension: { - Args: { - name: string; - }; - Returns: string; - }; - filename: { - Args: { - name: string; - }; - Returns: string; - }; - foldername: { - Args: { - name: string; - }; - Returns: string[]; - }; - get_size_by_bucket: { - Args: Record; - Returns: { - size: number; - bucket_id: string; - }[]; - }; - list_multipart_uploads_with_delimiter: { - Args: { - bucket_id: string; - prefix_param: string; - delimiter_param: string; - max_keys?: number; - next_key_token?: string; - next_upload_token?: string; - }; - Returns: { - key: string; - id: string; - created_at: string; - }[]; - }; - list_objects_with_delimiter: { - Args: { - bucket_id: string; - prefix_param: string; - delimiter_param: string; - max_keys?: number; - start_after?: string; - next_token?: string; - }; - Returns: { - name: string; - id: string; - metadata: Json; - updated_at: string; - }[]; - }; - search: { - Args: { - prefix: string; - bucketname: string; - limits?: number; - levels?: number; - offsets?: number; - search?: string; - sortcolumn?: string; - sortorder?: string; - }; - Returns: { - name: string; - id: string; - updated_at: string; - created_at: string; - last_accessed_at: string; - metadata: Json; - }[]; - }; - }; - Enums: { - [_ in never]: never; - }; - CompositeTypes: { - [_ in never]: never; - }; - }; -}; - -type PublicSchema = Database[Extract]; - -export type Tables< - PublicTableNameOrOptions extends - | keyof (PublicSchema["Tables"] & PublicSchema["Views"]) - | { schema: keyof Database }, - TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & - Database[PublicTableNameOrOptions["schema"]]["Views"]) - : never = never -> = PublicTableNameOrOptions extends { schema: keyof Database } - ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & - Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { - Row: infer R; - } - ? R - : never - : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & - PublicSchema["Views"]) - ? (PublicSchema["Tables"] & - PublicSchema["Views"])[PublicTableNameOrOptions] extends { - Row: infer R; - } - ? R - : never - : never; - -export type TablesInsert< - PublicTableNameOrOptions extends - | keyof PublicSchema["Tables"] - | { schema: keyof Database }, - TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] - : never = never -> = PublicTableNameOrOptions extends { schema: keyof Database } - ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I; - } - ? I - : never - : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] - ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Insert: infer I; - } - ? I - : never - : never; - -export type TablesUpdate< - PublicTableNameOrOptions extends - | keyof PublicSchema["Tables"] - | { schema: keyof Database }, - TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] - : never = never -> = PublicTableNameOrOptions extends { schema: keyof Database } - ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U; - } - ? U - : never - : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] - ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { - Update: infer U; - } - ? U - : never - : never; - -export type Enums< - PublicEnumNameOrOptions extends - | keyof PublicSchema["Enums"] - | { schema: keyof Database }, - EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] - : never = never -> = PublicEnumNameOrOptions extends { schema: keyof Database } - ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] - : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] - ? PublicSchema["Enums"][PublicEnumNameOrOptions] - : never; +// Command used to generate the types +// npx supabase gen types typescript --local --schema storage,public,functions > utils/supabase/database.types.ts + +export type Functions = Database["public"]["Functions"]; +// Supabase does not generate types for non defaul SQL data types, this type represent a postgis POINT +// Notice that it should be called as POINT(longitude latitude) +export type Point = `POINT(${number} ${number})`; + +export type Json = + | string + | number + | boolean + | null + | { [key: string]: Json | undefined } + | Json[]; + +export type Database = { + public: { + Tables: { + entry: { + Row: { + cadenas: number | null; + comment: string | null; + created_at: string; + crossing_time: number | null; + distance_walked: number | null; + full_lines: number | null; + highline_id: string; + id: string; + instagram: string; + is_highliner: boolean; + witness: string[] | null; + }; + Insert: { + cadenas?: number | null; + comment?: string | null; + created_at?: string; + crossing_time?: number | null; + distance_walked?: number | null; + full_lines?: number | null; + highline_id: string; + id?: string; + instagram: string; + is_highliner: boolean; + witness?: string[] | null; + }; + Update: { + cadenas?: number | null; + comment?: string | null; + created_at?: string; + crossing_time?: number | null; + distance_walked?: number | null; + full_lines?: number | null; + highline_id?: string; + id?: string; + instagram?: string; + is_highliner?: boolean; + witness?: string[] | null; + }; + Relationships: [ + { + foreignKeyName: "entry_highline_id_fkey"; + columns: ["highline_id"]; + isOneToOne: false; + referencedRelation: "highline"; + referencedColumns: ["id"]; + } + ]; + }; + favorite_highline: { + Row: { + created_at: string; + highline_id: string; + id: string; + profile_id: string; + }; + Insert: { + created_at?: string; + highline_id: string; + id?: string; + profile_id: string; + }; + Update: { + created_at?: string; + highline_id?: string; + id?: string; + profile_id?: string; + }; + Relationships: [ + { + foreignKeyName: "favorite_highline_highline_id_fkey"; + columns: ["highline_id"]; + isOneToOne: false; + referencedRelation: "highline"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "favorite_highline_profile_id_fkey"; + columns: ["profile_id"]; + isOneToOne: false; + referencedRelation: "profiles"; + referencedColumns: ["id"]; + } + ]; + }; + highline: { + Row: { + anchor_a: unknown | null; + anchor_b: unknown | null; + cover_image: string | null; + created_at: string; + description: string | null; + height: number; + id: string; + length: number; + name: string; + sector_id: number | null; + }; + Insert: { + anchor_a?: unknown | null; + anchor_b?: unknown | null; + cover_image?: string | null; + created_at?: string; + description?: string | null; + height: number; + id?: string; + length: number; + name: string; + sector_id?: number | null; + }; + Update: { + anchor_a?: unknown | null; + anchor_b?: unknown | null; + cover_image?: string | null; + created_at?: string; + description?: string | null; + height?: number; + id?: string; + length?: number; + name?: string; + sector_id?: number | null; + }; + Relationships: [ + { + foreignKeyName: "highline_sector_id_fkey"; + columns: ["sector_id"]; + isOneToOne: false; + referencedRelation: "sector"; + referencedColumns: ["id"]; + } + ]; + }; + profiles: { + Row: { + birthday: string | null; + description: string | null; + id: string; + name: string | null; + profile_picture: string | null; + username: string | null; + }; + Insert: { + birthday?: string | null; + description?: string | null; + id: string; + name?: string | null; + profile_picture?: string | null; + username?: string | null; + }; + Update: { + birthday?: string | null; + description?: string | null; + id?: string; + name?: string | null; + profile_picture?: string | null; + username?: string | null; + }; + Relationships: []; + }; + rig_setup: { + Row: { + highline_id: string; + id: number; + is_rigged: boolean; + rig_date: string; + riggers: string[]; + unrigged_at: string | null; + }; + Insert: { + highline_id: string; + id?: never; + is_rigged: boolean; + rig_date: string; + riggers: string[]; + unrigged_at?: string | null; + }; + Update: { + highline_id?: string; + id?: never; + is_rigged?: boolean; + rig_date?: string; + riggers?: string[]; + unrigged_at?: string | null; + }; + Relationships: [ + { + foreignKeyName: "rig_setup_highline_id_fkey"; + columns: ["highline_id"]; + isOneToOne: false; + referencedRelation: "highline"; + referencedColumns: ["id"]; + } + ]; + }; + rig_setup_webbing: { + Row: { + description: string | null; + id: number; + left_loop: boolean; + length: number; + right_loop: boolean; + setup_id: number; + webbing_id: number | null; + webbing_type: Database["public"]["Enums"]["webbing_type"]; + }; + Insert: { + description?: string | null; + id?: never; + left_loop: boolean; + length: number; + right_loop: boolean; + setup_id: number; + webbing_id?: number | null; + webbing_type: Database["public"]["Enums"]["webbing_type"]; + }; + Update: { + description?: string | null; + id?: never; + left_loop?: boolean; + length?: number; + right_loop?: boolean; + setup_id?: number; + webbing_id?: number | null; + webbing_type?: Database["public"]["Enums"]["webbing_type"]; + }; + Relationships: [ + { + foreignKeyName: "rig_setup_webbing_setup_id_fkey"; + columns: ["setup_id"]; + isOneToOne: false; + referencedRelation: "rig_setup"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "rig_setup_webbing_webbing_id_fkey"; + columns: ["webbing_id"]; + isOneToOne: false; + referencedRelation: "webbing"; + referencedColumns: ["id"]; + } + ]; + }; + sector: { + Row: { + created_at: string | null; + description: string | null; + id: number; + name: string; + }; + Insert: { + created_at?: string | null; + description?: string | null; + id?: number; + name: string; + }; + Update: { + created_at?: string | null; + description?: string | null; + id?: number; + name?: string; + }; + Relationships: []; + }; + webbing: { + Row: { + description: string | null; + id: number; + left_loop: boolean; + length: number; + model: number | null; + right_loop: boolean; + tag_name: string | null; + user_id: string; + }; + Insert: { + description?: string | null; + id?: never; + left_loop: boolean; + length: number; + model?: number | null; + right_loop: boolean; + tag_name?: string | null; + user_id: string; + }; + Update: { + description?: string | null; + id?: never; + left_loop?: boolean; + length?: number; + model?: number | null; + right_loop?: boolean; + tag_name?: string | null; + user_id?: string; + }; + Relationships: [ + { + foreignKeyName: "webbing_model_fkey"; + columns: ["model"]; + isOneToOne: false; + referencedRelation: "webbing_model"; + referencedColumns: ["id"]; + } + ]; + }; + webbing_model: { + Row: { + id: number; + material: Database["public"]["Enums"]["material_enum"]; + name: string; + weave: Database["public"]["Enums"]["weave_enum"]; + }; + Insert: { + id?: never; + material: Database["public"]["Enums"]["material_enum"]; + name: string; + weave: Database["public"]["Enums"]["weave_enum"]; + }; + Update: { + id?: never; + material?: Database["public"]["Enums"]["material_enum"]; + name?: string; + weave?: Database["public"]["Enums"]["weave_enum"]; + }; + Relationships: []; + }; + }; + Views: { + [_ in never]: never; + }; + Functions: { + get_crossing_time: { + Args: { + highline_id: string; + page_number: number; + page_size: number; + }; + Returns: { + instagram: string; + crossing_time: number; + profile_picture: string; + }[]; + }; + get_highline: { + Args: { + searchid?: string[]; + searchname?: string; + pagesize?: number; + pageparam?: number; + userid?: string; + }; + Returns: { + id: string; + created_at: string; + name: string; + height: number; + length: number; + description: string; + sector_id: number; + cover_image: string; + anchor_a_long: number; + anchor_a_lat: number; + anchor_b_long: number; + anchor_b_lat: number; + is_favorite: boolean; + status: string; + }[]; + }; + get_total_cadenas: { + Args: { + highline_ids: string[]; + page_number: number; + page_size: number; + start_date?: string; + end_date?: string; + }; + Returns: { + instagram: string; + total_cadenas: number; + profile_picture: string; + }[]; + }; + get_total_full_lines: { + Args: { + highline_ids: string[]; + page_number: number; + page_size: number; + start_date?: string; + end_date?: string; + }; + Returns: { + instagram: string; + total_full_lines: number; + profile_picture: string; + }[]; + }; + get_total_walked: { + Args: { + highline_ids: string[]; + page_number: number; + page_size: number; + start_date?: string; + end_date?: string; + }; + Returns: { + instagram: string; + total_distance_walked: number; + profile_picture: string; + }[]; + }; + highlines_in_view: { + Args: { + min_lat: number; + min_long: number; + max_lat: number; + max_long: number; + }; + Returns: { + id: string; + name: string; + anchor_a_lat: number; + anchor_a_long: number; + anchor_b_lat: number; + anchor_b_long: number; + }[]; + }; + profile_stats: { + Args: { + username: string; + }; + Returns: { + total_distance_walked: number; + total_cadenas: number; + total_full_lines: number; + }[]; + }; + }; + Enums: { + material_enum: "nylon" | "dyneema" | "polyester"; + weave_enum: "flat" | "tubular"; + webbing_type: "main" | "backup"; + }; + CompositeTypes: { + [_ in never]: never; + }; + }; + storage: { + Tables: { + buckets: { + Row: { + allowed_mime_types: string[] | null; + avif_autodetection: boolean | null; + created_at: string | null; + file_size_limit: number | null; + id: string; + name: string; + owner: string | null; + owner_id: string | null; + public: boolean | null; + updated_at: string | null; + }; + Insert: { + allowed_mime_types?: string[] | null; + avif_autodetection?: boolean | null; + created_at?: string | null; + file_size_limit?: number | null; + id: string; + name: string; + owner?: string | null; + owner_id?: string | null; + public?: boolean | null; + updated_at?: string | null; + }; + Update: { + allowed_mime_types?: string[] | null; + avif_autodetection?: boolean | null; + created_at?: string | null; + file_size_limit?: number | null; + id?: string; + name?: string; + owner?: string | null; + owner_id?: string | null; + public?: boolean | null; + updated_at?: string | null; + }; + Relationships: []; + }; + migrations: { + Row: { + executed_at: string | null; + hash: string; + id: number; + name: string; + }; + Insert: { + executed_at?: string | null; + hash: string; + id: number; + name: string; + }; + Update: { + executed_at?: string | null; + hash?: string; + id?: number; + name?: string; + }; + Relationships: []; + }; + objects: { + Row: { + bucket_id: string | null; + created_at: string | null; + id: string; + last_accessed_at: string | null; + metadata: Json | null; + name: string | null; + owner: string | null; + owner_id: string | null; + path_tokens: string[] | null; + updated_at: string | null; + user_metadata: Json | null; + version: string | null; + }; + Insert: { + bucket_id?: string | null; + created_at?: string | null; + id?: string; + last_accessed_at?: string | null; + metadata?: Json | null; + name?: string | null; + owner?: string | null; + owner_id?: string | null; + path_tokens?: string[] | null; + updated_at?: string | null; + user_metadata?: Json | null; + version?: string | null; + }; + Update: { + bucket_id?: string | null; + created_at?: string | null; + id?: string; + last_accessed_at?: string | null; + metadata?: Json | null; + name?: string | null; + owner?: string | null; + owner_id?: string | null; + path_tokens?: string[] | null; + updated_at?: string | null; + user_metadata?: Json | null; + version?: string | null; + }; + Relationships: [ + { + foreignKeyName: "objects_bucketId_fkey"; + columns: ["bucket_id"]; + isOneToOne: false; + referencedRelation: "buckets"; + referencedColumns: ["id"]; + } + ]; + }; + s3_multipart_uploads: { + Row: { + bucket_id: string; + created_at: string; + id: string; + in_progress_size: number; + key: string; + owner_id: string | null; + upload_signature: string; + user_metadata: Json | null; + version: string; + }; + Insert: { + bucket_id: string; + created_at?: string; + id: string; + in_progress_size?: number; + key: string; + owner_id?: string | null; + upload_signature: string; + user_metadata?: Json | null; + version: string; + }; + Update: { + bucket_id?: string; + created_at?: string; + id?: string; + in_progress_size?: number; + key?: string; + owner_id?: string | null; + upload_signature?: string; + user_metadata?: Json | null; + version?: string; + }; + Relationships: [ + { + foreignKeyName: "s3_multipart_uploads_bucket_id_fkey"; + columns: ["bucket_id"]; + isOneToOne: false; + referencedRelation: "buckets"; + referencedColumns: ["id"]; + } + ]; + }; + s3_multipart_uploads_parts: { + Row: { + bucket_id: string; + created_at: string; + etag: string; + id: string; + key: string; + owner_id: string | null; + part_number: number; + size: number; + upload_id: string; + version: string; + }; + Insert: { + bucket_id: string; + created_at?: string; + etag: string; + id?: string; + key: string; + owner_id?: string | null; + part_number: number; + size?: number; + upload_id: string; + version: string; + }; + Update: { + bucket_id?: string; + created_at?: string; + etag?: string; + id?: string; + key?: string; + owner_id?: string | null; + part_number?: number; + size?: number; + upload_id?: string; + version?: string; + }; + Relationships: [ + { + foreignKeyName: "s3_multipart_uploads_parts_bucket_id_fkey"; + columns: ["bucket_id"]; + isOneToOne: false; + referencedRelation: "buckets"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "s3_multipart_uploads_parts_upload_id_fkey"; + columns: ["upload_id"]; + isOneToOne: false; + referencedRelation: "s3_multipart_uploads"; + referencedColumns: ["id"]; + } + ]; + }; + }; + Views: { + [_ in never]: never; + }; + Functions: { + can_insert_object: { + Args: { + bucketid: string; + name: string; + owner: string; + metadata: Json; + }; + Returns: undefined; + }; + extension: { + Args: { + name: string; + }; + Returns: string; + }; + filename: { + Args: { + name: string; + }; + Returns: string; + }; + foldername: { + Args: { + name: string; + }; + Returns: string[]; + }; + get_size_by_bucket: { + Args: Record; + Returns: { + size: number; + bucket_id: string; + }[]; + }; + list_multipart_uploads_with_delimiter: { + Args: { + bucket_id: string; + prefix_param: string; + delimiter_param: string; + max_keys?: number; + next_key_token?: string; + next_upload_token?: string; + }; + Returns: { + key: string; + id: string; + created_at: string; + }[]; + }; + list_objects_with_delimiter: { + Args: { + bucket_id: string; + prefix_param: string; + delimiter_param: string; + max_keys?: number; + start_after?: string; + next_token?: string; + }; + Returns: { + name: string; + id: string; + metadata: Json; + updated_at: string; + }[]; + }; + operation: { + Args: Record; + Returns: string; + }; + search: { + Args: { + prefix: string; + bucketname: string; + limits?: number; + levels?: number; + offsets?: number; + search?: string; + sortcolumn?: string; + sortorder?: string; + }; + Returns: { + name: string; + id: string; + updated_at: string; + created_at: string; + last_accessed_at: string; + metadata: Json; + }[]; + }; + }; + Enums: { + [_ in never]: never; + }; + CompositeTypes: { + [_ in never]: never; + }; + }; +}; + +type PublicSchema = Database[Extract]; + +export type Tables< + PublicTableNameOrOptions extends + | keyof (PublicSchema["Tables"] & PublicSchema["Views"]) + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & + Database[PublicTableNameOrOptions["schema"]]["Views"]) + : never = never +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & + Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { + Row: infer R; + } + ? R + : never + : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & + PublicSchema["Views"]) + ? (PublicSchema["Tables"] & + PublicSchema["Views"])[PublicTableNameOrOptions] extends { + Row: infer R; + } + ? R + : never + : never; + +export type TablesInsert< + PublicTableNameOrOptions extends + | keyof PublicSchema["Tables"] + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + : never = never +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Insert: infer I; + } + ? I + : never + : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] + ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { + Insert: infer I; + } + ? I + : never + : never; + +export type TablesUpdate< + PublicTableNameOrOptions extends + | keyof PublicSchema["Tables"] + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + : never = never +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Update: infer U; + } + ? U + : never + : PublicTableNameOrOptions extends keyof PublicSchema["Tables"] + ? PublicSchema["Tables"][PublicTableNameOrOptions] extends { + Update: infer U; + } + ? U + : never + : never; + +export type Enums< + PublicEnumNameOrOptions extends + | keyof PublicSchema["Enums"] + | { schema: keyof Database }, + EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] + : never = never +> = PublicEnumNameOrOptions extends { schema: keyof Database } + ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] + : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"] + ? PublicSchema["Enums"][PublicEnumNameOrOptions] + : never; + +export type CompositeTypes< + PublicCompositeTypeNameOrOptions extends + | keyof PublicSchema["CompositeTypes"] + | { schema: keyof Database }, + CompositeTypeName extends PublicCompositeTypeNameOrOptions extends { + schema: keyof Database; + } + ? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"] + : never = never +> = PublicCompositeTypeNameOrOptions extends { schema: keyof Database } + ? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName] + : PublicCompositeTypeNameOrOptions extends keyof PublicSchema["CompositeTypes"] + ? PublicSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] + : never;