rails-uuid-pk 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93efad36dbc0fb3ab34a2a348a5dad4ae0cb75c3f6f62bf7da4580146fbcccb3
4
- data.tar.gz: df2a8e217103e1c732c894fd4ab48333e149e8a42a1a92a08bb023d72673ffa3
3
+ metadata.gz: 44071099c05c09c2bd83cf2c82eac2cd7794990d288d68d8ef775e2ecaa410e2
4
+ data.tar.gz: ba6ad1a7f1a00c2d5201122215c9fcfbd39142088775b24234f2a01c9e25dc05
5
5
  SHA512:
6
- metadata.gz: '09577137b7dbdd2b488260130f6afd4473292d06fb6646e141176de11a425f243b95ae3c43b8e69e89a7fcf3cb6b72d3f6cdb3b9794b56bf884c05895e4822de'
7
- data.tar.gz: 9a5818221c1251cb137e61a30045fb98a0957af248f9f3e5908e5e9fb6f8d74d4de84dfb60d40135d60028d4d679070c8d295174990f8cc990f58752841a33f0
6
+ metadata.gz: caf06da62bc4a35bd6eb8fc578e298d3a1652e89a1ea0bf74118aeb325b780e3f0dc8b7a1b37828967a6ca9287d164631ac4355a2817c9c483a4e4934396adef
7
+ data.tar.gz: 0b6a0d2920550d3d0eb385f4f42dcafd55877a6a603d6347d1d13b6a9171ddd4a74c8f14439125666455e91f2481d57b688bf8e6a18e9dde439c7daaa3918db3
data/CHANGELOG.md CHANGED
@@ -5,6 +5,58 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v1.0.0.html).
7
7
 
8
+ ## [0.7.0] - 2026-01-12
9
+
10
+ ### Added
11
+ - **SECURITY.md**: Comprehensive security documentation covering UUIDv7-specific security considerations
12
+ - Cryptographic security analysis with timestamp exposure details
13
+ - Database security implications and foreign key considerations
14
+ - Performance-security trade-offs analysis
15
+ - Security vulnerability reporting process
16
+ - Side-channel attack vectors and mitigation strategies
17
+ - Compliance considerations (GDPR, HIPAA, etc.)
18
+ - Security testing recommendations and monitoring guidelines
19
+ - **ARCHITECTURE.md**: Comprehensive architecture documentation
20
+ - Core design principles and architectural decisions
21
+ - App-level vs database-level UUID generation analysis
22
+ - Database compatibility rationale and trade-offs
23
+ - Migration performance implications and caching strategies
24
+ - Database replication and backup considerations
25
+ - ORM and query builder integration details
26
+ - Error handling and resilience patterns
27
+ - Future evolution and extensibility points
28
+ - **PERFORMANCE.md**: Comprehensive performance documentation in dedicated file
29
+ - UUID generation throughput metrics and cryptographic security details
30
+ - Database-specific performance characteristics (PostgreSQL, MySQL, SQLite)
31
+ - Index performance analysis comparing 36-byte UUIDs vs 4-byte integers
32
+ - Scaling recommendations for tables of different sizes (<1M, 1M-10M, >10M records)
33
+ - UUIDv7 vs UUIDv4 performance trade-offs with detailed comparison tables
34
+ - Index fragmentation and cache locality analysis
35
+ - Production monitoring and optimization guidelines
36
+ - **README.md**: Streamlined with concise performance overview and link to PERFORMANCE.md
37
+ - **Comprehensive UUIDv7 Correctness Testing**: Added extensive test suite validating UUIDv7 compliance
38
+ - RFC 9562 version and variant bits validation
39
+ - Timestamp monotonicity and collision resistance testing
40
+ - Format consistency and edge case handling
41
+ - Statistical randomness quality analysis
42
+ - Cross-database compatibility verification
43
+
44
+ ### Changed
45
+ - **Schema Dumper Compatibility**: Replaced fragile `caller` detection with Rails version-aware schema type handling
46
+ - Rails 8.1+: Uses `:uuid` type in schema dumps for native UUID support
47
+ - Rails 8.0.x: Uses `:string` type to avoid "Unknown type 'uuid'" errors
48
+ - Future-proof design that adapts to Rails version changes
49
+ - Added comprehensive test coverage for schema dumping behavior
50
+
51
+ ### Fixed
52
+ - **Schema Dumping Fragility**: Eliminated dependency on Rails internal `caller` stack inspection
53
+ - **Rails Version Compatibility**: Robust handling of UUID types across different Rails versions
54
+
55
+ ### Security
56
+ - Enhanced security posture with professional security documentation
57
+ - Clear vulnerability disclosure process for responsible reporting
58
+ - UUID-specific security guidance for enterprise adoption
59
+
8
60
  ## [0.6.0] - 2026-01-12
9
61
 
10
62
  ### Added
data/README.md CHANGED
@@ -90,6 +90,24 @@ end
90
90
  | Zero config after install | Yes | Migration helpers automatically handle foreign key types |
91
91
  | Works with Rails 7.1 – 8+ | Yes | Tested conceptually up to Rails 8.1+ |
92
92
 
93
+ ## Performance Overview
94
+
95
+ **Generation**: ~10,000 UUIDs/second with cryptographic security and monotonic ordering
96
+
97
+ | Database | Storage | Index Performance | Notes |
98
+ |----------|---------|-------------------|--------|
99
+ | **PostgreSQL** | Native UUID (16B) | Excellent | Optimal performance |
100
+ | **MySQL** | VARCHAR(36) (36B) | Good | 2.25x storage overhead |
101
+ | **SQLite** | VARCHAR(36) (36B) | Good | Good for development |
102
+
103
+ **Key Advantages**:
104
+ - **UUIDv7 outperforms UUIDv4** in most scenarios due to monotonic ordering
105
+ - **Better index locality** than random UUIDs with reduced fragmentation
106
+ - **Efficient range queries** for time-based data access
107
+ - **Production-ready scaling** with proper indexing and monitoring
108
+
109
+ For comprehensive performance analysis, scaling strategies, and optimization guides, see [PERFORMANCE.md](PERFORMANCE.md).
110
+
93
111
  ## Why not use native PostgreSQL `uuidv7()`?
94
112
 
95
113
  While PostgreSQL 18+ has excellent native `uuidv7()` support, the **fallback approach** was chosen for maximum compatibility:
@@ -105,12 +123,39 @@ You can still add native PostgreSQL defaults manually if you want maximum perfor
105
123
 
106
124
  ### Devcontainer Setup
107
125
 
108
- This project includes a devcontainer configuration for VS Code. To get started:
126
+ This project includes a devcontainer configuration for VS Code (highly recommended, as it automatically sets up Ruby 3.3, Rails, PostgreSQL, MySQL, and SQLite in an isolated environment). To get started:
109
127
 
110
128
  1. Open the project in VS Code
111
129
  2. When prompted, click "Reopen in Container" (or run `Dev Containers: Reopen in Container` from the command palette)
112
130
  3. The devcontainer will set up Ruby 3.3, Rails, and all dependencies automatically
113
131
 
132
+ #### Devcontainer CLI
133
+
134
+ For terminal-based development or automation, you can use the Devcontainer CLI. The devcontainer will be built and started automatically when you run the exec commands.
135
+
136
+ ##### Installation
137
+
138
+ - **MacOS**: `brew install devcontainer`
139
+ - **Other systems**: `npm install -g @devcontainers/cli`
140
+
141
+ ##### Usage
142
+
143
+ Run commands inside the devcontainer:
144
+
145
+ ```bash
146
+ # Install dependencies
147
+ devcontainer exec --workspace-folder . bundle install
148
+
149
+ # Run tests
150
+ devcontainer exec --workspace-folder . ./bin/test
151
+
152
+ # Run code quality checks
153
+ devcontainer exec --workspace-folder . ./bin/rubocop
154
+
155
+ # Interactive shell
156
+ devcontainer exec --workspace-folder . bash
157
+ ```
158
+
114
159
  ### Running Tests
115
160
 
116
161
  The project includes a comprehensive test suite that runs against SQLite, PostgreSQL, and MySQL.
@@ -156,6 +201,10 @@ For database testing, ensure the respective databases are running and accessible
156
201
 
157
202
  Bug reports and pull requests are welcome on GitHub at https://github.com/seouri/rails-uuid-pk.
158
203
 
204
+ Please see our [Security Policy](SECURITY.md) for information about reporting security vulnerabilities.
205
+
206
+ For detailed architecture documentation, design decisions, and technical rationale, see [ARCHITECTURE.md](ARCHITECTURE.md).
207
+
159
208
  ## License
160
209
 
161
210
  The gem is available as open source under the terms of the [MIT License](MIT-LICENSE).
@@ -2,12 +2,12 @@ module RailsUuidPk
2
2
  module Type
3
3
  class Uuid < ActiveRecord::Type::String
4
4
  def type
5
- # Return :string during schema dumping to avoid "Unknown type 'uuid'" errors
6
- # Return :uuid for normal operation and tests
7
- if caller.any? { |c| c.include?("schema_dumper") }
8
- :string
9
- else
5
+ # Rails 8.1+ supports UUID types in schema dumping
6
+ # Earlier versions need :string to avoid "Unknown type 'uuid'" errors
7
+ if rails_supports_uuid_in_schema?
10
8
  :uuid
9
+ else
10
+ :string
11
11
  end
12
12
  end
13
13
 
@@ -42,6 +42,13 @@ module RailsUuidPk
42
42
  def valid?(value)
43
43
  value.match?(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)
44
44
  end
45
+
46
+ def rails_supports_uuid_in_schema?
47
+ # Rails 8.1+ supports UUID types in schema dumping
48
+ # Earlier versions (8.0.x) need :string to avoid "Unknown type 'uuid'" errors
49
+ rails_version = Gem::Version.new(Rails::VERSION::STRING)
50
+ rails_version >= Gem::Version.new("8.1.0")
51
+ end
45
52
  end
46
53
  end
47
54
  end
@@ -1,3 +1,3 @@
1
1
  module RailsUuidPk
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-uuid-pk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joon Lee