diff --git a/postgresql/schemas/db-1.sql b/postgresql/schemas/db-1.sql index 9430ce1..e3b3531 100644 --- a/postgresql/schemas/db-1.sql +++ b/postgresql/schemas/db-1.sql @@ -161,7 +161,7 @@ END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION real_medium.create_article(_title varchar(255), _slug varchar(255), _body text, _description text, _user_id text, _tags varchar(255)[]) +CREATE OR REPLACE FUNCTION real_medium.create_article_v1(_title varchar(255), _slug varchar(255), _body text, _description text, _user_id text, _tags varchar(255)[]) RETURNS text AS $$ DECLARE @@ -192,6 +192,8 @@ END; $$ LANGUAGE plpgsql; + + CREATE OR REPLACE FUNCTION real_medium.is_favorited_article(_article_id text, _user_id text = NULL) RETURNS bool AS $$ @@ -217,7 +219,7 @@ BEGIN username, bio, image, - CASE WHEN _follower_id = NULL THEN + CASE WHEN _follower_id IS NULL THEN FALSE ELSE real_medium.is_following(_id, _follower_id) @@ -230,7 +232,7 @@ END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile(_article_id text, _follower_id text = NULL) +CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile_v1(_article_id text, _follower_id text = NULL) RETURNS SETOF real_medium.tagged_article_with_author_profile AS $$ BEGIN @@ -259,7 +261,9 @@ END; $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile_by_slug(_slug varchar(255), _follower_id text = NULL) + + +CREATE OR REPLACE FUNCTION real_medium.get_article_with_author_profile_by_slug_v1(_slug varchar(255), _follower_id text = NULL) RETURNS SETOF real_medium.tagged_article_with_author_profile AS $$ DECLARE @@ -296,6 +300,8 @@ END; $$ LANGUAGE plpgsql; + + CREATE OR REPLACE FUNCTION real_medium.get_feed_articles(_user_id text, _limit int = 20, _offset int = 0) RETURNS SETOF real_medium.tagged_article_with_author_profile AS $$ @@ -400,5 +406,3 @@ LANGUAGE plpgsql; CREATE INDEX IF NOT EXISTS idx_createdat ON real_medium.articles(created_at DESC); CREATE INDEX IF NOT EXISTS idx_tagname ON real_medium.tag_list(tag_name); - - diff --git a/src/db/create_article.sql b/src/db/create_article.sql index 6f54a46..8e061bb 100644 --- a/src/db/create_article.sql +++ b/src/db/create_article.sql @@ -1 +1 @@ -SELECT real_medium.create_article($1, $2, $3, $4, $5, $6) +SELECT real_medium.create_article_v1($1, $2, $3, $4, $5, $6) diff --git a/src/db/get_article_with_author_profile.sql b/src/db/get_article_with_author_profile.sql index d34f16a..da8e9fe 100644 --- a/src/db/get_article_with_author_profile.sql +++ b/src/db/get_article_with_author_profile.sql @@ -1 +1 @@ -SELECT real_medium.get_article_with_author_profile($1, $2) +SELECT real_medium.get_article_with_author_profile_v1($1, $2) diff --git a/src/db/get_article_with_author_profile_by_slug.sql b/src/db/get_article_with_author_profile_by_slug.sql index 2fdb628..1a0d085 100644 --- a/src/db/get_article_with_author_profile_by_slug.sql +++ b/src/db/get_article_with_author_profile_by_slug.sql @@ -1 +1 @@ -SELECT real_medium.get_article_with_author_profile_by_slug($1, $2) +SELECT real_medium.get_article_with_author_profile_by_slug_v1($1, $2)