35 lines
1.3 KiB
SQL
Executable file
35 lines
1.3 KiB
SQL
Executable file
-- Migration: Create users table
|
|
-- Description: Stores all system users (SuperAdmin, CompanyAdmin, Recruiter, JobSeeker)
|
|
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
|
identifier VARCHAR(100) UNIQUE NOT NULL,
|
|
password_hash VARCHAR(255) NOT NULL,
|
|
role VARCHAR(20) NOT NULL CHECK (role IN ('superadmin', 'companyAdmin', 'recruiter', 'jobSeeker')),
|
|
|
|
-- Personal Info
|
|
full_name VARCHAR(255),
|
|
phone VARCHAR(30),
|
|
line_id VARCHAR(100),
|
|
whatsapp VARCHAR(30),
|
|
instagram VARCHAR(100),
|
|
|
|
-- Settings
|
|
language VARCHAR(5) DEFAULT 'en' CHECK (language IN ('pt', 'en', 'es', 'ja')),
|
|
active BOOLEAN DEFAULT true,
|
|
|
|
-- Metadata
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
last_login_at TIMESTAMP
|
|
);
|
|
|
|
-- Indexes for performance
|
|
CREATE INDEX idx_users_identifier ON users(identifier);
|
|
CREATE INDEX idx_users_role ON users(role);
|
|
CREATE INDEX idx_users_active ON users(active);
|
|
|
|
-- Comments for documentation
|
|
COMMENT ON TABLE users IS 'Stores all system users across all roles';
|
|
COMMENT ON COLUMN users.identifier IS 'Username for login (NOT email)';
|
|
COMMENT ON COLUMN users.role IS 'User role: superadmin, companyAdmin, recruiter, or jobSeeker';
|