Subject: | sqlt-diagram fails to load SQLite schema |
See attached schema.
Attempted to run: sqlt-diagram -o nmkdb.png --db=SQLite -c nmkdb.sql
Error reported was: "
:
Error: translate: Error with parser 'SQL::Translator::Parser::SQLite':
no results at /usr/local/bin/sqlt-diagram line 133."
Note that there's a hard new-line at the start of the message, as well
as the floating ":" character.
Subject: | nmkdb.sql |
CREATE TABLE categories (
id INTEGER PRIMARY KEY,
label TEXT,
name TEXT,
notes TEXT
);
CREATE TABLE scales (
id INTEGER PRIMARY KEY,
scale INTEGER,
notes TEXT
);
CREATE TABLE manufacturers (
id INTEGER PRIMARY KEY,
name TEXT,
notes TEXT
);
CREATE TABLE box_conditions (
id INTEGER PRIMARY KEY,
condition TEXT,
notes
);
CREATE TABLE mediums (
id INTEGER PRIMARY KEY,
name TEXT,
abbreviation TEXT,
notes TEXT
);
CREATE TABLE kits (
id INTEGER PRIMARY KEY,
name TEXT,
quantity INTEGER,
manufacturer INTEGER REFERENCES manufacturers(id),
scale INTEGER REFERENCES scales(id),
category INTEGER REFERENCES categories(id),
condition INTEGER REFERENCES box_conditions(id),
split_from INTEGER REFERENCES kits(id),
upc INTEGER,
notes TEXT,
created INTEGER,
updated INTEGER
);
CREATE TABLE accessories (
id INTEGER PRIMARY KEY,
name TEXT,
category INTEGER REFERENCES categories(id),
split_from INTEGER REFERENCES accessories(id),
upc INTEGER,
notes TEXT,
created INTEGER,
updated INTEGER
);
CREATE TABLE kit_medium_map (
kit INTEGER REFERENCES kits(id),
medium INTEGER REFERENCES mediums(id)
);
CREATE INDEX kit_medium_index ON kit_medium_map(kit);
CREATE TABLE accessory_medium_map (
accessory INTEGER REFERENCES accessories(id),
medium INTEGER REFERENCES mediums(id)
);
CREATE INDEX accessory_medium_index ON accessory_medium_map(accessory);
CREATE TABLE kit_contains_accessory (
kit INTEGER REFERENCES kits(id),
accessory INTEGER REFERENCES accessories(id)
);
CREATE INDEX kit_accessory_index ON kit_contains_accessory(kit);
CREATE INDEX accessory_kit_index ON kit_contains_accessory(accessory);
-- Triggers to ensure the created/updated fields get populated
CREATE TRIGGER insert_kits AFTER INSERT ON kits
BEGIN
UPDATE kits
SET created = (SELECT strftime('%s','now')),
updated = (SELECT strftime('%s','now'))
WHERE id = NEW.id;
END;
CREATE TRIGGER update_kits AFTER UPDATE ON kits
BEGIN
UPDATE kits
SET updated = (SELECT strftime('%s','now'))
WHERE id = NEW.id;
END;
CREATE TRIGGER insert_accessories AFTER INSERT ON accessories
BEGIN
UPDATE accessories
SET created = (SELECT strftime('%s','now')),
updated = (SELECT strftime('%s','now'))
WHERE id = NEW.id;
END;
CREATE TRIGGER update_accessories AFTER UPDATE ON accessories
BEGIN
UPDATE accessories
SET updated = (SELECT strftime('%s','now'))
WHERE id = NEW.id;
END;