$sql="INSERT INTO test_groups (product_id,name,testrunner_plan_id,enabled) SELECT product_id,name,testrunner_plan_id,enabled FROM test_groups WHERE testgroup_id=?";
print$sql,"\n";
my$rv;
$rv=$litmus_dbh->do($sql,undef,$testgroup_id);
if($rv<=0){
die"Testgroup insert failed: $!";
}
$sql="SELECT MAX(testgroup_id) FROM test_groups";
$sth=$litmus_dbh->prepare($sql);
$sth->execute();
my($new_testgroup_id)=$sth->fetchrow_array;
$sth->finish;
if(!$new_testgroup_id){
die"Unable to lookup new testgroup_id!";
}
print"New testgroup id: $new_testgroup_id\n";
$sql="SELECT subgroup_id,testgroup_id,name,sort_order,testrunner_group_id,enabled FROM subgroups WHERE testgroup_id=?";
$sth=$litmus_dbh->prepare($sql);
$sth->execute($testgroup_id);
my@subgroups;
while(my$hashref=$sth->fetchrow_hashref){
push@subgroups,$hashref;
}
$sth->finish;
foreachmy$subgroup(@subgroups){
$rv=$litmus_dbh->do("INSERT INTO subgroups (testgroup_id,name,sort_order,testrunner_group_id,enabled) VALUES (?,?,?,?,?)",
undef,
$new_testgroup_id,
$subgroup->{'name'},
$subgroup->{'sort_order'},
$subgroup->{'testrunner_group_id'},
$subgroup->{'enabled'},
);
$sql="SELECT MAX(subgroup_id) FROM subgroups";
$sth=$litmus_dbh->prepare($sql);
$sth->execute();
my($new_subgroup_id)=$sth->fetchrow_array;
$sth->finish;
$rv=$litmus_dbh->do("INSERT INTO tests (subgroup_id,summary,details,community_enabled,format_id,regression_bug_id,steps,expected_results,sort_order,author_id,creation_date,last_updated,version,testrunner_case_id,testrunner_case_version,enabled) SELECT $new_subgroup_id,summary,details,community_enabled,format_id,regression_bug_id,steps,expected_results,sort_order,author_id,creation_date,last_updated,version,testrunner_case_id,testrunner_case_version,enabled FROM tests WHERE subgroup_id=?",