From: Don Armstrong Date: Mon, 12 Dec 2011 21:57:56 +0000 (-0800) Subject: move gty1 index creation; update mssql psql conversion X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;ds=inline;h=6e51d2d339036d36e6294b1bbed27e5c18a6a2f5;p=dbsnp.git move gty1 index creation; update mssql psql conversion --- diff --git a/schema/human_9606_schema/human_gty1_indexes_creation.pl b/schema/human_9606_schema/human_gty1_indexes_creation.pl deleted file mode 100755 index c4f0340..0000000 --- a/schema/human_9606_schema/human_gty1_indexes_creation.pl +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; -my @chr = (1..22, - qw(AltOnly MT NewSs NotOn PAR Un X Y) - ); -my %chr; -@chr{@chr} = @chr; -$chr{NewSs} = 'ss'; - -my %args; -@args{map {my $a = $_; lc($a)} @ARGV} = 1; - -if ($args{drop}) { - for my $chr (@chr) { - print "DROP TABLE SubInd_ch${chr};\n"; - } - print "DROP TABLE SubInd;\n"; -} -if ($args{create}) { - print <) { - s/\[([^]]+)\]/"$1"/g; - s/^\s*GO\s*$/;/; + # only add "" if we actually need them + s/\[([^]]+)\]/$1 =~ m{\W}?qq("$1"):$1/eg; + s/^\s*GO$/;/; s/tinyint/smallint/; s/binary(?:\s*\([^)]+\))?/bytea/ig; s/smalldatetime/TIMESTAMP/ig; s/DATETIME/TIMESTAMP/ig; - s/(?:NON)?CLUSTERED//g; + s/(?:NON)?CLUSTERED\s*//g; + s/\s*ASC\s*//g; s/int\s*IDENTITY\s*\(\d+,\s*\d+\)/SERIAL/ig; # mssql uses stupid names for indexes apparently; ditch them and # let pgsql choose s/(CREATE\s+(?:UNIQUE\s+)?INDEX\s+)\S+\s+(ON\s+)/$1$2/gi; - print $_; + # set defaults properly +# use re 'debug'; + s/(?ALTER\s+TABLE\s+\S+) # table name + \s+ADD\s+CONSTRAINT\s+ + \S+\s+DEFAULT\s+ + (?\((?(?:[^\(\)]++|(?&function))*)\)) # default value + \s+FOR\s+ + (?\S+) # column + /$+{altertable} ALTER COLUMN $+{column} SET DEFAULT $+{unbraceddef};/gix; + s/GETDATE\(\)/NOW()/gix; + $temp .= $_; } +$temp =~ s/\r//g; + +# cleanup \n; madness +$temp =~ s/\n(;)/$1/g; +$temp =~ s/\n\n+/\n/g; +print $temp;