Moves table declaration in DDL so table drops happen properly when needed

This commit is contained in:
Oleg Silkin 2019-05-23 06:33:07 -04:00
parent 6c94363ca2
commit 3298f23ce8

View file

@ -5,15 +5,7 @@ PRAGMA FOREIGN_KEYS = ON;
-- DROP TABLE IF EXISTS COMMENT;
-- DROP TABLE IF EXISTS CHANNEL;
CREATE TABLE IF NOT EXISTS CHANNEL(
ClaimId TEXT NOT NULL,
Name TEXT NOT NULL,
CONSTRAINT CHANNEL_PK PRIMARY KEY (ClaimId)
ON CONFLICT IGNORE
);
-- DROP TABLE IF EXISTS COMMENT;
DROP TABLE IF EXISTS COMMENT;
CREATE TABLE IF NOT EXISTS COMMENT (
CommentId TEXT NOT NULL,
LbryClaimId TEXT NOT NULL,
@ -30,6 +22,15 @@ CREATE TABLE IF NOT EXISTS COMMENT (
ON UPDATE CASCADE ON DELETE NO ACTION -- setting null implies comment is top level
);
DROP TABLE IF EXISTS CHANNEL;
CREATE TABLE IF NOT EXISTS CHANNEL(
ClaimId TEXT NOT NULL,
Name TEXT NOT NULL,
CONSTRAINT CHANNEL_PK PRIMARY KEY (ClaimId)
ON CONFLICT IGNORE
);
-- indexes
-- DROP INDEX IF EXISTS COMMENT_CLAIM_INDEX;
CREATE INDEX IF NOT EXISTS COMMENT_CLAIM_INDEX ON COMMENT (LbryClaimId);