first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,162 @@
<?php
class Upgrade24 extends Upgrade
{
public function upgrade()
{
$changed = false;
// jestlize je opravnene udelat upgrade, tak provest
if (findModule('feeds') && $this->checkRightfulness_1()) {
$this->makeChanges_1();
$changed = true;
}
if (findModule('feeds') && $this->checkRightfulness_2()) {
$this->makeChanges_2();
$changed = true;
}
if (findModule('products_parameters') && $this->checkRightfulness_3()) {
$this->makeChanges_3();
$changed = true;
}
if ($this->checkRightfulness_4() && (
findModule(Modules::PRODUCTS_SUPPLIERS)
|| findModule(Modules::SUPPLIERS)
)) {
$this->makeChanges_4();
$changed = true;
}
if (findModule('sliders') && $this->checkRightfulness_5()) {
$this->makeChanges_5();
$changed = true;
}
if ($this->checkRightfulness_8()) {
$this->makeChanges_8();
$changed = true;
}
if ($changed == false) {
$this->noChanges();
}
$this->printResult();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_1()
{
return $this->checkColumnExists('sections', 'feed_heureka');
}
// provest samotny upgrade
public function makeChanges_1()
{
sqlQuery('ALTER TABLE '.getTableName('sections').' ADD `feed_heureka` INT(11) NULL DEFAULT NULL');
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_2()
{
return $this->checkColumnExists('sections', 'feed_google');
}
// provest samotny upgrade
public function makeChanges_2()
{
sqlQuery('ALTER TABLE '.getTableName('sections').' ADD `feed_google` INT(11) NULL DEFAULT NULL');
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_3()
{
return $this->checkColumnType('parameters', 'descr', 'text') && $this->checkColumnType('parameters', 'descr', 'mediumtext');
}
// provest samotny upgrade
public function makeChanges_3()
{
sqlQuery('ALTER TABLE '.getTableName('parameters').' CHANGE `descr` `descr` TEXT NOT NULL');
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_4()
{
return $this->checkColumnExists('products_of_suppliers', 'price_buy');
}
// provest samotny upgrade
public function makeChanges_4()
{
sqlQuery('ALTER TABLE '.getTableName('products_of_suppliers').'
ADD `price_buy` DOUBLE NULL DEFAULT NULL,
ADD `price_sell` DOUBLE NULL DEFAULT NULL');
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_5()
{
return $this->checkTableExists('sliders');
}
// provest samotny upgrade
public function makeChanges_5()
{
sqlQuery('CREATE TABLE '.getTableName('sliders').' (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB ');
sqlQuery('CREATE TABLE '.getTableName('sliders_images')." (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`id_slider` INT(11) NOT NULL,
`image` VARCHAR(50) NOT NULL,
`position` INT(11) NOT NULL DEFAULT '1',
`description` TEXT,
`link` TEXT,
PRIMARY KEY (`id`),
KEY `id_slider` (`id_slider`)
) ENGINE=InnoDB");
sqlQuery('ALTER TABLE '.getTableName('sliders_images').'
ADD CONSTRAINT `sliders_images_ibfk_1` FOREIGN KEY (`id_slider`) REFERENCES `sliders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE');
sqlQuery('INSERT INTO '.getTableName('sliders')." (`id`, `name`) VALUES (1, 'Úvod')");
$this->upgradeOK();
}
// overi, jestli je opravnene provest upgrade
public function checkRightfulness_8()
{
return $this->checkForeignKeyExists('articles_authors_admins', 'id_admin');
}
// provest samotny upgrade
public function makeChanges_8()
{
sqlQuery('ALTER TABLE '.getTableName('articles_authors_admins').' ADD FOREIGN KEY ( `id_admin` ) REFERENCES `admins` (
`id`
) ON DELETE CASCADE ON UPDATE CASCADE');
sqlQuery('ALTER TABLE '.getTableName('articles_authors_admins').' ADD FOREIGN KEY ( `id_auth` ) REFERENCES `articles_authors` (
`id`
) ON DELETE CASCADE ON UPDATE CASCADE');
$this->upgradeOK();
}
}