diff options
Diffstat (limited to 'db/rest/post/api_post_insert.sql')
-rw-r--r-- | db/rest/post/api_post_insert.sql | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/db/rest/post/api_post_insert.sql b/db/rest/post/api_post_insert.sql deleted file mode 100644 index 8b2eb48..0000000 --- a/db/rest/post/api_post_insert.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE FUNCTION _api.post_insert() -RETURNS TRIGGER -LANGUAGE plpgsql VOLATILE -AS $BODY$ -DECLARE - _user_id INTEGER; -BEGIN - _user_id = _api.get_user_id(); - - NEW.content := _api.trim(NEW.content); - - PERFORM _api.validate_text( - _text => NEW.content, - _column => 'content', - _min => 1, - _max => 4096 - ); - - INSERT INTO admin.post ( - user_id, - content - ) VALUES ( - _user_id, - NEW.content - ); - - RETURN NEW; -END -$BODY$; - -GRANT EXECUTE ON FUNCTION _api.post_insert() - TO rest_user; -GRANT INSERT ON TABLE api.post - TO rest_user; -GRANT INSERT ON TABLE admin.post - TO rest_user; -GRANT UPDATE ON TABLE sys.post_id_seq - TO rest_user; - -CREATE TRIGGER api_post_insert_trgr - INSTEAD OF INSERT - ON api.post - FOR EACH ROW - EXECUTE PROCEDURE _api.post_insert(); |