github.com/supabase/cli@v1.168.1/internal/migration/squash/testdata/before.sql (about)

     1  
     2  SET statement_timeout = 0;
     3  SET lock_timeout = 0;
     4  SET idle_in_transaction_session_timeout = 0;
     5  SET client_encoding = 'UTF8';
     6  SET standard_conforming_strings = on;
     7  SELECT pg_catalog.set_config('search_path', '', false);
     8  SET check_function_bodies = false;
     9  SET xmloption = content;
    10  SET client_min_messages = warning;
    11  SET row_security = off;
    12  
    13  CREATE SCHEMA IF NOT EXISTS "storage";
    14  
    15  ALTER SCHEMA "storage" OWNER TO "supabase_admin";
    16  
    17  CREATE OR REPLACE FUNCTION "storage"."can_insert_object"("bucketid" "text", "name" "text", "owner" "uuid", "metadata" "jsonb") RETURNS "void"
    18      LANGUAGE "plpgsql"
    19      AS $$
    20  BEGIN
    21    INSERT INTO "storage"."objects" ("bucket_id", "name", "owner", "metadata") VALUES (bucketid, name, owner, metadata);
    22    -- hack to rollback the successful insert
    23    RAISE sqlstate 'PT200' using
    24    message = 'ROLLBACK',
    25    detail = 'rollback successful insert';
    26  END
    27  $$;
    28  
    29  ALTER FUNCTION "storage"."can_insert_object"("bucketid" "text", "name" "text", "owner" "uuid", "metadata" "jsonb") OWNER TO "supabase_storage_admin";
    30  
    31  CREATE TABLE IF NOT EXISTS "storage"."objects" (
    32      "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL,
    33      "bucket_id" "text",
    34      "name" "text",
    35      "owner" "uuid",
    36      "created_at" timestamp with time zone DEFAULT "now"(),
    37      "updated_at" timestamp with time zone DEFAULT "now"(),
    38      "last_accessed_at" timestamp with time zone DEFAULT "now"(),
    39      "metadata" "jsonb",
    40      "path_tokens" "text"[] GENERATED ALWAYS AS ("string_to_array"("name", '/'::"text")) STORED,
    41      "version" "text",
    42      "owner_id" "text"
    43  );
    44  
    45  ALTER TABLE "storage"."objects" OWNER TO "supabase_storage_admin";
    46  
    47  COMMENT ON COLUMN "storage"."objects"."owner" IS 'Field is deprecated, use owner_id instead';
    48  
    49  ALTER TABLE ONLY "storage"."buckets"
    50      ADD CONSTRAINT "buckets_pkey" PRIMARY KEY ("id");
    51  
    52  ALTER TABLE ONLY "storage"."migrations"
    53      ADD CONSTRAINT "migrations_name_key" UNIQUE ("name");
    54  
    55  ALTER TABLE ONLY "storage"."migrations"
    56      ADD CONSTRAINT "migrations_pkey" PRIMARY KEY ("id");
    57  
    58  ALTER TABLE ONLY "storage"."objects"
    59      ADD CONSTRAINT "objects_pkey" PRIMARY KEY ("id");
    60  
    61  CREATE UNIQUE INDEX "bname" ON "storage"."buckets" USING "btree" ("name");
    62  
    63  CREATE UNIQUE INDEX "bucketid_objname" ON "storage"."objects" USING "btree" ("bucket_id", "name");
    64  
    65  CREATE INDEX "name_prefix_search" ON "storage"."objects" USING "btree" ("name" "text_pattern_ops");
    66  
    67  CREATE OR REPLACE TRIGGER "update_objects_updated_at" BEFORE UPDATE ON "storage"."objects" FOR EACH ROW EXECUTE FUNCTION "storage"."update_updated_at_column"();
    68  
    69  ALTER TABLE ONLY "storage"."objects"
    70      ADD CONSTRAINT "objects_bucketId_fkey" FOREIGN KEY ("bucket_id") REFERENCES "storage"."buckets"("id");
    71  
    72  ALTER TABLE "storage"."buckets" ENABLE ROW LEVEL SECURITY;
    73  
    74  ALTER TABLE "storage"."migrations" ENABLE ROW LEVEL SECURITY;
    75  
    76  ALTER TABLE "storage"."objects" ENABLE ROW LEVEL SECURITY;
    77  
    78  GRANT ALL ON SCHEMA "storage" TO "postgres";
    79  GRANT USAGE ON SCHEMA "storage" TO "anon";
    80  GRANT USAGE ON SCHEMA "storage" TO "authenticated";
    81  GRANT USAGE ON SCHEMA "storage" TO "service_role";
    82  GRANT ALL ON SCHEMA "storage" TO "supabase_storage_admin";
    83  GRANT ALL ON SCHEMA "storage" TO "dashboard_user";
    84  
    85  ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "storage" GRANT ALL ON SEQUENCES  TO "postgres";
    86  ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "storage" GRANT ALL ON SEQUENCES  TO "anon";
    87  ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "storage" GRANT ALL ON SEQUENCES  TO "authenticated";
    88  ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "storage" GRANT ALL ON SEQUENCES  TO "service_role";
    89  
    90  RESET ALL;