From d01335340987ac49ad8fdcc778326839f32bdafd Mon Sep 17 00:00:00 2001 From: andryyy Date: Mon, 30 Jan 2017 11:24:07 +0100 Subject: [PATCH] Do not overwrite admin on db update --- data/web/inc/init.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/web/inc/init.sql b/data/web/inc/init.sql index b2cff817..6dc7fa4b 100644 --- a/data/web/inc/init.sql +++ b/data/web/inc/init.sql @@ -276,6 +276,6 @@ CREATE TABLE IF NOT EXISTS sogo_user_profile ( PRIMARY KEY (c_uid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; -REPLACE INTO admin (username, password, superadmin, created, modified, active) VALUES ('admin', '{SSHA256}K8eVJ6YsZbQCfuJvSUbaQRLr0HPLz5rC9IAp0PAFl0tmNDBkMDc0NDAyOTAxN2Rk', 1, NOW(), NOW(), 1); -DELETE FROM domain_admins WHERE domain='all'; -INSERT INTO domain_admins (username, domain, created, active) VALUES ('admin', 'ALL', NOW(), 1); +INSERT INTO `admin` (username, password, superadmin, created, modified, active) SELECT 'admin', '{SSHA256}K8eVJ6YsZbQCfuJvSUbaQRLr0HPLz5rC9IAp0PAFl0tmNDBkMDc0NDAyOTAxN2Rk', 1, NOW(), NOW(), 1 FROM `admin` WHERE NOT EXISTS (SELECT * FROM `admin`); +DELETE FROM `domain_admins`; +INSERT INTO `domain_admins` (username, domain, created, active) SELECT `username`, 'ALL', NOW(), 1 FROM `admin` WHERE superadmin='1' AND `username` NOT IN (SELECT `username` FROM `domain_admins`);