Skip to content

fix: use datetime for user soft delete#15

Open
xiaoxin-zk wants to merge 1 commit intojames-6-23:mainfrom
xiaoxin-zk:fix-deleted-at-datetime-pr
Open

fix: use datetime for user soft delete#15
xiaoxin-zk wants to merge 1 commit intojames-6-23:mainfrom
xiaoxin-zk:fix-deleted-at-datetime-pr

Conversation

@xiaoxin-zk
Copy link
Copy Markdown

This fixes a compatibility issue with deployments that share the upstream
ew-api MySQL schema.

Problem:

  • users.deleted_at is commonly datetime(3) in
    ew-api

ew_api_tools soft-delete code writes Unix timestamps ( ime.Now().Unix()) into deleted_at

  • on MySQL this causes delete-user requests to fail with Incorrect datetime value, and changing the shared column to BIGINT breaks
    ew-api with scan errors like unsupported Scan, storing driver.Value type int64 into type *time.Time

Fix:

  • write ime.Time for single-user soft delete
  • write ime.Time for batch soft delete
  • keep Unix timestamps only for activity threshold calculations
  • surface batch update errors instead of ignoring them

Validated on a live deployment:

  • upstream
    ew-api kept working with users.deleted_at = datetime(3)
  • DELETE /api/users/:id?hard_delete=false returned 200 after the change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant