X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F08postgres-to-mysql.t;h=19a668b43b38107b141dd1f882fb5c90c7511a25;hb=2e11379ef0451e54acca5dee655b0c33272008ed;hp=23d82328595a8c5d6c5224c07bf93456d0798423;hpb=407bc860dcd264edba2430a506207874a0247257;p=dbsrgits%2FSQL-Translator.git diff --git a/t/08postgres-to-mysql.t b/t/08postgres-to-mysql.t index 23d8232..19a668b 100644 --- a/t/08postgres-to-mysql.t +++ b/t/08postgres-to-mysql.t @@ -1,7 +1,10 @@ #!/usr/local/bin/perl # vim: set ft=perl: -BEGIN { print "1..1\n" } +use strict; +use Test::More tests => 1; +use SQL::Translator; +use Data::Dumper; my $create = q| @@ -31,70 +34,15 @@ create table cvterm ( foreign key (cv_id) references cv (cv_id), name varchar(255) not null, termdefinition text, --- the primary dbxref for this term. Other dbxrefs may be cvterm_dbxref dbxref_id int, foreign key (dbxref_id) references dbxref (dbxref_id), unique(termname, cv_id) ); create index cvterm_idx1 on cvterm (cv_id); - -|; -#-- The unique key on termname, termtype_id ensures that all terms are -#-- unique within a given cv - -use SQL::Translator; -use Data::Dumper; - -$SQL::Translator::DEBUG = 1; - -my $tr = SQL::Translator->new(parser => "PostgreSQL", - producer => "MySQL" - #producer => "SQL::Translator::Producer::MySQL::translate" - #producer => sub { Dumper($_[1]) } - ); - -print "not " unless ($tr->translate(\$create)); -print "ok 1 # pointless test -- plz fix me!\n"; - -__END__ -__DATA__ - --- The cvterm module design is based on the ontology - --- ================================================ --- TABLE: cv --- ================================================ - -create table cv ( - cv_id serial not null, - primary key (cv_id), - cvname varchar not null, - cvdefinition text, - - unique(cvname) -); - --- ================================================ --- TABLE: cvterm --- ================================================ - -create table cvterm ( - cvterm_id serial not null, - primary key (cvterm_id), - cv_id int not null, - foreign key (cv_id) references cv (cv_id), - name varchar(255) not null, - termdefinition text, -- the primary dbxref for this term. Other dbxrefs may be cvterm_dbxref - dbxref_id int, - foreign key (dbxref_id) references dbxref (dbxref_id), - - unique(termname, cv_id) -- The unique key on termname, termtype_id ensures that all terms are -- unique within a given cv -); -create index cvterm_idx1 on cvterm (cv_id); -- ================================================ @@ -154,7 +102,10 @@ create table cvtermsynonym ( unique(cvterm_id, termsynonym) ); -create index cvterm_synonym_idx1 on cvterm_synonym (cvterm_id); + +-- The table "cvterm_synonym" doesn't exist, so +-- creating an index on it screws things up! +-- create index cvterm_synonym_idx1 on cvterm_synonym (cvterm_id); -- ================================================ -- TABLE: cvterm_dbxref @@ -173,3 +124,11 @@ create table cvterm_dbxref ( create index cvterm_dbxref_idx1 on cvterm_dbxref (cvterm_id); create index cvterm_dbxref_idx2 on cvterm_dbxref (dbxref_id); +|; + +my $tr = SQL::Translator->new( + parser => "PostgreSQL", + producer => "MySQL" +); + +ok( $tr->translate(\$create), 'Translate PG2My' );