16 lines
594 B
MySQL
16 lines
594 B
MySQL
|
|
-- Create API keys table for external service authentication
|
||
|
|
CREATE TABLE IF NOT EXISTS api_keys (
|
||
|
|
api_key_id INT AUTO_INCREMENT PRIMARY KEY,
|
||
|
|
key_name VARCHAR(100) NOT NULL,
|
||
|
|
key_hash VARCHAR(255) UNIQUE NOT NULL,
|
||
|
|
key_prefix VARCHAR(20) NOT NULL,
|
||
|
|
is_active BOOLEAN DEFAULT TRUE,
|
||
|
|
created_by INT,
|
||
|
|
last_used TIMESTAMP NULL,
|
||
|
|
expires_at TIMESTAMP NULL,
|
||
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
FOREIGN KEY (created_by) REFERENCES users(user_id) ON DELETE SET NULL,
|
||
|
|
INDEX idx_key_hash (key_hash),
|
||
|
|
INDEX idx_is_active (is_active)
|
||
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|