ALTER TABLE external_access
  ADD COLUMN is_approved TINYINT(1) NOT NULL DEFAULT 0,
  ADD COLUMN created_by VARCHAR(36) NULL;

UPDATE external_access
SET is_approved = 1
WHERE archived_at IS NULL;

CREATE TABLE external_access_pending (
  id VARCHAR(36) NOT NULL PRIMARY KEY,
  resource_name VARCHAR(100) NOT NULL,
  link VARCHAR(500) NOT NULL,
  login VARCHAR(100) NOT NULL,
  password VARCHAR(100) NOT NULL,
  comment TEXT NULL,
  status VARCHAR(20) NOT NULL DEFAULT 'pending',
  target_id VARCHAR(36) NULL,
  created_by VARCHAR(36) NULL,
  reviewed_by VARCHAR(36) NULL,
  reviewed_at TIMESTAMP NULL,
  rejection_reason TEXT NULL,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

