Removes triggers & adds default channel for anonymous comments

This commit is contained in:
Oleg Silkin 2019-05-19 02:24:20 -04:00
parent 2cad79f1ba
commit a64f233641

View file

@ -2,8 +2,9 @@
PRAGMA FOREIGN_KEYS = ON; PRAGMA FOREIGN_KEYS = ON;
-- tables -- tables
DROP TABLE IF EXISTS COMMENT; -- DROP TABLE IF EXISTS COMMENT;
DROP TABLE IF EXISTS CHANNEL; -- DROP TABLE IF EXISTS CHANNEL;
CREATE TABLE IF NOT EXISTS CHANNEL( CREATE TABLE IF NOT EXISTS CHANNEL(
ClaimId TEXT NOT NULL, ClaimId TEXT NOT NULL,
Name TEXT NOT NULL, Name TEXT NOT NULL,
@ -33,23 +34,6 @@ CREATE TABLE IF NOT EXISTS COMMENT (
DROP INDEX IF EXISTS COMMENT_CLAIM_INDEX; DROP INDEX IF EXISTS COMMENT_CLAIM_INDEX;
CREATE INDEX COMMENT_CLAIM_INDEX ON COMMENT (LbryClaimId); 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 -- VIEWS
DROP VIEW IF EXISTS COMMENTS_ON_CLAIMS; 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 JOIN CHANNEL AS AUTHOR ON OG.ChannelId = AUTHOR.ClaimId
ORDER BY OG.Timestamp; ORDER BY OG.Timestamp;
-- this is the default channel for anyone who wants to publish anonymously
INSERT INTO CHANNEL
VALUES ('9cb713f01bf247a0e03170b5ed00d5161340c486', '@Anonymous');