Skip to content

Replace database-managed timestamps with Spring JPA auditing for created_at and updated_at fields #915

@coderabbitai

Description

@coderabbitai

Description

Currently, the file_info table uses database-managed timestamps with DEFAULT CURRENT_TIMESTAMP for both created_at and updated_at fields. However, the FileInfo entity already has Spring JPA auditing annotations (@CreatedDate and @LastModifiedDate) and @EnableJpaAuditing is configured.

Current State

  • Database schema: created_at timestamp DEFAULT CURRENT_TIMESTAMP
  • Database schema: updated_at timestamp DEFAULT CURRENT_TIMESTAMP
  • Entity has @CreatedDate and @LastModifiedDate annotations
  • @EnableJpaAuditing is enabled in WebMvcConfig

Desired State

  • Remove DEFAULT CURRENT_TIMESTAMP from database schema
  • Make both fields NOT NULL since Spring will guarantee their population
  • Rely entirely on Spring JPA auditing for timestamp management

Benefits

  • Consistent timestamp management at the application layer
  • Better testability and control over audit fields
  • Cleaner separation of concerns

Changes Required

  1. Update init-db.sql to remove database defaults and add NOT NULL constraints
  2. Ensure Spring auditing is properly configured (already done)
  3. Update any existing data migration if needed

References

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions