CREATE TABLE story_step_entity (
  id TEXT PRIMARY KEY,
  local_id TEXT NOT NULL,
  type INTEGER NOT NULL,
  parent_id TEXT,
  url TEXT,
  path TEXT,
  text TEXT,
  checked BOOLEAN NOT NULL,
  position INTEGER NOT NULL,
  document_id TEXT NOT NULL,
  is_group BOOLEAN NOT NULL,
  has_inner_steps BOOLEAN NOT NULL,
  background_color INTEGER,
  tags TEXT NOT NULL,
  spans TEXT NOT NULL,
  link_to_document TEXT
);

selectByDocumentId:
SELECT *
FROM story_step_entity
WHERE document_id = ?;

insert:
INSERT INTO story_step_entity(id, local_id, type, parent_id, url, path, text, checked, position, document_id, is_group, has_inner_steps, background_color, tags, spans, link_to_document)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(id) DO
UPDATE SET id=excluded.id, local_id=excluded.local_id, type=excluded.type, parent_id=excluded.parent_id,
url=excluded.url, path=excluded.path, text=excluded.text, checked=excluded.checked, position=excluded.position,
document_id=excluded.document_id, is_group=excluded.is_group, has_inner_steps=excluded.has_inner_steps,
background_color=excluded.background_color, tags=excluded.tags, spans=excluded.spans, link_to_document=excluded.link_to_document;

deleteByDocumentId:
DELETE
FROM story_step_entity
WHERE document_id = ?;

deleteByDocumentIds:
DELETE
FROM story_step_entity
WHERE document_id IN ?;
