3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/typed_uuid/psql_schema_dumper.rb', line 3
def extensions(stream)
super(stream)
stream.puts "## These are functions that must be enabled in order to support typed_uuids\n## in this database\nexecute <<-SQL\n CREATE OR REPLACE FUNCTION typed_uuid(t bytea) RETURNS uuid AS $$\n DECLARE\n bytes bytea := gen_random_bytes(16);\n uuid bytea;\n BEGIN\n bytes := set_byte(bytes, 6, (get_byte(bytes, 4) # get_byte(bytes, 8)) # get_byte(t, 0));\n bytes := set_byte(bytes, 7, (get_byte(bytes, 5) # get_byte(bytes, 9)) # get_byte(t, 1));\n RETURN encode( bytes, 'hex') :: uuid;\n END;\n $$ LANGUAGE plpgsql;\nSQL\n\n RB\n stream\nend\n"
|