Skip to content

Commit

Permalink
Merge pull request #821 from flyspray/testdata-existing-autoincrement
Browse files Browse the repository at this point in the history
autodetect next taskid for createTestData
  • Loading branch information
peterdd committed Aug 11, 2023
2 parents b82cfdc + 375e7f6 commit 9df87ba
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/createTestData.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,17 @@ function createTestData()
$codes=array('','php','xml','sql','html');

echo "Creating $maxtasks tasks: ";
# task id 1 is the single 'default task' after a fresh install.
$prevtaskopened = 1; # TODO use information_schema info about next auto_increment value of table {tasks}
$firsttaskid = $prevtaskopened + 1;
if ($conf['database']['dbtype'] == 'mysql' or $conf['database']['dbtype'] == 'mysqli') {
$sqlid=$db->query("SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=? AND TABLE_NAME=?",
array($conf['database']['dbname'], $conf['database']['dbprefix'].'tasks')
);
$firsttaskid = $db->fetchOne($sqlid);
$prevtaskopened = $firsttaskid - 1;
} else {
# TODO similiar for Postgresql and other (PDO?)
$prevtaskopened = 1;
$firsttaskid = $prevtaskopened + 1;
}
$finaltaskid=$maxtasks + $prevtaskopened;

for ($i = $firsttaskid; $i <= $finaltaskid; $i++) {
Expand Down

0 comments on commit 9df87ba

Please sign in to comment.