text: BEGIN;
  
  
  DROP VIEW lsif_dumps_with_repository_name;
  DROP VIEW lsif_uploads_with_repository_name;
  DROP VIEW lsif_dumps;
  
  ALTER TABLE IF EXISTS lsif_uploads DROP COLUMN IF EXISTS associated_index_id;
  
  -- Recreate views with new columns
  CREATE VIEW lsif_dumps AS SELECT u.*, u.finished_at as processed_at FROM lsif_uploads u WHERE state = 'completed';
  
  CREATE VIEW lsif_dumps_with_repository_name AS
    SELECT u.*, r.name as repository_name FROM lsif_dumps u
                                                 JOIN repo r ON r.id = u.repository_id
     WHERE r.deleted_at IS NULL;
  
  CREATE VIEW lsif_uploads_with_repository_name AS
    SELECT u.*, r.name as repository_name FROM lsif_uploads u
                                                 JOIN repo r ON r.id = u.repository_id
     WHERE r.deleted_at IS NULL;
  
  COMMIT;
  