ALTER TABLE performance_goals
    ADD COLUMN tenant_id INTEGER,
    ADD COLUMN branch_id INTEGER;
CREATE INDEX performance_goals_tenant_idx ON performance_goals(tenant_id);
CREATE INDEX performance_goals_branch_idx ON performance_goals(branch_id);

ALTER TABLE goal_milestones
    ADD COLUMN tenant_id INTEGER,
    ADD COLUMN branch_id INTEGER;
CREATE INDEX goal_milestones_tenant_idx ON goal_milestones(tenant_id);
CREATE INDEX goal_milestones_branch_idx ON goal_milestones(branch_id);

ALTER TABLE goal_documents
    ADD COLUMN tenant_id INTEGER,
    ADD COLUMN branch_id INTEGER;
CREATE INDEX goal_documents_tenant_idx ON goal_documents(tenant_id);
CREATE INDEX goal_documents_branch_idx ON goal_documents(branch_id);

ALTER TABLE performance_reviews
    ADD COLUMN tenant_id INTEGER,
    ADD COLUMN branch_id INTEGER;
CREATE INDEX performance_reviews_tenant_idx ON performance_reviews(tenant_id);
CREATE INDEX performance_reviews_branch_idx ON performance_reviews(branch_id);

ALTER TABLE review_documents
    ADD COLUMN tenant_id INTEGER,
    ADD COLUMN branch_id INTEGER;
CREATE INDEX review_documents_tenant_idx ON review_documents(tenant_id);
CREATE INDEX review_documents_branch_idx ON review_documents(branch_id);

ALTER TABLE feedback_notes
    ADD COLUMN tenant_id INTEGER,
    ADD COLUMN branch_id INTEGER;
CREATE INDEX feedback_notes_tenant_idx ON feedback_notes(tenant_id);
CREATE INDEX feedback_notes_branch_idx ON feedback_notes(branch_id);

ALTER TABLE check_ins
    ADD COLUMN tenant_id INTEGER,
    ADD COLUMN branch_id INTEGER;
CREATE INDEX check_ins_tenant_idx ON check_ins(tenant_id);
CREATE INDEX check_ins_branch_idx ON check_ins(branch_id);

UPDATE performance_goals SET tenant_id = 1, branch_id = 1 WHERE tenant_id IS NULL;
UPDATE goal_milestones SET tenant_id = 1, branch_id = 1 WHERE tenant_id IS NULL;
UPDATE goal_documents SET tenant_id = 1, branch_id = 1 WHERE tenant_id IS NULL;
UPDATE performance_reviews SET tenant_id = 1, branch_id = 1 WHERE tenant_id IS NULL;
UPDATE review_documents SET tenant_id = 1, branch_id = 1 WHERE tenant_id IS NULL;
UPDATE feedback_notes SET tenant_id = 1, branch_id = 1 WHERE tenant_id IS NULL;
UPDATE check_ins SET tenant_id = 1, branch_id = 1 WHERE tenant_id IS NULL;
