Soft-deleting Postgres rows without losing the URL slug

📰 Dev.to · Daniel Rusnok

Learn how to soft-delete Postgres rows without losing the URL slug using a simple technique

intermediate Published 10 Apr 2026
Action Steps
  1. Create a new column to track soft-deleted rows
  2. Update the unique constraint to exclude soft-deleted rows
  3. Write a function to soft-delete rows and release the slug
  4. Use the function to soft-delete a row and verify the slug is released
  5. Test the solution with multiple rows and slugs
  6. Apply the solution to your production database
Who Needs to Know This

Developers and database administrators can benefit from this technique to manage data efficiently and avoid conflicts with unique URL slugs

Key Insight

💡 Use a separate column to track soft-deleted rows and update the unique constraint to exclude them, allowing the URL slug to be reused

Share This
💡 Soft-delete Postgres rows without losing the URL slug using a simple 6-line code technique!

Key Takeaways

Learn how to soft-delete Postgres rows without losing the URL slug using a simple technique

Full Article

Six lines of code that let you release a unique-constrained slug back into the namespace...
Read full article → ← Back to Reads