30-day-mini-habit

Build at Hackathon challenge 🏆 Goal-tracking app

Getting Started with Create React App

Using Netlify Serverless Functions with Netlify Dev

Authentication

-- Create a table for public "profiles"
create table profiles (
  id uuid references auth.users not null,
  updated_at timestamp with time zone,
  username text unique,
  avatar_url text,
  about text,

  primary key (id),
  unique(username),
  constraint username_length check (char_length(username) >= 3)
);
- security
alter table profiles enable row level security;

-- create policy "Public profiles are viewable by everyone."
--   on profiles for select
--   using ( true );

create policy "Users can insert their own profile."
  on profiles for insert
  with check ( auth.uid() = id );

create policy "Users can update own profile."
  on profiles for update
  using ( auth.uid() = id );
- no need for real time or storage.

Sign in, Sign up

Table habit

-- Create a table for public "profiles"
create table habit (
  id bigint generated by default as identity primary key,
  user_id uuid references auth.users not null,
  habit_name text not null,
  start_date date not null,
  end_date date not null,
  reminder_time json,
  reminder_type json,
  inserted_at timestamp with time zone default timezone('utc'::text, now()) not null
);


alter table habit enable row level security;

create policy "Individuals can create habit." on habit for
    insert with check (auth.uid() = user_id);

create policy "Individuals can view their own habit. " on habit for
    select using (auth.uid() = user_id);

create policy "Individuals can update their own habit." on habit for
    update using (auth.uid() = user_id);

create policy "Individuals can delete their own habit." on habit for
    delete using (auth.uid() = user_id);


Table habit_track

Cron