I modified your code and created a sample data, this is the result.
Code.gs
function deleteshift() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName('main');
const dataSheet = ss.getSheetByName('deletDB');
const existingId = sheet.getActiveCell().getValue();
const existing = dataSheet.getRange(2, 6, dataSheet.getLastRow() - 1).getValues().flat();
const index = (existing.length - existing.reverse().indexOf(existingId)) + 1;
dataSheet.deleteRow(index);
}
Sample Data
After:
Reference: