rails-uuid-pk 0.3.0 → 0.4.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 +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +11 -6
- data/lib/rails_uuid_pk/mysql2_adapter_extension.rb +9 -0
- data/lib/rails_uuid_pk/railtie.rb +22 -0
- data/lib/rails_uuid_pk/version.rb +1 -1
- data/lib/rails_uuid_pk.rb +1 -0
- metadata +19 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3eb01e2f1dc8ef76a90110c9d6ef882f79cfc6584395129046d404f116be94e3
|
|
4
|
+
data.tar.gz: 7aa3b43c50beb54b037428f0abf36f4df642968eb0ba368bfe57328bcea2f8cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '09b2676618355ede8b113e7693e8c1673e1f8c32888f0027ab97fd82c81713af5b2f55b995d565f4445465c8c27ce53c4a42fe4f2247017e6c2cf4a0083af9e7'
|
|
7
|
+
data.tar.gz: 967f36d838dfd8e649a8674cce0a29642f39ee0e1a45dc70c4f66a1597abf65591c71cb434d97fb21affccf337337a04f2602e9fe470d43a464f3b5c2eca2298
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ 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.4.0] - 2026-01-10
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **MySQL 8.0+ support**: Full MySQL compatibility with VARCHAR(36) UUID storage
|
|
12
|
+
- MySQL2 adapter extension for native database type mappings
|
|
13
|
+
- MySQL-specific type handling and schema dumping support
|
|
14
|
+
- Comprehensive MySQL test suite with performance and edge case testing
|
|
15
|
+
- CI pipeline support for MySQL 8.0 testing
|
|
16
|
+
- Updated documentation to include MySQL setup and compatibility notes
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Updated project description to reflect support for PostgreSQL, MySQL, and SQLite
|
|
20
|
+
- Enhanced test runner to support all three database adapters
|
|
21
|
+
- Updated development environment setup to include MySQL configuration
|
|
22
|
+
- Expanded database coverage from 2 to 3 major Rails database adapters
|
|
23
|
+
|
|
24
|
+
### Technical Details
|
|
25
|
+
- Added `lib/rails_uuid_pk/mysql2_adapter_extension.rb` for MySQL adapter integration
|
|
26
|
+
- Extended Railtie with MySQL-specific type mappings and adapter detection
|
|
27
|
+
- Enhanced migration helpers compatibility with MySQL VARCHAR(36) column detection
|
|
28
|
+
- Added MySQL performance testing (bulk operations, concurrent access, memory efficiency)
|
|
29
|
+
- Implemented MySQL edge case testing (long table names, special characters)
|
|
30
|
+
- Updated CI workflow with MySQL 8.0 service configuration
|
|
31
|
+
|
|
8
32
|
## [0.3.0] - 2026-01-09
|
|
9
33
|
|
|
10
34
|
### Added
|
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# rails-uuid-pk
|
|
2
2
|
|
|
3
3
|
**Dead-simple UUIDv7 primary keys for modern Rails apps**
|
|
4
|
-
Works great with **PostgreSQL 18
|
|
4
|
+
Works great with **PostgreSQL 18+**, **MySQL 8.0+**, and **SQLite 3.51+** — zero extra extensions required.
|
|
5
5
|
|
|
6
6
|
[](https://rubygems.org/gems/rails-uuid-pk)
|
|
7
7
|
[](https://www.ruby-lang.org)
|
|
@@ -12,8 +12,9 @@ Works great with **PostgreSQL 18+** and **SQLite 3.51+** — zero extra extensio
|
|
|
12
12
|
- Uses **native** `SecureRandom.uuid_v7` (Ruby 3.3+)
|
|
13
13
|
- Automatically sets `:uuid` as default primary key type
|
|
14
14
|
- Adds reliable `before_create` callback for UUIDv7 generation
|
|
15
|
-
- Works perfectly on **
|
|
15
|
+
- Works perfectly on **PostgreSQL 18+**, **MySQL 8.0+**, and **SQLite** (and older versions too)
|
|
16
16
|
- **PostgreSQL**: Uses native `UUID` column types with full database support
|
|
17
|
+
- **MySQL**: Uses `VARCHAR(36)` with custom ActiveRecord type handling
|
|
17
18
|
- **SQLite**: Uses `VARCHAR(36)` with custom ActiveRecord type handling
|
|
18
19
|
- Zero database extensions needed
|
|
19
20
|
- Minimal and maintainable — no monkey-patching hell
|
|
@@ -91,7 +92,9 @@ No manual `type: :uuid` specification needed!
|
|
|
91
92
|
|--------------------------------------|-----------------|-----------------------------------------------------------------------|
|
|
92
93
|
| UUIDv7 generation | Automatic | Uses `SecureRandom.uuid_v7` (very good randomness + monotonicity) |
|
|
93
94
|
| PostgreSQL 18+ native `uuidv7()` | Not used | Fallback approach — more universal, no extensions needed |
|
|
94
|
-
|
|
|
95
|
+
| PostgreSQL support | Full | Native `UUID` column types with full database support |
|
|
96
|
+
| MySQL 8.0+ support | Full | Uses `VARCHAR(36)` with custom ActiveRecord type handling |
|
|
97
|
+
| SQLite support | Full | Uses `VARCHAR(36)` with custom ActiveRecord type handling |
|
|
95
98
|
| Index locality / performance | Very good | UUIDv7 is monotonic → almost as good as sequential IDs |
|
|
96
99
|
| Zero config after install | Yes | Migration helpers automatically handle foreign key types |
|
|
97
100
|
| Works with Rails 7.1 – 8+ | Yes | Tested conceptually up to Rails 8.1+ |
|
|
@@ -119,15 +122,16 @@ This project includes a devcontainer configuration for VS Code. To get started:
|
|
|
119
122
|
|
|
120
123
|
### Running Tests
|
|
121
124
|
|
|
122
|
-
The project includes a comprehensive test suite that runs against
|
|
125
|
+
The project includes a comprehensive test suite that runs against SQLite, PostgreSQL, and MySQL.
|
|
123
126
|
|
|
124
127
|
```bash
|
|
125
|
-
# Run all tests (SQLite + PostgreSQL)
|
|
128
|
+
# Run all tests (SQLite + PostgreSQL + MySQL)
|
|
126
129
|
./bin/test
|
|
127
130
|
|
|
128
131
|
# Run tests for specific database
|
|
129
132
|
DB=sqlite ./bin/test # SQLite only
|
|
130
133
|
DB=postgres ./bin/test # PostgreSQL only
|
|
134
|
+
DB=mysql ./bin/test # MySQL only
|
|
131
135
|
```
|
|
132
136
|
|
|
133
137
|
### Code Quality
|
|
@@ -152,9 +156,10 @@ gem install rails-uuid-pk-0.1.0.gem
|
|
|
152
156
|
|
|
153
157
|
### Database Setup
|
|
154
158
|
|
|
155
|
-
For
|
|
159
|
+
For database testing, ensure the respective databases are running and accessible. The test suite uses these environment variables:
|
|
156
160
|
- `DB_HOST` (defaults to localhost)
|
|
157
161
|
- `RAILS_ENV=test_postgresql` for PostgreSQL tests
|
|
162
|
+
- `RAILS_ENV=test_mysql` for MySQL tests
|
|
158
163
|
|
|
159
164
|
## Contributing
|
|
160
165
|
|
|
@@ -17,6 +17,19 @@ module RailsUuidPk
|
|
|
17
17
|
RailsUuidPk::Type::Uuid.new
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
# Also map "uuid" SQL type to our custom UUID type for direct lookups
|
|
21
|
+
ActiveRecord::Base.connection.send(:type_map).register_type "uuid" do |sql_type|
|
|
22
|
+
RailsUuidPk::Type::Uuid.new
|
|
23
|
+
end
|
|
24
|
+
elsif ActiveRecord::Base.connection.adapter_name == "MySQL"
|
|
25
|
+
# Register the UUID type with ActiveRecord for MySQL
|
|
26
|
+
ActiveRecord::Type.register(:uuid, RailsUuidPk::Type::Uuid, adapter: :mysql2)
|
|
27
|
+
|
|
28
|
+
# Map varchar SQL type to our custom UUID type (since that's how UUID columns are stored in MySQL)
|
|
29
|
+
ActiveRecord::Base.connection.send(:type_map).register_type(/varchar/i) do |sql_type|
|
|
30
|
+
RailsUuidPk::Type::Uuid.new
|
|
31
|
+
end
|
|
32
|
+
|
|
20
33
|
# Also map "uuid" SQL type to our custom UUID type for direct lookups
|
|
21
34
|
ActiveRecord::Base.connection.send(:type_map).register_type "uuid" do |sql_type|
|
|
22
35
|
RailsUuidPk::Type::Uuid.new
|
|
@@ -30,6 +43,15 @@ module RailsUuidPk
|
|
|
30
43
|
ActiveRecord::ConnectionAdapters::SQLite3Adapter.prepend(RailsUuidPk::Sqlite3AdapterExtension)
|
|
31
44
|
end
|
|
32
45
|
|
|
46
|
+
initializer "rails-uuid-pk.mysql_native_types" do
|
|
47
|
+
begin
|
|
48
|
+
require "active_record/connection_adapters/mysql2_adapter"
|
|
49
|
+
ActiveRecord::ConnectionAdapters::Mysql2Adapter.prepend(RailsUuidPk::Mysql2AdapterExtension)
|
|
50
|
+
rescue LoadError
|
|
51
|
+
# MySQL adapter not available, skip MySQL-specific initialization
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
33
55
|
|
|
34
56
|
|
|
35
57
|
initializer "rails-uuid-pk.schema_format" do |app|
|
data/lib/rails_uuid_pk.rb
CHANGED
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.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joon Lee
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '8.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: mysql2
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 0.5.7
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 0.5.7
|
|
26
40
|
- !ruby/object:Gem::Dependency
|
|
27
41
|
name: pg
|
|
28
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -51,8 +65,8 @@ dependencies:
|
|
|
51
65
|
- - "~>"
|
|
52
66
|
- !ruby/object:Gem::Version
|
|
53
67
|
version: 2.9.0
|
|
54
|
-
description: Automatically use
|
|
55
|
-
Works with PostgreSQL and SQLite, zero configuration required.
|
|
68
|
+
description: Automatically use UUID v7 for all primary keys in Rails applications.
|
|
69
|
+
Works with PostgreSQL, MySQL, and SQLite, zero configuration required.
|
|
56
70
|
email:
|
|
57
71
|
- seouri@gmail.com
|
|
58
72
|
executables: []
|
|
@@ -69,6 +83,7 @@ files:
|
|
|
69
83
|
- lib/rails_uuid_pk.rb
|
|
70
84
|
- lib/rails_uuid_pk/concern.rb
|
|
71
85
|
- lib/rails_uuid_pk/migration_helpers.rb
|
|
86
|
+
- lib/rails_uuid_pk/mysql2_adapter_extension.rb
|
|
72
87
|
- lib/rails_uuid_pk/railtie.rb
|
|
73
88
|
- lib/rails_uuid_pk/sqlite3_adapter_extension.rb
|
|
74
89
|
- lib/rails_uuid_pk/type.rb
|
|
@@ -97,5 +112,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
97
112
|
requirements: []
|
|
98
113
|
rubygems_version: 4.0.3
|
|
99
114
|
specification_version: 4
|
|
100
|
-
summary: Dead-simple
|
|
115
|
+
summary: Dead-simple UUID v7 primary keys for Rails apps
|
|
101
116
|
test_files: []
|