game1n / t8-cms

[WIP] A micro content management system
t8-cms.vercel.app
MIT License
8 stars 8 forks source link

Add capability to render markdown stored in DB #20

Open ps-89 opened 1 year ago

ps-89 commented 1 year ago

Ref: https://github.com/remarkjs/react-markdown

abhiandthetruth commented 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?

ps-89 commented 1 year ago

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.

abhiandthetruth commented 1 year ago

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.

ps-89 commented 1 year ago

@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.

Screenshot 2022-10-10 at 9 17 29 AM

The users table looks like below:

Screenshot 2022-10-10 at 9 20 43 AM
ps-89 commented 1 year ago

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);
abhiandthetruth commented 1 year ago

Yup will try the above queries. Will raise a PR with the docs and migration

ps-89 commented 1 year ago

@abhiandthetruth Do let me know if you're facing any issues or if more context is needed.

abhiandthetruth commented 1 year ago

@ps-89 will be able to start this on the weekend. Short on time rn

ps-89 commented 1 year ago

DB setup and instructions are done. The DDL file is present at ./resources/postgres/t8_ddl.sql.