uuid_v7 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +9 -4
- data/CHANGELOG.md +5 -0
- data/lib/uuid_v7/patches/mysql/fk_helper.rb +26 -24
- data/lib/uuid_v7/patches/mysql/fx_migration.rb +7 -0
- data/lib/uuid_v7/types/base.rb +1 -1
- data/lib/uuid_v7/version.rb +1 -1
- data/uuid_v7.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bfb30c0bb6b0b8ba240c7a3cafc4a0108ece68cceef7b076a1f7f81a6906c3c
|
4
|
+
data.tar.gz: 9563de770f70af0359ef6a443f6b7c723f8ac5b713448149de13b58a54484729
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df2e3e982b03512447da3edba9df9166ea97b1e22a3ae0ab1db2b46184331b445db009dc2d819499d03591ac944b29806b2a33568bb8bc7d0e77bda1ac2de617
|
7
|
+
data.tar.gz: ce8499ff324be43d751d16d55f9e783739a4c85b67b54854c0e36968d93a1b0cc5f755c2baa0ba905b3435fb17913cdbe2cf74314a4fbd8d1011e004320cfb56
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2024-
|
3
|
+
# on 2024-07-10 09:34:11 UTC using RuboCop version 1.57.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
11
|
+
Metrics/AbcSize:
|
12
|
+
Max: 23
|
13
|
+
|
9
14
|
# Offense count: 3
|
10
15
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
11
16
|
Metrics/MethodLength:
|
12
|
-
Max:
|
17
|
+
Max: 42
|
13
18
|
|
14
19
|
# Offense count: 2
|
15
20
|
# Configuration parameters: IgnoredMetadata.
|
@@ -32,7 +37,7 @@ RSpec/ExampleLength:
|
|
32
37
|
RSpec/MultipleExpectations:
|
33
38
|
Max: 2
|
34
39
|
|
35
|
-
# Offense count:
|
40
|
+
# Offense count: 7
|
36
41
|
# Configuration parameters: AllowedGroups.
|
37
42
|
RSpec/NestedGroups:
|
38
43
|
Max: 6
|
@@ -42,7 +47,7 @@ RSpec/SubjectStub:
|
|
42
47
|
Exclude:
|
43
48
|
- 'spec/integrations/migrations/mysql/fx_migration_spec.rb'
|
44
49
|
|
45
|
-
# Offense count:
|
50
|
+
# Offense count: 6
|
46
51
|
# This cop supports safe autocorrection (--autocorrect).
|
47
52
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
48
53
|
# URISchemes: http, https
|
data/CHANGELOG.md
CHANGED
@@ -1,35 +1,37 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
module
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
module UuidV7
|
4
|
+
module Patches
|
5
|
+
module Mysql
|
6
|
+
module FkHelper
|
7
|
+
# update_fk_uuid_between_table(parent_table_name: :engines, child_table_name: :pistons)
|
8
|
+
def update_fk_uuid_between_table(parent_table_name:, child_table_name:)
|
9
|
+
table_name_parent = parent_table_name.to_s.to_sym # :engines
|
10
|
+
table_name_child = child_table_name.to_s.to_sym # :pistons
|
11
|
+
foreign_key_id = :"#{table_name_parent.to_s.singularize}_id" # :engine_id
|
12
|
+
foreign_key_uuid = :"#{table_name_parent.to_s.singularize}_uuid" # :engine_uuid
|
12
13
|
|
13
|
-
|
14
|
+
add_column table_name_child, foreign_key_uuid, :binary, limit: 16, null: true # :pistons, :engine_uuid
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
# Update the foreign_key in child table
|
17
|
+
connection.execute <<-SQL.squish
|
18
|
+
UPDATE #{table_name_child} child
|
19
|
+
JOIN #{table_name_parent} parent ON child.#{foreign_key_id} = parent.id
|
20
|
+
SET child.#{foreign_key_uuid} = parent.uuid;
|
21
|
+
SQL
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
# change_column_null :pistons, :engine_uuid, false
|
24
|
+
change_column_null table_name_child, foreign_key_uuid, false
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
# add_index :pistons, :engine_uuid
|
27
|
+
add_index table_name_child, foreign_key_uuid
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
# add_foreign_key :pistons, :engines, column: :engine_uuid, primary_key: :uuid, type: :binary
|
30
|
+
add_foreign_key table_name_child, table_name_parent, column: foreign_key_uuid, primary_key: :uuid, type: :binary
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
# remove_column table_name_child, foreign_key_id
|
33
|
+
# rename_column table_name_child, foreign_key_uuid, foreign_key_id
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -45,6 +45,13 @@ module UuidV7
|
|
45
45
|
END
|
46
46
|
SQL
|
47
47
|
|
48
|
+
# Check for NULL created_at values
|
49
|
+
result = connection.exec_query(<<~SQL)
|
50
|
+
SELECT COUNT(*) AS count FROM #{table_name} WHERE created_at IS NULL;
|
51
|
+
SQL
|
52
|
+
|
53
|
+
raise ActiveRecord::RecordInvalid, "There are records with NULL created_at in #{table_name}" if (result.rows[0][0]).positive?
|
54
|
+
|
48
55
|
connection.execute <<~SQL
|
49
56
|
UPDATE #{table_name} SET #{column_name} = uuid_v7(created_at) WHERE #{column_name} IS NULL;
|
50
57
|
SQL
|
data/lib/uuid_v7/types/base.rb
CHANGED
data/lib/uuid_v7/version.rb
CHANGED
data/uuid_v7.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
|
14
14
|
spec.homepage = "https://github.com/joel/uuid_v7"
|
15
15
|
spec.license = "MIT"
|
16
|
-
spec.required_ruby_version = ">= 3.
|
16
|
+
spec.required_ruby_version = ">= 3.3.3"
|
17
17
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
19
19
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uuid_v7
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Azemar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -126,14 +126,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
126
|
requirements:
|
127
127
|
- - ">="
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: 3.
|
129
|
+
version: 3.3.3
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
132
|
- - ">="
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
|
-
rubygems_version: 3.5.
|
136
|
+
rubygems_version: 3.5.11
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Provides UUID V7 support for Ruby on Rails applications using Mysql and Sqlite.
|