Delete Data Type

Delete DataType Mutation

Deletes an existing data type definition from the system.

Arguments

Name
Type
Description

id

ID!

The ID of the data type to delete

Return Type

DataTypeDeletePayload! - Confirmation of the delete operation.

Return Fields

DataTypeDeletePayload:

Field
Type
Description

deletedID

ID

The ID of the deleted data type

Usage Example

mutation {
  deleteDataType(id: "dt_123456789") {
    deletedID
  }
}

JavaScript Example

Important Considerations

Soft vs Hard Delete

The pyck system implements soft deletes by default, meaning:

  • The data type record is marked as deleted (deletedAt timestamp is set)

  • The data type definition remains in the database for audit purposes

  • The data type will not appear in normal queries

  • Entities using this data type retain their data but lose schema validation

Dependency Impact

Before deleting a data type, consider:

  • Active Entities: Customers, suppliers, items, or other entities using this data type

  • Forms and UI: Frontend applications relying on the schema structure

  • Validation Rules: Business logic that depends on the data type schema

  • Reports and Analytics: Systems that query data based on the schema

  • API Integrations: External systems expecting specific data formats

Data Type Usage

Data types are referenced by entities through:

  • dataTypeID - Direct reference to the data type

  • dataTypeSlug - String-based reference for easier identification

  • Schema validation applied to the data field of entities

Permissions

Data type deletion typically requires:

  • Administrative or system architect privileges

  • Proper authorization for the tenant/organization

  • Understanding of system-wide impact of the deletion

  • Compliance with data governance policies

Error Scenarios

The mutation may fail in these cases:

  • Not Found: Data type ID doesn't exist

  • Permission Denied: Insufficient privileges to delete data types

  • Constraint Violations: Entities are actively using this data type

  • System Data Types: Attempting to delete built-in or system data types

  • Default Data Types: Trying to delete data types marked as default

Pre-Deletion Checklist

Before deleting a data type:

  1. Identify Usage: Query all entities using this data type

  2. Migration Plan: Plan how to handle existing entities

  3. Backup Schema: Save the JSON schema definition

  4. Stakeholder Approval: Get approval from business stakeholders

  5. System Testing: Test system behavior after deletion

  6. Rollback Plan: Prepare to restore if issues arise

Migration Strategies

Entity Reassignment

Data Preservation

Best Practices

  1. Impact Analysis: Thoroughly analyze dependencies before deletion

  2. Gradual Migration: Move entities to other data types first

  3. Communication: Notify all stakeholders of the planned deletion

  4. Documentation: Document reasons for deletion and migration steps

  5. Testing: Test system behavior in non-production environments

  6. Monitoring: Monitor system health after deletion

Alternative Approaches

Instead of deletion, consider:

  • Deprecation: Mark data type as deprecated but keep it available

  • Versioning: Create new versions instead of deleting old ones

  • Archiving: Move unused data types to an archived status

  • Replacement: Create replacement data types before deleting old ones

Recovery Options

If a data type is accidentally deleted:

  • Soft Delete Recovery: Clear the deletedAt timestamp to restore

  • Schema Restoration: Recreate the data type with the same JSON schema

  • Entity Reassignment: Update entities to use the restored data type

  • Validation Repair: Fix any validation issues that occurred during the outage

After data type deletion, you may need to:

  • Update documentation and API references

  • Modify form generation systems

  • Update validation logic in applications

  • Revise data import/export processes

  • Adjust reporting and analytics queries

Monitoring and Alerts

Consider setting up monitoring for:

  • Entities without valid data type references

  • Validation errors due to missing schemas

  • Performance impacts from schema changes

  • Failed operations due to missing data types

Last updated

Was this helpful?