CREATE VIRTUAL TABLE "JMdict_KanjiElementFTS" USING FTS5("elementId" UNINDEXED, "reading");

CREATE TRIGGER "JMdict_KanjiElement_InsertFTS"
AFTER INSERT ON "JMdict_KanjiElement"
BEGIN
  INSERT INTO "JMdict_KanjiElementFTS"("elementId", "reading")
  VALUES (NEW."elementId", NEW."reading");
END;

CREATE TRIGGER "JMdict_KanjiElement_UpdateFTS"
AFTER UPDATE OF "elementId", "reading"
ON "JMdict_KanjiElement"
BEGIN
  UPDATE "JMdict_KanjiElementFTS"
  SET
    "elementId" = NEW."elementId",
    "reading" = NEW."reading"
  WHERE "elementId" = OLD."elementId";
END;

CREATE TRIGGER "JMdict_KanjiElement_DeleteFTS"
AFTER DELETE ON "JMdict_KanjiElement"
BEGIN
  DELETE FROM "JMdict_KanjiElementFTS"
  WHERE "elementId" = OLD."elementId";
END;



CREATE VIRTUAL TABLE "JMdict_ReadingElementFTS" USING FTS5("elementId" UNINDEXED, "reading");

CREATE TRIGGER "JMdict_ReadingElement_InsertFTS"
AFTER INSERT ON "JMdict_ReadingElement"
BEGIN
  INSERT INTO "JMdict_ReadingElementFTS"("elementId", "reading")
  VALUES (NEW."elementId", NEW."reading");
END;

CREATE TRIGGER "JMdict_ReadingElement_UpdateFTS"
AFTER UPDATE OF "elementId", "reading"
ON "JMdict_ReadingElement"
BEGIN
  UPDATE "JMdict_ReadingElementFTS"
  SET
    "elementId" = NEW."elementId",
    "reading" = NEW."reading"
  WHERE "elementId" = OLD."elementId";
END;

CREATE TRIGGER "JMdict_ReadingElement_DeleteFTS"
AFTER DELETE ON "JMdict_ReadingElement"
BEGIN
  DELETE FROM "JMdict_ReadingElementFTS"
  WHERE "elementId" = OLD."elementId";
END;
