Only output trigger 'scope' if it's set in YAML and JSON producers
[dbsrgits/SQL-Translator.git] / t / 30sqlt-new-diff-sqlite.t
index 5d6ad92..34f6fb1 100644 (file)
@@ -23,7 +23,7 @@ my ( $source_schema, $target_schema ) = map {
       or die $tr->error;
     my $out = $t->translate( catfile($Bin, qw/data diff/, $_ ) )
       or die $tr->error;
-    
+
     my $schema = $t->schema;
     unless ( $schema->name ) {
         $schema->name( $_ );
@@ -32,11 +32,11 @@ my ( $source_schema, $target_schema ) = map {
 } (qw/create1.yml create2.yml/);
 
 # Test for differences
-my $out = SQL::Translator::Diff::schema_diff( $source_schema, 'SQLite', $target_schema, 'SQLite', 
-  { no_batch_alters => 1, 
+my $out = SQL::Translator::Diff::schema_diff( $source_schema, 'SQLite', $target_schema, 'SQLite',
+  { no_batch_alters => 1,
     ignore_missing_methods => 1,
     output_db => 'SQLite',
-  } 
+  }
 );
 
 eq_or_diff($out, <<'## END OF DIFF', "Diff as expected");
@@ -98,17 +98,19 @@ CREATE TABLE added (
 CREATE TEMPORARY TABLE employee_temp_alter (
   position varchar(50) NOT NULL,
   employee_id int(11) NOT NULL,
-  PRIMARY KEY (position, employee_id)
+  PRIMARY KEY (position, employee_id),
+  FOREIGN KEY (employee_id) REFERENCES person(person_id)
 );
 
-INSERT INTO employee_temp_alter SELECT position, employee_id FROM employee;
+INSERT INTO employee_temp_alter( position, employee_id) SELECT position, employee_id FROM employee;
 
 DROP TABLE employee;
 
 CREATE TABLE employee (
   position varchar(50) NOT NULL,
   employee_id int(11) NOT NULL,
-  PRIMARY KEY (position, employee_id)
+  PRIMARY KEY (position, employee_id),
+  FOREIGN KEY (employee_id) REFERENCES person(person_id)
 );
 
 INSERT INTO employee SELECT position, employee_id FROM employee_temp_alter;
@@ -126,10 +128,11 @@ CREATE TEMPORARY TABLE person_temp_alter (
   weight double(11,2),
   iq int(11) DEFAULT 0,
   is_rock_star tinyint(4) DEFAULT 1,
+  value double(8,2) DEFAULT 0.00,
   physical_description text
 );
 
-INSERT INTO person_temp_alter SELECT person_id, name, age, weight, iq, is_rock_star, physical_description FROM person;
+INSERT INTO person_temp_alter( person_id, name, age, weight, iq, value, physical_description) SELECT person_id, name, age, weight, iq, value, description FROM person;
 
 DROP TABLE person;
 
@@ -140,6 +143,7 @@ CREATE TABLE person (
   weight double(11,2),
   iq int(11) DEFAULT 0,
   is_rock_star tinyint(4) DEFAULT 1,
+  value double(8,2) DEFAULT 0.00,
   physical_description text
 );
 
@@ -149,7 +153,7 @@ CREATE UNIQUE INDEX UC_person_id02 ON person (person_id);
 
 CREATE UNIQUE INDEX UC_age_name02 ON person (age, name);
 
-INSERT INTO person SELECT person_id, name, age, weight, iq, is_rock_star, physical_description FROM person_temp_alter;
+INSERT INTO person SELECT person_id, name, age, weight, iq, is_rock_star, value, physical_description FROM person_temp_alter;
 
 DROP TABLE person_temp_alter;