Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steverobbins/d7e8dcb44a112bf925b747d16e603dc5 to your computer and use it in GitHub Desktop.
Save steverobbins/d7e8dcb44a112bf925b747d16e603dc5 to your computer and use it in GitHub Desktop.
select eet.entity_type_code, sf.store_id, max(sf.increment_id) real_increment_last_id, ees.increment_last_id, if(ees.increment_last_id >= max(sf.increment_id), 'Yes', 'No') healthy
from sales_flat_shipment sf
inner join eav_entity_store ees on ees.store_id = sf.store_id
inner join eav_entity_type eet on eet.entity_type_id = ees.entity_type_id
where eet.entity_type_code = 'shipment'
group by sf.store_id, eet.entity_type_code
union all
select eet.entity_type_code, sf.store_id, max(sf.increment_id) real_increment_last_id, ees.increment_last_id, if(ees.increment_last_id >= max(sf.increment_id), 'Yes', 'No') healthy
from sales_flat_invoice sf
inner join eav_entity_store ees on ees.store_id = sf.store_id
inner join eav_entity_type eet on eet.entity_type_id = ees.entity_type_id
where eet.entity_type_code = 'invoice'
group by sf.store_id, eet.entity_type_code
union all
select eet.entity_type_code, sf.store_id, max(sf.increment_id) real_increment_last_id, ees.increment_last_id, if(ees.increment_last_id >= max(sf.increment_id), 'Yes', 'No') healthy
from sales_flat_order sf
inner join eav_entity_store ees on ees.store_id = sf.store_id
inner join eav_entity_type eet on eet.entity_type_id = ees.entity_type_id
where eet.entity_type_code = 'order'
group by sf.store_id, eet.entity_type_code
union all
select eet.entity_type_code, sf.store_id, max(sf.increment_id) real_increment_last_id, ees.increment_last_id, if(ees.increment_last_id >= max(sf.increment_id), 'Yes', 'No') healthy
from sales_flat_creditmemo sf
inner join eav_entity_store ees on ees.store_id = sf.store_id
inner join eav_entity_type eet on eet.entity_type_id = ees.entity_type_id
where eet.entity_type_code = 'creditmemo'
group by sf.store_id, eet.entity_type_code;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment