Open ps-89 opened 1 year ago
@ps-89 facing difficulty while connecting to supabase, mostly because tables do not exist. Are we supposed to construct the tables manually in supabase? If yes, should we not have migrations etc to have this automatically constructed?
There's missing docs around the DB schema, the migrations should be there ideally. What I'm thinking of is moving away from supabase or using some abstraction to hide supabase's integration underneath(cue for an interesting task to take up if someone's interested) which could be swapped with some other backend service.
Will update the schema and instructions to run the project with proper env variables to point to one's own supabase URL in some time.
Yeah that is a good thought in my opinion. Making a codebase database agnostic is best. We can limit the db interaction to a specific layer in the code. Kind of a wrapper on the db calls. That would be a major redesign tho. For tracking purposes you can create a separate issue for this and also for the docs too.
@abhiandthetruth You can refer below screenshot for setting up your own schema on a personal supabase account, I'll set up the SQL DDL file later. Will create the issues too in some time.
The users table looks like below:
Here's the schema that my PG frontend client shows for the tables, feel free to clean up these and use to setup your own tables, as well as raise a PR to include these in a DDL migration file. For actual SQL DDL for migration, some cleaning up will be required.
-- Table Definition ----------------------------------------------
CREATE TABLE blogs (
id uuid NOT NULL,
"createdAt" timestamp with time zone DEFAULT now(),
title text DEFAULT ''::text,
description character varying,
"readingTime" smallint,
tags character varying[],
"blogId" uuid DEFAULT uuid_generate_v4() UNIQUE PRIMARY KEY,
heading character varying,
"publisherName" text,
"blogImage" character varying
);
COMMENT ON TABLE blogs IS 'cms-blogs';
-- Indices -------------------------------------------------------
CREATE UNIQUE INDEX blogs_blog_id_key ON blogs("blogId" uuid_ops);
CREATE UNIQUE INDEX blogs_pkey ON blogs("blogId" uuid_ops);
-- Table Definition ----------------------------------------------
CREATE TABLE users (
id text PRIMARY KEY,
"createdAt" timestamp with time zone DEFAULT now(),
"fullName" character varying,
phone text
);
-- Indices -------------------------------------------------------
CREATE UNIQUE INDEX users_pkey ON users(id text_ops);
Yup will try the above queries. Will raise a PR with the docs and migration
@abhiandthetruth Do let me know if you're facing any issues or if more context is needed.
@ps-89 will be able to start this on the weekend. Short on time rn
DB setup and instructions are done. The DDL file is present at ./resources/postgres/t8_ddl.sql
.
Ref: https://github.com/remarkjs/react-markdown