-- Departments Table
CREATE TABLE departments (
    tenant_id UUID,
    department_id UUID,
    name VARCHAR(100) NOT NULL,
    PRIMARY KEY (tenant_id, department_id),
    FOREIGN KEY (tenant_id) REFERENCES tenants(id)
);
-- Employees Table
CREATE TABLE employees (
    tenant_id UUID,
    employee_id UUID,
    department_id UUID,
    title VARCHAR(100),
    compensation NUMERIC(15, 2),
    PRIMARY KEY (tenant_id, employee_id),
    FOREIGN KEY (tenant_id, employee_id) REFERENCES users.tenant_users(tenant_id, user_id),
    FOREIGN KEY (tenant_id, department_id) REFERENCES departments(tenant_id, department_id)
);
-- Feedback Table
CREATE TABLE feedback (
    tenant_id UUID,
    feedback_id UUID,
    giver_id UUID,
    receiver_id UUID,
    feedback_text TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    is_anonymous BOOLEAN DEFAULT FALSE,
    vector_embedding VECTOR(768), -- Adjust the dimensions as needed
    PRIMARY KEY (tenant_id, feedback_id),
    FOREIGN KEY (tenant_id, giver_id) REFERENCES employees(tenant_id, employee_id),
    FOREIGN KEY (tenant_id, receiver_id) REFERENCES employees(tenant_id, employee_id)
);
-- Self Feedback Table
CREATE TABLE self_feedback (
    tenant_id UUID,
    self_feedback_id UUID,
    employee_id UUID,
    feedback_text TEXT,
    vector_embedding VECTOR(768), -- Adjust the dimensions as needed
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (tenant_id, self_feedback_id),
    FOREIGN KEY (tenant_id, employee_id) REFERENCES employees(tenant_id, employee_id)
);
-- Kudos Table
CREATE TABLE kudos (
    tenant_id UUID,
    kudos_id UUID,
    giver_id UUID,
    receiver_id UUID,
    kudos_text TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    vector_embedding VECTOR(768), -- Adjust the dimensions as needed
    PRIMARY KEY (tenant_id, kudos_id),
    FOREIGN KEY (tenant_id, giver_id) REFERENCES employees(tenant_id, employee_id),
    FOREIGN KEY (tenant_id, receiver_id) REFERENCES employees(tenant_id, employee_id)
);
-- Badges Table
CREATE TABLE badges (
    tenant_id UUID,
    badge_id UUID,
    employee_id UUID,
    badge_name VARCHAR(100),
    issued_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (tenant_id, badge_id),
    FOREIGN KEY (tenant_id, employee_id) REFERENCES employees(tenant_id, employee_id)
);
-- Notifications Table
CREATE TABLE notifications (
    tenant_id UUID,
    notification_id UUID,
    employee_id UUID,
    notification_text TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    is_read BOOLEAN DEFAULT FALSE,
    PRIMARY KEY (tenant_id, notification_id),
    FOREIGN KEY (tenant_id, employee_id) REFERENCES employees(tenant_id, employee_id)
);