fix: cql migration

This commit is contained in:
Namekuji 2023-09-09 01:49:05 -04:00
parent f9b8567f7c
commit ee71630842
No known key found for this signature in database
GPG key ID: 1D62332C07FBA532
2 changed files with 30 additions and 0 deletions

View file

@ -1,3 +1,5 @@
DROP MATERIALIZED VIEW IF EXISTS reaction_by_user_id;
DROP MATERIALIZED VIEW IF EXISTS reaction_by_id;
CREATE TYPE IF NOT EXISTS emoji ( CREATE TYPE IF NOT EXISTS emoji (
"name" text, "name" text,
"url" text, "url" text,
@ -5,3 +7,16 @@ CREATE TYPE IF NOT EXISTS emoji (
"height" int, "height" int,
); );
ALTER TABLE reaction ADD "emoji" frozen<emoji>; ALTER TABLE reaction ADD "emoji" frozen<emoji>;
CREATE MATERIALIZED VIEW IF NOT EXISTS reaction_by_user_id AS
SELECT * FROM reaction
WHERE "userId" IS NOT NULL
AND "createdAt" IS NOT NULL
AND "noteId" IS NOT NULL
PRIMARY KEY ("userId", "createdAt", "noteId")
WITH CLUSTERING ORDER BY ("createdAt" DESC);
CREATE MATERIALIZED VIEW IF NOT EXISTS reaction_by_id AS
SELECT * FROM reaction
WHERE "noteId" IS NOT NULL
AND "reaction" IS NOT NULL
AND "userId" IS NOT NULL
PRIMARY KEY ("noteId", "reaction", "userId");

View file

@ -1,2 +1,17 @@
DROP MATERIALIZED VIEW reaction_by_user_id;
DROP MATERIALIZED VIEW reaction_by_id;
ALTER TABLE reaction DROP "emoji"; ALTER TABLE reaction DROP "emoji";
DROP TYPE emoji; DROP TYPE emoji;
CREATE MATERIALIZED VIEW reaction_by_user_id AS
SELECT * FROM reaction
WHERE "userId" IS NOT NULL
AND "createdAt" IS NOT NULL
AND "noteId" IS NOT NULL
PRIMARY KEY ("userId", "createdAt", "noteId")
WITH CLUSTERING ORDER BY ("createdAt" DESC);
CREATE MATERIALIZED VIEW reaction_by_id AS
SELECT * FROM reaction
WHERE "noteId" IS NOT NULL
AND "reaction" IS NOT NULL
AND "userId" IS NOT NULL
PRIMARY KEY ("noteId", "reaction", "userId");