CREATE TABLE webauthn_credentials (
    id               INTEGER PRIMARY KEY AUTOINCREMENT,
    account_id       INTEGER NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
    name             TEXT    NOT NULL DEFAULT '',
    credential_id_enc   BLOB NOT NULL,
    credential_id_nonce BLOB NOT NULL,
    public_key_enc      BLOB NOT NULL,
    public_key_nonce    BLOB NOT NULL,
    aaguid           TEXT    NOT NULL DEFAULT '',
    sign_count       INTEGER NOT NULL DEFAULT 0,
    discoverable     INTEGER NOT NULL DEFAULT 0,
    transports       TEXT    NOT NULL DEFAULT '',
    created_at       TEXT    NOT NULL,
    updated_at       TEXT    NOT NULL,
    last_used_at     TEXT
);

CREATE INDEX idx_webauthn_credentials_account_id ON webauthn_credentials(account_id);
