uuid_migrations 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +6 -1
- data/lib/uuid_migrations/migration.rb +10 -0
- data/lib/uuid_migrations/version.rb +1 -1
- data/lib/uuid_migrations.rb +18 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91380dc0c6b33e0413b1e1f7ce768adb10b4c36f811eaad40482bbe85ceb8f41
|
4
|
+
data.tar.gz: a66d3cc80e2d336458cb9d70014afb67c202dee58213e3f6700ba5874398e9b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 930ca688a3614b8f7b93465667c6de5a46caf9ffd8dd0e54dc820282583aa34c45087fa3fd6a8a030b98533e2414acd42c3daf959884dbc5cb407f31e471f805
|
7
|
+
data.tar.gz: 43d091cf8c8fd0762ca1a5c925a07bda076d2d9ed0fd8552cd78567c99ce5345e272c76cc6031198fa68aa4d4af180d0b0f0eb4f5b57fc66e8f122108ef85c7e
|
data/.standard.yml
CHANGED
data/CHANGELOG.md
CHANGED
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
|
-
|
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
|
|
data/lib/uuid_migrations.rb
CHANGED
@@ -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
|
-
|
8
|
-
|
6
|
+
mattr_accessor :start_with
|
7
|
+
|
8
|
+
def add_uuid_column(td)
|
9
|
+
return td if 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::
|
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.
|
4
|
+
version: 0.2.0
|
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
|