Files
honey-be/src/main/resources/db/migration/V2__create_sessions_table.sql

14 lines
564 B
MySQL
Raw Normal View History

-- Create sessions table for Bearer token authentication
CREATE TABLE IF NOT EXISTS sessions (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
session_id_hash VARCHAR(255) NOT NULL UNIQUE,
user_id BIGINT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP NOT NULL,
INDEX idx_session_hash (session_id_hash),
INDEX idx_expires_at (expires_at),
INDEX idx_user_id (user_id),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;