Deleting Content using the CLI

Is there a way to delete the content using the CLI (eg drop all content) ? I wasnt able to find this capability.
We are currently loading the data as part of our of our CI/CD pipeline. All Projects are destroyed at the end of the day and rebuild in the morning

Sorry, I have not seen this yet. There is no feature for that. If you want to delete everything, I recommend these settings:


and

APPS__DELETEPERMANENT (not added to appsettings.json yet)

Other wise your app will just be marked as deleted and db grows over time.

I have pushes a new version of the CLI with a command to delete apps.

HI @Sebastian I was more after the deletion of all content (Im currently not using Assets) how would i go about doing that? Can i just call the delete schema endpoint (https://…/app_name/schemas/schema_name -Headers $Header -Method Delete)?

I am also interested in this and can let you know what we do (note that we are using the C# SquidexClient but hopefully they have feature parity). We used to do as you say and just delete the schema, however it seemed to leave a lot of data intact in the database which was causing our database to balloon (this was a test environment so we were often deleting and recreating schemas with a lot of content).

So now to be more confident that everything is being cleaned up as well as possible we do the following:

  1. Get all content IDs for the schema we want to delete
  2. Run a bulk update request containing individual permanent delete requests for each content ID
  3. Delete the schema

Would appreciate knowing that what we’re doing is the right thing to do or completely pointless or if there is an alternative approach!

I have said you should delete the app. There is a deletion process for that.

If this is not possible you approach should work.

1 Like

I see you mention some settings above but im afraid I still dont understand. Is there a delete endpoint for deleting the App? Can the CLI be used for this as well (couldnt see an option)

The newest version of the CLI has a delete function, just check out the help. Should be `sq apps delete" I think.

But you also have to turn on the settings above to really get rid of everything.

So if you use squidex for testing or in your CLI I recommend the following:

  1. Create a new setup with the sync command.
  2. Create a new app for your tests (probably not for every test)
  3. Run your tests
  4. Delete the app.

Ok understood. In my case I wont be able to delete the App as it has multiple schemas (for this particular application).

Ive put together something like what @slalFe suggested. Im able to get all the Ids. But when i execute the the Delete endpoint on the Content passing in the Id im getting “405 Method Not Allowed”.

https://…/api/content/app-name/schema-name?id=6f9fa672-4b98-439b-ac08-170c30768201

It is the wrong endpoint.

This is the API docs for the Squidex website app: https://cloud.squidex.io/api/content/squidex-website/docs

You can also use the bulk endpoint, but it is not described here. YOu can use the Squidex client library for that: https://github.com/Squidex/squidex-samples/blob/master/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentsClient.cs#L347

Yes thats the document i was refering to

doc: https://cloud.squidex.io/api/content/squidex-website/docs#operation/DeleteSettingsContent
endpoint: https://cloud.squidex.ioapi/content/squidex-website/settings/{id}

and from that i formulated my request

https://…/api/content/app-name/schema-name/?id=6f9fa672-4b98-439b-ac08-170c30768201

but getting “405 Method Not Allowed

Got it. It should be

https://…/api/content/app-name/schema-name/6f9fa672-4b98-439b-ac08-170c30768201

Yes :wink: … exactly like that.

Hello, let me know if you want me to raise a separate support request for this but it may be a quick answer! I believe I have overridden apps:deletePermanent with true using appsettings.Custom.json (have also overridden the rebuild:apps with true and that seems to be working), am I right in saying this should also work when deleting view the UI? Or is perhaps having rebuild:apps set to true somehow counteracting my deletion?

This is one of those end of the days and am stuck questions, I’ll have another look in the morning and try using the CLI!

Rebuild:apps = true is something you should not configure permanently. It takes the events and rebuilds the snapshots from the events when the application starts. But only for the app itself, so basically everything under settings.

It could interact the deletion in the following way:

  1. Deletion is on and deleted half the app events.
  2. Squidex is restarted
  3. The rebuilder rebuilds the app from the remaining events.
  4. Deleter deletes the rest of the events.

Sorry I didn’t clarify, was just setting rebuild:apps=true to restore some soft-deleted apps so they could be properly deleted (following https://docs.squidex.io/01-getting-started/installation/troubleshooting-and-support/restore-deleted-apps#variation-2 , variation 1 didn’t work for me) which is why both settings were enabled at the same time.

Also apologies, I clearly wasn’t patient enough as I came in this morning to find that the deleted apps were no longer present in States_Apps so believe it did work, I just underestimated how long it would take (couple of the apps were created just for purpose of testing deletion so were very small, but in total we have a lot of events and content). Now I just need to look into why sizes of some of those collections (Events2, States_Contents_All3 predominantly) didn’t go down significantly when permanently deleting our biggest app…

Solution could well be that we just need to completely teardown our Squidex instance (is just a testing one) and recreate, making sure to adhere to proper content and app removal going forwards.

Edit: Oh just re-read what you said; so if I permanently delete the app but Squidex gets redeployed soon afterwards interrupting the background processes (we host in Docker), it should carry on with the deletion once it is back up again?

Edit: I’ll make this my last edit and again apologies for not being patient, I think my confusion was partially being caused by MongoDB Compass not automatically updating data being displayed. I can now see that everything has indeed been deleted in that there are no documents, it is just still reporting some use based on the indexes but it could be that they will also go soon or be rewritten as I re-add apps.

Thanks for your time and help on this!

1 Like

Good that I have not responded immediately :smiley:

1 Like