ALTER TABLE employees ADD COLUMN IF NOT EXISTS profile_unavailable_streak INTEGER NOT NULL DEFAULT 0; ALTER TABLE employees ADD COLUMN IF NOT EXISTS last_profile_check_at TIMESTAMPTZ; CREATE TABLE IF NOT EXISTS employee_profile_urls ( id SERIAL PRIMARY KEY, employee_id INTEGER NOT NULL REFERENCES employees(id) ON DELETE CASCADE, url TEXT NOT NULL, first_seen_at TIMESTAMPTZ NOT NULL DEFAULT now(), last_seen_at TIMESTAMPTZ NOT NULL DEFAULT now(), CONSTRAINT uq_employee_profile_urls_employee_url UNIQUE (employee_id, url) ); CREATE INDEX IF NOT EXISTS ix_employee_profile_urls_employee_id ON employee_profile_urls (employee_id);