10 # only add "" if we actually need them
11 s/\[([^]]+)\]/$1 =~ m{\W}?qq("$1"):$1/eg;
14 s/binary(?:\s*\([^)]+\))?/bytea/ig;
15 s/smalldatetime/TIMESTAMP/ig;
16 s/DATETIME/TIMESTAMP/ig;
17 s/(?:NON)?CLUSTERED\s*//g;
19 s/int\s*IDENTITY\s*\(\d+,\s*\d+\)/SERIAL/ig;
20 # mssql uses stupid names for indexes apparently; ditch them and
22 s/(CREATE\s+(?:UNIQUE\s+)?INDEX\s+)\S+\s+(ON\s+)/$1$2/gi;
23 # set defaults properly
25 s/(?<altertable>ALTER\s+TABLE\s+\S+) # table name
26 \s+ADD\s+CONSTRAINT\s+
28 (?<function>\((?<unbraceddef>(?:[^\(\)]++|(?&function))*)\)) # default value
30 (?<column>\S+) # column
31 /$+{altertable} ALTER COLUMN $+{column} SET DEFAULT $+{unbraceddef};/gix;
32 s/GETDATE\(\)/NOW()/gix;
38 $temp =~ s/\n(;)/$1/g;
39 $temp =~ s/\n\n+/\n/g;