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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c908c8d88e22891fb147c5663b41cafdc6af30bcac9fa1fbcfabc30b255968c0
4
- data.tar.gz: 2c5b7a5d99ae22350e9456b07b51b33a2dab4ac72308cac434264b935c15387b
3
+ metadata.gz: 4bfb30c0bb6b0b8ba240c7a3cafc4a0108ece68cceef7b076a1f7f81a6906c3c
4
+ data.tar.gz: 9563de770f70af0359ef6a443f6b7c723f8ac5b713448149de13b58a54484729
5
5
  SHA512:
6
- metadata.gz: 3377eca301f991088bb5efa01b36f242544dc0a61ac81065461aedf3748d4fde80d1798b19bd10c0e37c188b5387558ac4b215dc624e994ef773f06613533e43
7
- data.tar.gz: 77b5f0fbd47744296b8a51ad46c75f0ec999538a58f8765e4cdfa35c6206e8a5b12b0689260e862b7b5359be101dc9754ee8fead17bc8750e6e35ee80ee154a5
6
+ metadata.gz: df2e3e982b03512447da3edba9df9166ea97b1e22a3ae0ab1db2b46184331b445db009dc2d819499d03591ac944b29806b2a33568bb8bc7d0e77bda1ac2de617
7
+ data.tar.gz: ce8499ff324be43d751d16d55f9e783739a4c85b67b54854c0e36968d93a1b0cc5f755c2baa0ba905b3435fb17913cdbe2cf74314a4fbd8d1011e004320cfb56
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ require:
6
6
  - rubocop-rspec
7
7
 
8
8
  AllCops:
9
- TargetRubyVersion: 3.2.1
9
+ TargetRubyVersion: 3.3.3
10
10
  NewCops: enable
11
11
 
12
12
  Style/StringLiterals:
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-02-09 11:25:12 UTC using RuboCop version 1.59.0.
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: 38
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: 6
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: 4
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,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2024-07-10
4
+
5
+ - Fix Zeitwerk::NameError
6
+ - Check if created_at is present
7
+
3
8
  ## [0.1.2] - 2024-02-09
4
9
 
5
10
  Configure The Behaviours When UUID Is Invalid
@@ -1,35 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Alliantist
4
- module Migrations
5
- module UuidFkHelper
6
- # update_fk_uuid_between_table(parent_table_name: :engines, child_table_name: :pistons)
7
- def update_fk_uuid_between_table(parent_table_name:, child_table_name:)
8
- table_name_parent = parent_table_name.to_s.to_sym # :engines
9
- table_name_child = child_table_name.to_s.to_sym # :pistons
10
- foreign_key_id = :"#{table_name_parent.to_s.singularize}_id" # :engine_id
11
- foreign_key_uuid = :"#{table_name_parent.to_s.singularize}_uuid" # :engine_uuid
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
- add_column table_name_child, foreign_key_uuid, :binary, limit: 16, null: true # :pistons, :engine_uuid
14
+ add_column table_name_child, foreign_key_uuid, :binary, limit: 16, null: true # :pistons, :engine_uuid
14
15
 
15
- # Update the foreign_key in child table
16
- connection.execute <<-SQL.squish
17
- UPDATE #{table_name_child} child
18
- JOIN #{table_name_parent} parent ON child.#{foreign_key_id} = parent.id
19
- SET child.#{foreign_key_uuid} = parent.uuid;
20
- SQL
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
- # change_column_null :pistons, :engine_uuid, false
23
- change_column_null table_name_child, foreign_key_uuid, false
23
+ # change_column_null :pistons, :engine_uuid, false
24
+ change_column_null table_name_child, foreign_key_uuid, false
24
25
 
25
- # add_index :pistons, :engine_uuid
26
- add_index table_name_child, foreign_key_uuid
26
+ # add_index :pistons, :engine_uuid
27
+ add_index table_name_child, foreign_key_uuid
27
28
 
28
- # add_foreign_key :pistons, :engines, column: :engine_uuid, primary_key: :uuid, type: :binary
29
- add_foreign_key table_name_child, table_name_parent, column: foreign_key_uuid, primary_key: :uuid, type: :binary
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
- # remove_column table_name_child, foreign_key_id
32
- # rename_column table_name_child, foreign_key_uuid, foreign_key_id
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
@@ -77,7 +77,7 @@ module UuidV7
77
77
  def initialize(value)
78
78
  @value = value
79
79
 
80
- super(value)
80
+ super
81
81
  end
82
82
 
83
83
  def hex
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UuidV7
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
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.2.1"
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.2
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-02-09 00:00:00.000000000 Z
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.2.1
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.3
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.