uuid_migrations 0.1.0 → 0.2.1

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: e6793cd22e76c66409351c5042c3fc11341c1a2a1ada55e4d7cad3f6e54c3c65
4
- data.tar.gz: cda16681ccc123b10d4b225ea06eec2a6806b3ae33d78eb97232b6c3d033e508
3
+ metadata.gz: 6042d5733037b0c09e2e64258c3600f7331e9563d39cc04046634407113c4c80
4
+ data.tar.gz: a172ff865f8a11d1d659a5aa43d292b6bf4560e5a0364081077db01817c13c2b
5
5
  SHA512:
6
- metadata.gz: be5320095caaad7e511f870aee83616cf0125b97feaf005b465d8000f8b73862746255fb66497fb6ea2d3b7e4f5355d48a0519a686482dbea4a40bb718b76c1a
7
- data.tar.gz: f3433906dac69158798f72e449b4598cd56362d39a40325f0238266304242156f892eb8d21a3fc0ae36f80bfa67d88654a9734f60b87624f91229930be2ab4aa
6
+ metadata.gz: f7b2c6927d5f6ed4babe827b707d79e94d678fcbdc48fe7999c80e882810fde4331dea076e07019db90a70def50378fc5ef8033301a5ac9759a70217424c08e8
7
+ data.tar.gz: 4fde7e5bd8896678628924a4675008f158ed60dd3342ce6a3cda5f3da5c464a6f107f6acfebe4a8f3deeb873685b9bd7dbe0d4956e11a5eaddb17a26d8179b35
data/.standard.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  # For available configuration options, see:
2
2
  # https://github.com/standardrb/standard
3
- ruby_version: 3.0
3
+ format: progress
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1] - 2024-05-24
4
+
5
+ - Fix bug on schema load
6
+
7
+ ## [0.2.0] - 2024-05-24
8
+
9
+ - Adding `UuidMigrations.start_with` option
10
+
3
11
  ## [0.1.0] - 2024-05-24
4
12
 
5
13
  - Initial release
data/README.md CHANGED
@@ -14,7 +14,12 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
14
 
15
15
  ## Usage
16
16
 
17
- TODO: Write usage instructions here
17
+ By default, it will add `t.uuid` to all `create_table` in all your migrations.
18
+ To prevent adding `t.uuid` to migrations that were created before installing this gem, create an initializer with:
19
+
20
+ ```ruby
21
+ UuidMigrations.start_with = 20240524142747
22
+ ```
18
23
 
19
24
  ## Development
20
25
 
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UuidMigrations
4
+ module Migration
5
+ def migrate(direction)
6
+ uuid_migrations.checker.direction = direction
7
+ super
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UuidMigrations
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -1,14 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_record"
4
- require "active_record/connection_adapters/postgresql_adapter"
5
4
 
6
5
  module UuidMigrations
7
- def build_create_table_definition(table_name, **options)
8
- td = super
6
+ mattr_accessor :start_with
7
+
8
+ def add_uuid_column(td)
9
+ return td if version.blank? || (UuidMigrations.start_with.present? && version < UuidMigrations.start_with)
10
+
9
11
  td.column(:uuid, :uuid, default: -> { "gen_random_uuid()" }) if td[:uuid].blank?
10
12
  td
11
13
  end
14
+
15
+ def create_table(...)
16
+ if block_given?
17
+ super do |td|
18
+ yield(td)
19
+ add_uuid_column(td)
20
+ end
21
+ else
22
+ super
23
+ end
24
+ end
12
25
  end
13
26
 
14
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend UuidMigrations
27
+ ActiveRecord::Migration.prepend UuidMigrations
28
+ ActiveRecord::Migration::Current.prepend UuidMigrations
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uuid_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hallelujah
@@ -40,6 +40,7 @@ files:
40
40
  - README.md
41
41
  - Rakefile
42
42
  - lib/uuid_migrations.rb
43
+ - lib/uuid_migrations/migration.rb
43
44
  - lib/uuid_migrations/version.rb
44
45
  - sig/uuid_migrations.rbs
45
46
  homepage: https://github.com/propitech/uuid_migrations