rails-uuid-pk 0.4.0 → 0.5.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 +21 -0
- data/README.md +6 -16
- data/lib/rails_uuid_pk/version.rb +1 -1
- metadata +1 -4
- data/app/models/concerns/has_uuidv7_primary_key.rb +0 -17
- data/lib/generators/rails_uuid_pk/install/install_generator.rb +0 -42
- data/lib/generators/rails_uuid_pk/install/templates/has_uuidv7_primary_key.rb +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 615c351b860e9cf6b5cc663f8f1a8d4c5781bb6f7f12d658440f42a3173d8fc0
|
|
4
|
+
data.tar.gz: 5973fbaed1fb21337bd3e3377c59f7ba410dd50d8837eb444e0c15ead96ddaaf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9a9adf355b72109ed26fa08586983581aa0b4005bbbbc504782a6f5297198b4852f6b664138b24976f2405c464adeba017d177143b15f95761b2901f2aee336
|
|
7
|
+
data.tar.gz: bde5e20373b9d07a9013194f3b90faa01cdad6a63de4598b1d1925c0b80694c8416256290f4410d4c4821c1e7ff51e5bcb9281753bcc12f0ec31fa56c06790be
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ 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.5.0] - 2026-01-10
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **Made gem truly zero-configuration**: Removed install generator and concern file
|
|
12
|
+
- Simplified installation to just `bundle install` - no generator command needed
|
|
13
|
+
- Removed `app/models/concerns/has_uuidv7_primary_key.rb` template and explicit inclusion option
|
|
14
|
+
- Updated documentation to reflect simplified zero-config approach
|
|
15
|
+
- All functionality now works automatically through Railtie inclusion
|
|
16
|
+
|
|
17
|
+
### Removed
|
|
18
|
+
- Install generator (`rails g rails_uuid_pk:install`)
|
|
19
|
+
- Optional concern file for explicit inclusion
|
|
20
|
+
- Generator template and associated test cases
|
|
21
|
+
- Manual installation steps and configuration options
|
|
22
|
+
|
|
23
|
+
### Technical Details
|
|
24
|
+
- Eliminated generator complexity while maintaining all core functionality
|
|
25
|
+
- Streamlined user experience - just add gem to Gemfile and it works
|
|
26
|
+
- Removed optional explicit concern inclusion in favor of automatic Railtie-based inclusion
|
|
27
|
+
- Updated AGENTS.md and README.md to reflect simplified architecture
|
|
28
|
+
|
|
8
29
|
## [0.4.0] - 2026-01-10
|
|
9
30
|
|
|
10
31
|
### Added
|
data/README.md
CHANGED
|
@@ -24,21 +24,16 @@ Works great with **PostgreSQL 18+**, **MySQL 8.0+**, and **SQLite 3.51+** — ze
|
|
|
24
24
|
Add to your `Gemfile`:
|
|
25
25
|
|
|
26
26
|
```ruby
|
|
27
|
-
gem "rails-uuid-pk", "~> 0.
|
|
27
|
+
gem "rails-uuid-pk", "~> 0.5"
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Then run:
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
33
|
bundle install
|
|
34
|
-
rails generate rails_uuid_pk:install
|
|
35
34
|
```
|
|
36
35
|
|
|
37
|
-
The
|
|
38
|
-
|
|
39
|
-
- Set `primary_key_type: :uuid` in your generators config
|
|
40
|
-
- Create `app/models/concerns/has_uuidv7_primary_key.rb` (optional explicit include)
|
|
41
|
-
- Show important compatibility notes
|
|
36
|
+
That's it! The gem automatically enables UUIDv7 primary keys for all your models.
|
|
42
37
|
|
|
43
38
|
## Usage
|
|
44
39
|
|
|
@@ -60,32 +55,27 @@ User.create!(name: "Alice") # ← id is automatically a proper UUIDv7
|
|
|
60
55
|
|
|
61
56
|
### Action Text & Active Storage
|
|
62
57
|
|
|
63
|
-
When you
|
|
58
|
+
When you install Action Text or Active Storage:
|
|
64
59
|
|
|
65
60
|
```bash
|
|
66
61
|
rails action_text:install
|
|
67
62
|
rails active_storage:install
|
|
68
63
|
```
|
|
69
64
|
|
|
70
|
-
The generated migrations
|
|
71
|
-
|
|
72
|
-
This works because rails-uuid-pk includes smart migration helpers that detect the primary key type of referenced tables and automatically set `type: :uuid` for foreign keys.
|
|
65
|
+
The generated migrations seamlessly integrate with UUID primary keys. Rails-uuid-pk's smart migration helpers automatically detect UUID primary keys in referenced tables and set the appropriate `type: :uuid` for foreign keys.
|
|
73
66
|
|
|
74
67
|
### Polymorphic associations
|
|
75
68
|
|
|
76
|
-
|
|
69
|
+
Polymorphic associations work seamlessly with UUID primary keys. Whether you're using Action Text's `record` references or custom polymorphic associations, the migration helpers automatically detect the parent table's primary key type and set the correct foreign key type.
|
|
77
70
|
|
|
78
|
-
For
|
|
71
|
+
For example, this migration will automatically use `type: :uuid` when the parent models have UUID primary keys:
|
|
79
72
|
|
|
80
73
|
```ruby
|
|
81
|
-
# This will automatically use type: :uuid if the parent models have UUID primary keys
|
|
82
74
|
create_table :comments do |t|
|
|
83
75
|
t.references :commentable, polymorphic: true
|
|
84
76
|
end
|
|
85
77
|
```
|
|
86
78
|
|
|
87
|
-
No manual `type: :uuid` specification needed!
|
|
88
|
-
|
|
89
79
|
## Features / Trade-offs
|
|
90
80
|
|
|
91
81
|
| Feature | Status | Notes |
|
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.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joon Lee
|
|
@@ -77,9 +77,6 @@ files:
|
|
|
77
77
|
- MIT-LICENSE
|
|
78
78
|
- README.md
|
|
79
79
|
- Rakefile
|
|
80
|
-
- app/models/concerns/has_uuidv7_primary_key.rb
|
|
81
|
-
- lib/generators/rails_uuid_pk/install/install_generator.rb
|
|
82
|
-
- lib/generators/rails_uuid_pk/install/templates/has_uuidv7_primary_key.rb
|
|
83
80
|
- lib/rails_uuid_pk.rb
|
|
84
81
|
- lib/rails_uuid_pk/concern.rb
|
|
85
82
|
- lib/rails_uuid_pk/migration_helpers.rb
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# app/models/concerns/has_uuidv7_primary_key.rb
|
|
2
|
-
# (this file is copied by the generator - you can modify it later if needed)
|
|
3
|
-
|
|
4
|
-
module HasUuidv7PrimaryKey
|
|
5
|
-
extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
-
included do
|
|
8
|
-
before_create :assign_uuidv7_if_needed, if: -> { id.nil? }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def assign_uuidv7_if_needed
|
|
14
|
-
return if id.present?
|
|
15
|
-
self.id = SecureRandom.uuid_v7
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
module RailsUuidPk
|
|
2
|
-
module Generators
|
|
3
|
-
class InstallGenerator < Rails::Generators::Base
|
|
4
|
-
source_root File.expand_path("templates", __dir__)
|
|
5
|
-
|
|
6
|
-
desc "Installs rails-uuid-pk: sets uuid primary key + includes UUIDv7 concern"
|
|
7
|
-
|
|
8
|
-
def add_concern_file
|
|
9
|
-
copy_file "has_uuidv7_primary_key.rb",
|
|
10
|
-
"app/models/concerns/has_uuidv7_primary_key.rb"
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def show_next_steps
|
|
14
|
-
say "\nrails-uuid-pk was successfully installed!", :green
|
|
15
|
-
|
|
16
|
-
say "\n✅ Action Text & Active Storage compatibility", :green
|
|
17
|
-
say "─────────────────────────────────────────────────────────────"
|
|
18
|
-
say "Migration helpers now automatically handle foreign key types!"
|
|
19
|
-
say "When you run:"
|
|
20
|
-
say " rails action_text:install"
|
|
21
|
-
say " rails active_storage:install"
|
|
22
|
-
say ""
|
|
23
|
-
say "The generated migrations will automatically use the correct UUID types"
|
|
24
|
-
say "for foreign keys. No manual editing required!"
|
|
25
|
-
say "─────────────────────────────────────────────────────────────\n"
|
|
26
|
-
|
|
27
|
-
say "\nRecommended next steps:", :yellow
|
|
28
|
-
say " 1. Add to ApplicationRecord (if you prefer explicit include):"
|
|
29
|
-
say " class ApplicationRecord < ActiveRecord::Base"
|
|
30
|
-
say " primary_abstract_class"
|
|
31
|
-
say " include HasUuidv7PrimaryKey"
|
|
32
|
-
say " end\n"
|
|
33
|
-
|
|
34
|
-
say " 2. Or keep relying on Railtie automatic include (recommended for most cases)\n"
|
|
35
|
-
|
|
36
|
-
say " 3. Now you can run:", :cyan
|
|
37
|
-
say " rails g model User name:string email:string\n"
|
|
38
|
-
say " → will create table with uuid primary key + automatic uuidv7\n"
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# app/models/concerns/has_uuidv7_primary_key.rb
|
|
2
|
-
# (this file is copied by the generator - you can modify it later if needed)
|
|
3
|
-
|
|
4
|
-
module HasUuidv7PrimaryKey
|
|
5
|
-
extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
-
included do
|
|
8
|
-
before_create :assign_uuidv7_if_needed, if: -> { id.nil? }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def assign_uuidv7_if_needed
|
|
14
|
-
return if id.present?
|
|
15
|
-
self.id = SecureRandom.uuid_v7
|
|
16
|
-
end
|
|
17
|
-
end
|