mirror of
https://github.com/friendica/friendica
synced 2024-12-22 22:40:16 +00:00
Check for existance before creation
This commit is contained in:
parent
156712597c
commit
366ff0a8b7
1 changed files with 18 additions and 13 deletions
31
update.php
31
update.php
|
@ -434,10 +434,12 @@ function update_1347()
|
||||||
|
|
||||||
function pre_update_1348()
|
function pre_update_1348()
|
||||||
{
|
{
|
||||||
DBA::insert('contact', ['nurl' => '']);
|
if (!DBA::exists('contact', ['id' => 0])) {
|
||||||
$lastid = DBA::lastInsertId();
|
DBA::insert('contact', ['nurl' => '']);
|
||||||
if ($lastid != 0) {
|
$lastid = DBA::lastInsertId();
|
||||||
DBA::update('contact', ['id' => 0], ['id' => $lastid]);
|
if ($lastid != 0) {
|
||||||
|
DBA::update('contact', ['id' => 0], ['id' => $lastid]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The tables "permissionset" and "tag" could or could not exist during the update.
|
// The tables "permissionset" and "tag" could or could not exist during the update.
|
||||||
|
@ -453,17 +455,20 @@ function update_1348()
|
||||||
{
|
{
|
||||||
// Insert a permissionset with id=0
|
// Insert a permissionset with id=0
|
||||||
// Setting it to -1 and then changing the value to 0 tricks the auto increment
|
// Setting it to -1 and then changing the value to 0 tricks the auto increment
|
||||||
DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']);
|
if (!DBA::exists('permissionset', ['id' => 0])) {
|
||||||
$lastid = DBA::lastInsertId();
|
DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']);
|
||||||
if ($lastid != 0) {
|
$lastid = DBA::lastInsertId();
|
||||||
DBA::update('permissionset', ['id' => 0], ['id' => $lastid]);
|
if ($lastid != 0) {
|
||||||
|
DBA::update('permissionset', ['id' => 0], ['id' => $lastid]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!DBA::exists('tag', ['id' => 0])) {
|
||||||
DBA::insert('tag', ['name' => '']);
|
DBA::insert('tag', ['name' => '']);
|
||||||
$lastid = DBA::lastInsertId();
|
$lastid = DBA::lastInsertId();
|
||||||
if ($lastid != 0) {
|
if ($lastid != 0) {
|
||||||
DBA::update('tag', ['id' => 0], ['id' => $lastid]);
|
DBA::update('tag', ['id' => 0], ['id' => $lastid]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Update::SUCCESS;
|
return Update::SUCCESS;
|
||||||
|
|
Loading…
Reference in a new issue