I have been trying to perform a simple select oper...
# flutter
p
I have been trying to perform a simple select operation but I am still getting permission errors. It been days and I have tried everything to get this to work. I would sincerely appreciate any help I can get. If not, I guess I have to forget and abandon Supabase until it is more matured with fixes to such things. I am 20 days late behind schedule and I am stuck on this permission thing.
h
so sorry to hear that. Can you provide more detail
s
@User Please share the exact error and we can go from there.
p
Hello @User @User , sorry for the late reply. I am working on a appointment app for my project and I wanted to keep it simple and avoid Firebase at all cost.
So I created a project, and here is the sql command to create the tables, add triggers, and set policies
Copy code
sql
-- start a transaction
begin;

-- drop the public schema and recreate it
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;
COMMENT ON SCHEMA public IS 'standard public schema';

-- enable extensions
create extension if not exists "uuid-ossp" with schema extensions;
create extension if not exists moddatetime schema extensions;


-- create custom types
create type public.gender as enum('male', 'female');
create type public.appointment_type as enum('drive_through', 'drive_over');
create type public.appointment_status as enum('pending', 'assigned', 'completed' );

-- create tables with comments
-- PROFILES
create table if not exists public.profiles(
  id uuid references auth.users  primary key,
  username text unique not null,
  avatar_url text,
  first_name text,
  last_name text,
  other_names text,
  gender gender,
  email text,
  phone text,
  created_at timestamp with time zone default now() not null,
  updated_at timestamp with time zone default now() not null
);
comment on table public.profiles is 'all profiles for the users';
comment on column public.profiles.id is 'references the private auth user';
comment on column public.profiles.username is 'a unique name to identify the user';
I don't mind sharing the full source code of the project here but for sake of brevity, let me share only the relevant files here
Copied from the flutter quiz demo https://github.com/phamhieu/supabase-flutter-demo
This handles authentication in the app
This is where I perform crud operations to Supabase.
Please let me know if there's anything you would want me to provide to help me fix this issue. sincerely appreciate your help 🙏
Here is the error I get when I try to perform a select or insert operation.
Copy code
{
flutter: │ 💡   "data": null,
flutter: │ 💡   "status": 403,
flutter: │ 💡   "error": {
flutter: │ 💡     "message": "permission denied for table products",
flutter: │ 💡     "details": null,
flutter: │ 💡     "hint": null,
flutter: │ 💡     "code": "42501"
flutter: │ 💡   },
flutter: │ 💡   "count": null
flutter: │ 💡 }
Here is my pubspec.yaml