Skip to content

Commit

Permalink
try out supabase migration
Browse files Browse the repository at this point in the history
  • Loading branch information
martypdx committed Nov 1, 2023
1 parent bcdd3cb commit 0ce1d11
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .env.example
@@ -1,3 +1,5 @@
# General supabase access token (all projects)
SUPABASE_ACCESS_TOKEN=
# Supabase Project
SUPABASE_DB_PASSWORD=
SUPABASE_PROJECT_ID=
14 changes: 14 additions & 0 deletions supabase/migrations/20231101213201_healer.sql
@@ -0,0 +1,14 @@
create table "public"."healer" (
"id" bigint generated by default as identity not null,
"created_at" timestamp with time zone not null default now(),
"name" text not null,
"content" text not null,
"avatar" text
);


CREATE UNIQUE INDEX healer_pkey ON public.healer USING btree (id);

alter table "public"."healer" add constraint "healer_pkey" PRIMARY KEY using index "healer_pkey";


28 changes: 28 additions & 0 deletions supabase/migrations/20231101215311_waitlist.sql
@@ -0,0 +1,28 @@
create extension if not exists "citext" with schema "public" version '1.6';

create table "public"."waitlist" (
"id" bigint generated always as identity not null,
"created_at" timestamp with time zone not null default now(),
"email" citext not null
);


alter table "public"."waitlist" enable row level security;

CREATE UNIQUE INDEX email_unique ON public.waitlist USING btree (email);

CREATE UNIQUE INDEX waitlist_pk ON public.waitlist USING btree (id);

alter table "public"."waitlist" add constraint "waitlist_pk" PRIMARY KEY using index "waitlist_pk";

alter table "public"."waitlist" add constraint "email_unique" UNIQUE using index "email_unique";

create policy "Enable insert for public"
on "public"."waitlist"
as permissive
for insert
to public
with check (true);



29 changes: 0 additions & 29 deletions supabase/seed.sql
@@ -1,29 +0,0 @@
-- Table: public.waitlist

-- case insensitive column type
CREATE EXTENSION IF NOT EXISTS citext;

DROP TABLE IF EXISTS public.waitlist;
CREATE TABLE IF NOT EXISTS public.waitlist
(
id int8 NOT NULL GENERATED ALWAYS AS IDENTITY,
created_at timestamp with time zone NOT NULL DEFAULT now(),
email citext NOT NULL,
CONSTRAINT waitlist_pk PRIMARY KEY(id),
CONSTRAINT email_unique UNIQUE(email)
) TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.waitlist
ENABLE ROW LEVEL SECURITY;

GRANT ALL ON TABLE public.waitlist TO anon;
GRANT ALL ON TABLE public.waitlist TO authenticated;
GRANT ALL ON TABLE public.waitlist TO postgres;
GRANT ALL ON TABLE public.waitlist TO service_role;
GRANT ALL ON TABLE public.waitlist TO supabase_admin;

DROP POLICY IF EXISTS "Enable insert for public" ON public.waitlist;
CREATE POLICY "Enable insert for public" ON public.waitlist
AS PERMISSIVE FOR INSERT
TO public
WITH CHECK (true);
29 changes: 29 additions & 0 deletions supabase/waitlist.sql
@@ -0,0 +1,29 @@
-- Table: public.waitlist

-- case insensitive column type
CREATE EXTENSION IF NOT EXISTS citext;

DROP TABLE IF EXISTS public.waitlist;
CREATE TABLE IF NOT EXISTS public.waitlist
(
id int8 NOT NULL GENERATED ALWAYS AS IDENTITY,
created_at timestamp with time zone NOT NULL DEFAULT now(),
email citext NOT NULL,
CONSTRAINT waitlist_pk PRIMARY KEY(id),
CONSTRAINT email_unique UNIQUE(email)
) TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.waitlist
ENABLE ROW LEVEL SECURITY;

GRANT ALL ON TABLE public.waitlist TO anon;
GRANT ALL ON TABLE public.waitlist TO authenticated;
GRANT ALL ON TABLE public.waitlist TO postgres;
GRANT ALL ON TABLE public.waitlist TO service_role;
GRANT ALL ON TABLE public.waitlist TO supabase_admin;

DROP POLICY IF EXISTS "Enable insert for public" ON public.waitlist;
CREATE POLICY "Enable insert for public" ON public.waitlist
AS PERMISSIVE FOR INSERT
TO public
WITH CHECK (true);

0 comments on commit 0ce1d11

Please sign in to comment.