Check for existance before creation
This commit is contained in:
parent
156712597c
commit
366ff0a8b7
|
@ -434,11 +434,13 @@ function update_1347()
|
|||
|
||||
function pre_update_1348()
|
||||
{
|
||||
if (!DBA::exists('contact', ['id' => 0])) {
|
||||
DBA::insert('contact', ['nurl' => '']);
|
||||
$lastid = DBA::lastInsertId();
|
||||
if ($lastid != 0) {
|
||||
DBA::update('contact', ['id' => 0], ['id' => $lastid]);
|
||||
}
|
||||
}
|
||||
|
||||
// The tables "permissionset" and "tag" could or could not exist during the update.
|
||||
// This depends upon the previous version. Depending upon this situation we have to add
|
||||
|
@ -453,18 +455,21 @@ function update_1348()
|
|||
{
|
||||
// Insert a permissionset with id=0
|
||||
// Setting it to -1 and then changing the value to 0 tricks the auto increment
|
||||
if (!DBA::exists('permissionset', ['id' => 0])) {
|
||||
DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']);
|
||||
$lastid = DBA::lastInsertId();
|
||||
if ($lastid != 0) {
|
||||
DBA::update('permissionset', ['id' => 0], ['id' => $lastid]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!DBA::exists('tag', ['id' => 0])) {
|
||||
DBA::insert('tag', ['name' => '']);
|
||||
$lastid = DBA::lastInsertId();
|
||||
if ($lastid != 0) {
|
||||
DBA::update('tag', ['id' => 0], ['id' => $lastid]);
|
||||
}
|
||||
}
|
||||
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue