Files
casadoc/public/userportal/api/sql/api_tokens.sql
T
2026-07-27 21:04:07 +03:00

16 lines
677 B
SQL

-- Casadoc Mobile API - bearer token table.
CREATE TABLE IF NOT EXISTS api_tokens (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
user_id BIGINT UNSIGNED NOT NULL, -- auth_users.id
name VARCHAR(255) NOT NULL, -- device_name
token CHAR(64) NOT NULL, -- sha256(plaintext)
last_used_at TIMESTAMP NULL DEFAULT NULL,
expires_at TIMESTAMP NULL DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE KEY uq_api_tokens_token (token),
KEY idx_api_tokens_user (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;