SQL Snippets

Before performing destructive operations it is recommended you create a database backup.

When deleting data, you can replace DELETE with SELECT to view what is about to get deleted.

Delete all records

-- Record values
delete from compose_record_value;

-- Records
delete from compose_record;

Delete all records of a namespace

-- Record values
delete from compose_record_value where record_id in (select id from compose_record where rel_namespace = {NAMESPACE_ID} AND module_id = {MODULE_ID});

-- Records
delete from compose_record where rel_namespace = {NAMESPACE_ID};

Delete all records of a module

-- Record values
delete from compose_record_value where record_id in (select id from compose_record where rel_namespace = {NAMESPACE_ID} AND module_id = {MODULE_ID});

-- Records
delete from compose_record where rel_namespace = {NAMESPACE_ID} AND module_id = {MODULE_ID};

Delete specific record values

delete from compose_record_value where name = {FIELD_NAME} AND record_id in (select id from compose_record where rel_namespace = {NAMESPACE_ID} AND module_id = {MODULE_ID});

Delete all soft deleted records

-- Record values
delete from compose_record_value where record_id in (select id from compose_record where rel_namespace = {NAMESPACE_ID} AND module_id = {MODULE_ID} and deleted_at IS NOT NULL);

-- Records
delete from compose_record where rel_namespace = {NAMESPACE_ID} AND module_id = {MODULE_ID} and deleted_at IS NOT NULL;