Creating the comments table
First and foremost, we need a table to store our comments data. We want to keep the data structure of a comment as simple as possible – in our case, the comment is a piece of written text with a specific creation date and an author.
With the primary key, every comment will get a unique ID. Also, a comment will point to the ticket it belongs to (a relation). Adding a tenant-comment relation to the comments
table isn’t a necessity as the related ticket (which has a tenant relation) would imply who the tenant is. But, to be able to use simpler RLS expressions, we’ll also add the tenant reference to each comment.
So, go to the Table Editor and create a comments
table. It will consist of the following columns: id
, comment_text
, created_by
(the author), created_at
, ticket
(the reference), tenant
, and author_1name
(to cache the author). I will spare you from the explanation of how to create the table, but here’s a screenshot of...