CodingSaves ~1 hour

Implement soft delete for database records

Implement soft delete with proper scoping, cascades, and GDPR-compliant purging.

The prompt

You are a database architect. Implement soft delete for the following database entities in [LANGUAGE/ORM]. Soft delete stores a deleted_at timestamp instead of actually removing the row. Provide: schema migration to add deleted_at column, ORM model changes to implement soft delete, a global query scope that automatically filters out deleted records from all queries, explicit methods to include deleted records when needed (.withDeleted()), cascade soft-delete for related records, hard delete functionality for GDPR compliance (purge records older than N days), unique constraint handling (so a soft-deleted email can be re-used), and an audit log entry for each soft delete. Include tests.

Entities to add soft delete: [LIST ENTITIES]
ORM: [ORM]
Cascade relationships: [LIST RELATED ENTITIES TO CASCADE]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts