typed_uuid 2.0 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/typed_uuid.rb +1 -0
- data/lib/typed_uuid/psql_schema_dumper.rb +25 -0
- data/lib/typed_uuid/railtie.rb +3 -1
- data/lib/typed_uuid/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0743664e3f9987059821b25c8c42f80b062bbeeb3ba563e795d4b9845920505
|
4
|
+
data.tar.gz: ec150decbaced84ca8cbd26b06af761551969ee9cc74145291c552215ab2a94b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3e66ca9962d22a9ccece4458708c132e776062dc5d10071b715816c4c5329a99c6bea6b172e0f33a55c274a761e0850c1cb4a957b31de2124f3942d60204aa3
|
7
|
+
data.tar.gz: 502b8f036034be6a080aa0722b26918810589fc741666d2ab4f0c125d987895bc2ba19ab886b79ff13b97e38b50698808dbc28eb80d2b1d822c1dda055f89ad3
|
data/lib/typed_uuid.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module TypedUUID::PsqlSchemaDumper
|
2
|
+
|
3
|
+
def extensions(stream)
|
4
|
+
super(stream)
|
5
|
+
stream.puts <<-RB
|
6
|
+
## These are functions that must be enabled in order to support typed_uuids
|
7
|
+
## in this database
|
8
|
+
execute <<-SQL
|
9
|
+
CREATE OR REPLACE FUNCTION typed_uuid(t bytea) RETURNS uuid AS $$
|
10
|
+
DECLARE
|
11
|
+
bytes bytea := gen_random_bytes(16);
|
12
|
+
uuid bytea;
|
13
|
+
BEGIN
|
14
|
+
bytes := set_byte(bytes, 6, (get_byte(bytes, 4) # get_byte(bytes, 8)) # get_byte(t, 0));
|
15
|
+
bytes := set_byte(bytes, 7, (get_byte(bytes, 5) # get_byte(bytes, 9)) # get_byte(t, 1));
|
16
|
+
RETURN encode( bytes, 'hex') :: uuid;
|
17
|
+
END;
|
18
|
+
$$ LANGUAGE plpgsql;
|
19
|
+
SQL
|
20
|
+
|
21
|
+
RB
|
22
|
+
stream
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/typed_uuid/railtie.rb
CHANGED
@@ -8,7 +8,9 @@ class TypedUUID::Railtie < Rails::Railtie
|
|
8
8
|
end
|
9
9
|
|
10
10
|
require 'active_record/connection_adapters/postgresql/schema_definitions'
|
11
|
-
ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition.include
|
11
|
+
ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition.include(TypedUUID::PsqlColumnMethods)
|
12
|
+
|
13
|
+
ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend(TypedUUID::PsqlSchemaDumper)
|
12
14
|
end
|
13
15
|
|
14
16
|
end
|
data/lib/typed_uuid/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typed_uuid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Bracy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- lib/typed_uuid.rb
|
182
182
|
- lib/typed_uuid/active_record.rb
|
183
183
|
- lib/typed_uuid/psql_column_methods.rb
|
184
|
+
- lib/typed_uuid/psql_schema_dumper.rb
|
184
185
|
- lib/typed_uuid/railtie.rb
|
185
186
|
- lib/typed_uuid/version.rb
|
186
187
|
- test/test_helper.rb
|