Migration: delete all entries for a given Content Model

Is there any way to delete all of the entries for a Content Model in a migration?
My use case: I have a now-obsolete Content Model, let’s say “Accordion”. I want to delete all of the current accordions, and then the CM itself.

The docs don’t seem to cover this possibility, but I thought I’d ask just in case, because it seems like a pretty common use case.

I can delete all the accordions myself, manually or as part of a rake task (we have a Rails app), but it’d be good to be able to keep everything in the scope of the migrations, rather than have to mix migrations and other tasks.


Hi @katherine

The second function argument is called context. Inside context you can find makeRequest, spaceId and acessToken. You can use makeRequest to getting entries and then delete them.

For example:

module.exports = async function (migration, { makeRequest, spaceId, accessToken }) {
  const resp = await makeRequest({
    method: 'GET',
    url: `/entries?content_type=accordion&limit=1000`

  // Do something with results


1 Like

Thankyou, that’s great!

1 Like