gohorsejobs/backend/migrations/002_create_companies_table.sql

41 lines
1.3 KiB
SQL
Executable file

-- Migration: Create companies table
-- Description: Stores company information for employers
CREATE TABLE IF NOT EXISTS companies (
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
name VARCHAR(255) NOT NULL,
slug VARCHAR(255) UNIQUE NOT NULL, -- URL friendly name
type VARCHAR(50) DEFAULT 'company', -- company, agency, etc
document VARCHAR(100), -- Houjin Bangou (Company Number)
-- Contact
address TEXT,
region_id INT,
city_id INT,
phone VARCHAR(30),
email VARCHAR(255),
website VARCHAR(255),
-- Branding
logo_url TEXT,
description TEXT,
-- Status
active BOOLEAN DEFAULT true,
verified BOOLEAN DEFAULT false,
-- Metadata
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Indexes
CREATE INDEX idx_companies_active ON companies(active);
CREATE INDEX idx_companies_verified ON companies(verified);
CREATE INDEX idx_companies_region ON companies(region_id);
CREATE INDEX idx_companies_slug ON companies(slug);
-- Comments
COMMENT ON TABLE companies IS 'Stores company/employer information';
COMMENT ON COLUMN companies.document IS 'Japanese Company Number (Houjin Bangou)';
COMMENT ON COLUMN companies.verified IS 'Whether company has been verified by admin';