Commit 4766d98f authored by Karamel's avatar Karamel
Browse files

Fix updatedbto8.2 for fiscal mirrors.

parent e8a45bdc
......@@ -32,6 +32,8 @@ if (!is_readable($cfgFile)) {
$ptApp = AppContext::loadFromConfig(parse_ini_file($cfgFile));
unset($cfgFile);
$isMirror = $ptApp->isFiscalMirror();
$db = $ptApp->getDbModule()->getDatabase($v8User);
if ($db === false) {
die(sprintf("V8 user %s not found\n", $v8User));
......@@ -42,18 +44,24 @@ $em = $ptApp->getDao()->getEntityManager();
$sqls = [];
switch ($db['type']) {
case 'postgresql':
$sqls[] = 'ALTER TABLE sessions ADD csperpetual DOUBLE PRECISION NOT NULL DEFAULT 0.0;';
if (!$isMirror) {
$sqls[] = 'ALTER TABLE sessions ADD csperpetual DOUBLE PRECISION NOT NULL DEFAULT 0.0;';
}
$sqls[] = 'CREATE SEQUENCE archiverequests_id_seq INCREMENT BY 1 MINVALUE 1 START 1;';
$sqls[] = 'CREATE TABLE archives (number INT NOT NULL, info TEXT NOT NULL, content BYTEA NOT NULL, contentHash VARCHAR(255) NOT NULL, signature VARCHAR(255) NOT NULL, PRIMARY KEY(number));';
$sqls[] = 'CREATE TABLE archiverequests (id INT NOT NULL, startDate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, stopDate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, processing BOOLEAN NOT NULL, PRIMARY KEY(id));';
break;
case 'mysql':
$sqls[] = 'ALTER TABLE sessions ADD csperpetual DOUBLE PRECISION NOT NULL DEFAULT 0.0;';
if (!$isMirror) {
$sqls[] = 'ALTER TABLE sessions ADD csperpetual DOUBLE PRECISION NOT NULL DEFAULT 0.0;';
}
$sqls[] = 'CREATE TABLE archives (number INT NOT NULL, info LONGTEXT NOT NULL, content LONGBLOB NOT NULL, contentHash VARCHAR(255) NOT NULL, signature VARCHAR(255) NOT NULL, PRIMARY KEY(number)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;';
$sqls[] = 'CREATE TABLE archiverequests (id INT AUTO_INCREMENT NOT NULL, startDate DATETIME NOT NULL, stopDate DATETIME NOT NULL, processing TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;';
break;
case 'sqlite':
$sqls = 'ALTER TABLE sessions ADD COLUMN csperpetual DOUBLE PRECISION NOT NULL DEFAULT 0.0;';
if (!$isMirror) {
$sqls = 'ALTER TABLE sessions ADD COLUMN csperpetual DOUBLE PRECISION NOT NULL DEFAULT 0.0;';
}
$sqls = 'CREATE TABLE archives (number INTEGER NOT NULL, info CLOB NOT NULL, content BLOB NOT NULL, contentHash VARCHAR(255) NOT NULL, signature VARCHAR(255) NOT NULL, PRIMARY KEY(number));';
$sqls = 'CREATE TABLE archiverequests (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, startDate DATETIME NOT NULL, stopDate DATETIME NOT NULL, processing BOOLEAN NOT NULL);';
break;
......@@ -65,6 +73,10 @@ foreach ($sqls as $sql) {
$stmt->execute();
}
if ($isMirror) {
return;
}
$crAPI = new CashregisterAPI($ptApp->getDao());
$cashRegisters = $crAPI->getAll();
foreach ($cashRegisters as $cr) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment