From a64f233641fcbfea58e7a2c5996cd735464b057f Mon Sep 17 00:00:00 2001 From: Oleg Silkin Date: Sun, 19 May 2019 02:24:20 -0400 Subject: [PATCH] Removes triggers & adds default channel for anonymous comments --- comments_ddl.sql => schema/comments_ddl.sql | 26 +++++---------------- 1 file changed, 6 insertions(+), 20 deletions(-) rename comments_ddl.sql => schema/comments_ddl.sql (76%) diff --git a/comments_ddl.sql b/schema/comments_ddl.sql similarity index 76% rename from comments_ddl.sql rename to schema/comments_ddl.sql index 895813f..a34870b 100644 --- a/comments_ddl.sql +++ b/schema/comments_ddl.sql @@ -2,8 +2,9 @@ PRAGMA FOREIGN_KEYS = ON; -- tables -DROP TABLE IF EXISTS COMMENT; -DROP TABLE IF EXISTS CHANNEL; +-- DROP TABLE IF EXISTS COMMENT; +-- DROP TABLE IF EXISTS CHANNEL; + CREATE TABLE IF NOT EXISTS CHANNEL( ClaimId TEXT NOT NULL, Name TEXT NOT NULL, @@ -33,23 +34,6 @@ CREATE TABLE IF NOT EXISTS COMMENT ( DROP INDEX IF EXISTS COMMENT_CLAIM_INDEX; CREATE INDEX COMMENT_CLAIM_INDEX ON COMMENT (LbryClaimId); --- triggers -DROP TRIGGER IF EXISTS CHANNEL_INSERT_VALIDATE; -CREATE TRIGGER CHANNEL_INSERT_VALIDATE - BEFORE INSERT ON CHANNEL - WHEN NOT (0 < LENGTH(NEW.Name AND LENGTH(NEW.Name) < 256)) - BEGIN - SELECT RAISE(FAIL, 'EITHER CHANNEL_ID OR CHANNEL_NAME ARE INVALID LENGTH'); - END; - --- todo: remove this shit -DROP TRIGGER IF EXISTS COMMENT_INSERT_VALIDATE; -CREATE TRIGGER COMMENT_INSERT_VALIDATE - BEFORE INSERT ON COMMENT - WHEN NOT (0 < LENGTH(NEW.Body) AND LENGTH(NEW.Body) <= 2000) - BEGIN - SELECT RAISE(FAIL, 'INVALID COMMENT BODY LENGTH'); - end; -- VIEWS DROP VIEW IF EXISTS COMMENTS_ON_CLAIMS; @@ -70,4 +54,6 @@ CREATE VIEW COMMENT_REPLIES (Author, CommentBody, ParentAuthor, ParentCommentBod JOIN CHANNEL AS AUTHOR ON OG.ChannelId = AUTHOR.ClaimId ORDER BY OG.Timestamp; - +-- this is the default channel for anyone who wants to publish anonymously +INSERT INTO CHANNEL +VALUES ('9cb713f01bf247a0e03170b5ed00d5161340c486', '@Anonymous'); \ No newline at end of file