Conversation
Replace auto-incrementing integer primary keys with UUIDv7 across the entire application for improved scalability, global uniqueness, and time-ordered sorting capabilities. Changes: Database Migrations: - PostgreSQL: Change SERIAL to UUID type for all primary keys - MySQL: Change BIGINT AUTO_INCREMENT to BINARY(16) for all primary keys - Update both users and outbox_events table migrations Domain Models: - user.User: Change ID field from int64 to uuid.UUID - outbox.OutboxEvent: Change ID field from int64 to uuid.UUID - user/http/dto.UserResponse: Update ID field to uuid.UUID Application Code: - Generate UUIDs in application using uuid.NewV7() instead of database auto-increment - User creation: Generate UUID before database insertion - OutboxEvent creation: Generate UUID before database insertion - Update all repository method signatures to accept uuid.UUID Repository Layer: - user/repository: GetByID() now accepts uuid.UUID parameter - All repository implementations compatible with UUID storage Use Case Layer: - user/usecase: Update interfaces and implementations to use uuid.UUID - GetUserByID() signature changed to accept uuid.UUID Tests: - Update all test files to use uuid.Must(uuid.NewV7()) - Update mock implementations for UUID compatibility - worker/event_worker_test: Use UUIDs in test fixtures - user/repository_test: Use UUIDs in test cases - user/usecase_test: Update mock methods and assertions - http/http_test: Update handler tests for UUID responses Dependencies: - Add github.com/google/uuid v1.6.0 Documentation: - Add comprehensive UUIDv7 section to README.md - Document benefits: time-ordering, global uniqueness, scalability - Provide implementation examples for new domains - Update code examples throughout README Benefits: - Time-ordered IDs maintain temporal sorting - Globally unique across distributed systems - Better database index performance than random UUIDs - No centralized ID generation required - Merge-friendly for database consolidation scenarios Breaking Changes: - All ID fields changed from int64 to uuid.UUID - API responses now return UUIDs as strings - Database schema requires migration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace auto-incrementing integer primary keys with UUIDv7 across the entire application for improved scalability, global uniqueness, and time-ordered sorting capabilities.
Changes:
Database Migrations:
Domain Models:
Application Code:
Repository Layer:
Use Case Layer:
Tests:
Dependencies:
Documentation:
Benefits:
Breaking Changes: