-- QSL card designer templates. The json column holds the full template
-- document (schema v1, internal/qslcard). Photos referenced by a template
-- are copied into <dataDir>/qsl/templates/<id>/ — never referenced at their
-- original path. profile_id scopes the "default template" choice; a NULL
-- profile keeps the template usable by everyone.
CREATE TABLE qsl_templates (
    id          INTEGER PRIMARY KEY,
    name        TEXT NOT NULL,
    profile_id  INTEGER REFERENCES station_profiles(id) ON DELETE SET NULL,
    json        TEXT NOT NULL,
    is_default  INTEGER NOT NULL DEFAULT 0,
    created_at  TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
    updated_at  TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now'))
);
