You are reading the documentation for an outdated Corteza release. 2024.9 is the latest stable Corteza release.

SQL Snippets

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

You can replace the delete statement with the select statement to view the data which is about to be 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;