Skip to content

Add soft delete middleware and Drizzle query filters #53

@PAMulligan

Description

@PAMulligan

Description

The `pipeline.config.json` has `softDeleteDefault: true`, but there's no middleware or query filter implementation for soft deletes. Add a Drizzle query filter and middleware that automatically handles soft delete logic.

Why

Soft deletes are enabled by default in the pipeline config, but the generated code doesn't implement the pattern. This gap means users get a `deleted_at` column but still need to manually filter deleted records in every query.

Current State

`pipeline.config.json`:
```json
"database": {
"softDeleteDefault": true
}
```

No corresponding implementation exists in templates or skills.

Acceptance Criteria

  • Add a `deleted_at` timestamp column to the Drizzle schema template
  • Create a Drizzle query helper that automatically filters `WHERE deleted_at IS NULL`
  • Create a `softDelete()` function that sets `deleted_at` instead of deleting
  • Add a route handler pattern for DELETE endpoints that calls `softDelete()`
  • Add a `?include_deleted=true` query param for admin endpoints
  • Update the `database-design` skill to generate soft delete columns when enabled
  • Add integration tests for soft delete behavior
  • CI passes

Implementation

```typescript
// Soft delete helper
export async function softDelete(db: Database, table: Table, id: string) {
return db.update(table).set({ deletedAt: new Date() }).where(eq(table.id, id));
}

// Query filter
export function notDeleted<T extends { deletedAt: Column }>(table: T) {
return isNull(table.deletedAt);
}
```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions