Categories that uses in articles
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
title | varchar( 255 ) | name of category | |
Indexes | |||
article_categories_pkey | ON id |
Table for likes. Contains user and article reference. User can like (add row) and unlike (delete row) article.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | user_id | integer | user reference |
* | article_id | integer | |
Indexes | |||
article_likes_user_id_comment_id_unique | ON user_id, article_id | ||
article_likes_article_id_index | ON article_id | ||
article_likes_user_id_index | ON user_id | ||
Foreign Keys | |||
fk_likes_articles_1 | ( article_id ) ref articles (id) | ||
fk_likes_users_1 | ( user_id ) ref users (id) |
Statuses for articles. For example, "on moderation", "publish", "banned" etc.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
title | varchar( 255 ) | name of article status | |
Indexes | |||
article_statuses_pkey | ON id |
Article entity.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | serial AUTOINCREMENT | |
* | created_at | timestamptz DEFAULT now() | date of creation |
* | updated_at | timestamptz DEFAULT now() | date of last update |
removed_at | timestamptz | date of removing article | |
* | title | varchar( 1024 ) | name of article |
* | content | text | content of article |
* | author_id | integer | reference to author of article |
* | article_status_id | integer | reference to article status |
* | language_id | integer | reference to language |
category_id | integer | regerenct to article category | |
image | varchar( 255 ) | link to the image | |
Indexes | |||
articles_pkey | ON id | ||
articles_article_status_id_idx | ON article_status_id | ||
articles_author_id_idx | ON author_id | ||
articles_category_id_idx | ON category_id | ||
articles_created_at_idx | ON created_at | ||
articles_language_id_idx | ON language_id | ||
articles_removed_at_idx | ON removed_at | ||
articles_updated_at_idx | ON updated_at | ||
Foreign Keys | |||
fk_articles_categories_1 | ( category_id ) ref article_categories (id) | ||
fk_articles_article_statuses_1 | ( article_status_id ) ref article_statuses (id) | ||
fk_articles_languages_1 | ( language_id ) ref languages (id) | ||
fk_articles_users_1 | ( author_id ) ref users (id) | ||
Triggers | |||
t_articles_upd | CREATE TRIGGER t_articles_upd BEFORE UPDATE ON public.articles FOR EACH ROW EXECUTE PROCEDURE upd_updated_at() |
Table for comment likes. User can add (create row) or remove (delete row) only one like.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | user_id | integer | reference to user |
* | comment_id | integer | regerence to comment |
Indexes | |||
comment_likes_user_id_comment_id_unique | ON user_id, comment_id | ||
comment_likes_comment_id_index | ON comment_id | ||
comment_likes_user_id_index | ON user_id | ||
Foreign Keys | |||
fk_comment_likes_comments_1 | ( comment_id ) ref comments (id) | ||
fk_comment_likes_users_1 | ( user_id ) ref users (id) |
Comment entity. Can be relative on parent comment (needed for creating recursive tree of comments with answers).
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | serial AUTOINCREMENT | |
* | created_at | timestamptz DEFAULT now() | date of creating comment |
* | updated_at | timestamptz DEFAULT now() | date of last updating |
removed_at | timestamptz | date of removing | |
* | author_id | integer | user that create comment |
* | article_id | integer | reference to article |
parent_id | integer | reference to parent comment for recursive showing | |
content | text | main content of comment | |
Indexes | |||
comments_pkey | ON id | ||
comments_article_id_idx | ON article_id | ||
comments_author_id_idx | ON author_id | ||
comments_created_at_idx | ON created_at | ||
comments_parent_id_idx | ON parent_id | ||
comments_removed_at_idx | ON removed_at | ||
comments_updated_at_idx | ON updated_at | ||
Foreign Keys | |||
fk_comments_articles_1 | ( article_id ) ref articles (id) | ||
fk_comments_comments_1 | ( parent_id ) ref comments (id) | ||
fk_comments_users_1 | ( author_id ) ref users (id) | ||
Triggers | |||
t_comments_upd | CREATE TRIGGER t_comments_upd BEFORE UPDATE ON public.comments FOR EACH ROW EXECUTE PROCEDURE upd_updated_at() |
Realisation of ability for subscribing to another user activity (publish new articles).
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | follower_id | integer | reference to user that want to subscribe |
* | author_id | integer | publisher |
Indexes | |||
followers_follower_id_author_id_uindex | ON follower_id, author_id | ||
followers_author_id_index | ON author_id | ||
followers_follower_id_index | ON follower_id | ||
Foreign Keys | |||
fk_followers_users_1 | ( follower_id ) ref users (id) | ||
fk_followers_users_2 | ( author_id ) ref users (id) |
Dictionary for available languages.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
iso_639-1 | varchar( 255 ) | iso-631-1 view ("en") | |
title | varchar( 255 ) | full name of language | |
Indexes | |||
languages_pkey | ON id |
List of available log actions.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
title | varchar( 255 ) | name of action | |
Indexes | |||
log_actions_pkey | ON id |
Realization of simple log system. For controlling some users activities.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | created_at | timestamptz DEFAULT now() | date of creation event |
* | action_id | integer | reference to log-action |
user_id | integer | reference to user that was envolved or that was used in the action | |
admin_id | integer | reference to user with admin role that create action | |
thread_id | integer | reference to thread if its entity was used in the action | |
article_id | integer | reference to article_id if this entity was used in the action | |
comment_id | integer | reference to comment_id if this entity was used in the action | |
* | metadata | jsonb | additional fields for action that don't have strictly structure |
Indexes | |||
logs_action_id_idx | ON action_id | ||
logs_admin_id_idx | ON admin_id | ||
logs_article_id_idx | ON article_id | ||
logs_comment_id_idx | ON comment_id | ||
logs_created_at_idx | ON created_at | ||
logs_metadata_idx | ON metadata | ||
logs_thread_id_idx | ON thread_id | ||
logs_user_id_idx | ON user_id | ||
Foreign Keys | |||
fk_logs_articles_1 | ( article_id ) ref articles (id) | ||
fk_logs_comments_1 | ( comment_id ) ref comments (id) | ||
fk_logs_log_actions_1 | ( action_id ) ref log_actions (id) | ||
fk_logs_threads_1 | ( thread_id ) ref threads (id) | ||
fk_logs_users_1 | ( user_id ) ref users (id) | ||
fk_logs_users_2 | ( admin_id ) ref users (id) |
List of permissions.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
title | varchar( 255 ) | name of permission | |
Indexes | |||
permissions_pkey | ON id |
Mapping role to permissions. One to many.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | role_id | integer | reference to role |
* | permission_id | integer | reference to permission |
Foreign Keys | |||
fk_role_to_permission_permissions_1 | ( role_id ) ref permissions (id) | ||
fk_role_to_permission_roles_1 | ( permission_id ) ref roles (id) |
Available roles.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
title | varchar( 255 ) | name of role | |
Indexes | |||
roles_pkey | ON id |
List of available tags of articles.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | serial AUTOINCREMENT | |
* | title | varchar( 255 ) | name of tag |
Indexes | |||
tags_pkey | ON id |
Mapping tags to articles.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | article_id | integer | reference to article |
* | tags_id | integer | reference to tag |
Indexes | |||
tags_to_articles_article_id_idx | ON article_id | ||
tags_to_articles_tags_id_idx | ON tags_id | ||
tags_to_articles_article_id_tags_id_unique_idx | ON article_id, tags_id | ||
Foreign Keys | |||
fk_tags_to_articles_articles_1 | ( article_id ) ref articles (id) | ||
fk_tags_to_articles_tags_1 | ( tags_id ) ref tags (id) |
Dictionary of thread priorities. User can set priority of thread for emergency messages.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
title | varchar( 255 ) | kind of priority | |
Indexes | |||
thread_priorities_pkey | ON id |
Chat-room with user and admin.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | serial AUTOINCREMENT | |
* | created_at | timestamptz DEFAULT now() | date of creating |
* | priority_id | integer | reference to priority |
* | user_id | integer | reference to user |
* | admin_id | integer | reference to user with role admin |
* | status_id | integer | |
Indexes | |||
threads_pkey | ON id | ||
threads_admin_id_idx | ON admin_id | ||
threads_created_at_idx | ON created_at | ||
threads_user_id_idx | ON user_id | ||
Foreign Keys | |||
fk_threads_thread_priorities_1 | ( priority_id ) ref thread_priorities (id) | ||
fk_threads_threads_statuses_1 | ( status_id ) ref threads_statuses (id) | ||
fk_threads_users_1 | ( user_id ) ref users (id) | ||
fk_threads_users_2 | ( admin_id ) ref users (id) |
Messages inside threads between users and admins.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | serial AUTOINCREMENT | |
* | thread_id | integer | reference to chat-room |
* | created_at | timestamptz DEFAULT now() | date of creating |
* | updated_at | timestamptz DEFAULT now() | date of last updating |
removed_at | timestamptz | date of removing | |
* | user_id | integer | reference to user that create message |
content | text | content of message | |
Indexes | |||
threads_messages_pkey | ON id | ||
threads_messages_thread_id_created_at_ids | ON thread_id, created_at | ||
Foreign Keys | |||
fk_threads_messages_threads_1 | ( thread_id ) ref threads (id) | ||
fk_threads_messages_users_1 | ( user_id ) ref users (id) | ||
Triggers | |||
t_threads_messages_upd | CREATE TRIGGER t_threads_messages_upd BEFORE UPDATE ON public.threads_messages FOR EACH ROW EXECUTE PROCEDURE upd_updated_at() |
Dictionary with threads statuses. Threads can be "closed" for example if problem of user was resolved.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
title | varchar( 255 ) | name of thread status | |
Indexes | |||
threads_statuses_pkey | ON id |
List of available timezones.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
title | varchar( 255 ) | name of timezone ("Europe/Kiev") | |
Indexes | |||
timezones_pkey | ON id |
List of user internal statuses that used for system defining.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
* | title | varchar( 255 ) | name of internal status |
Indexes | |||
user_internal_statuses_pkey | ON id |
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | smallserial AUTOINCREMENT | |
title | varchar( 255 ) | name of status | |
Indexes | |||
user_statuses_pkey | ON id |
Mapping user to role.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | user_id | integer | reference to user |
* | role_id | integer | reference to role |
* | created_at | timestamptz DEFAULT now() | date of creation |
Indexes | |||
user_to_role_user_id_idx | ON user_id, role_id | ||
Foreign Keys | |||
fk_user_to_role_roles_1 | ( role_id ) ref roles (id) | ||
fk_user_to_role_users_1 | ( user_id ) ref users (id) |
User entity.
Idx | Field Name | Data Type | Description |
---|---|---|---|
* | id | serial AUTOINCREMENT | |
* | created_at | timestamptz DEFAULT now() | date of create |
* | updated_at | timestamptz DEFAULT now() | date of last change |
removed_at | timestamptz | date of remove or ban | |
* | varchar( 255 ) | email of user that needs for registration | |
phone | varchar( 255 ) | not required fields with phone-number | |
* | password | varchar( 255 ) | hash of password |
* | status_id | integer | reference to user status |
* | language_id | integer | reference to language |
* | timezone_id | integer | reference to user timezone |
* | nickname | varchar( 255 ) | user nickname |
birthday | date | date of birth | |
image | varchar( 255 ) | link to avatar | |
internal_status_id | integer | reference to internal user status | |
Indexes | |||
users_pkey | ON id | ||
users_email_idx | ON email | ||
users_nickname_idx | ON nickname | ||
users_created_at_idx | ON created_at | ||
users_updated_at_idx | ON updated_at | ||
Foreign Keys | |||
fk_users_languages_1 | ( language_id ) ref languages (id) | ||
fk_users_timezones_1 | ( timezone_id ) ref timezones (id) | ||
fk_users_user_types_1 | ( internal_status_id ) ref user_internal_statuses (id) | ||
fk_users_user_statuses_1 | ( status_id ) ref user_statuses (id) | ||
Triggers | |||
t_users_upd | CREATE TRIGGER t_users_upd BEFORE UPDATE ON public.users FOR EACH ROW EXECUTE PROCEDURE upd_updated_at() |
Procedures | Description |
---|---|
upd_updated_at | Procedure for triggering update columns and setting current timestamp in 'updated_at'-field. |