120 lines
4.1 KiB
PHP
120 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace KupShop\ReclamationsSuppliersBundle\Resources\upgrade;
|
|
|
|
class ReclamationsSuppliersUpgrade extends \UpgradeNew
|
|
{
|
|
public function check_ReclamationsSuppliers()
|
|
{
|
|
return $this->checkTableExists('reclamations_suppliers');
|
|
}
|
|
|
|
/** Create table 'reclamations_suppliers' */
|
|
public function upgrade_ReclamationsSuppliers()
|
|
{
|
|
sqlQuery('create table reclamations_suppliers
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
code varchar(20) null,
|
|
id_supplier int null,
|
|
date_created datetime default current_timestamp() null,
|
|
date_handle datetime null,
|
|
status int not null,
|
|
history longtext null,
|
|
date_accepted datetime null,
|
|
id_delivery int null,
|
|
id_balikonos int null,
|
|
constraint code
|
|
unique (code),
|
|
constraint reclamations_suppliers_balikonos_id_fk
|
|
foreign key (id_balikonos) references balikonos (id)
|
|
on update cascade on delete set null,
|
|
constraint reclamations_suppliers_delivery_type_delivery_id_fk
|
|
foreign key (id_delivery) references delivery_type_delivery (id)
|
|
on update cascade on delete set null
|
|
);
|
|
|
|
');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_ReclamationsSuppliersItems()
|
|
{
|
|
return $this->checkTableExists('reclamations_suppliers_items');
|
|
}
|
|
|
|
/** Create table 'reclamations_suppliers_items' */
|
|
public function upgrade_ReclamationsSuppliersItems()
|
|
{
|
|
sqlQuery('
|
|
create table reclamations_suppliers_items
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
id_reclamation_supplier int not null,
|
|
id_reclamation int null,
|
|
id_product int not null,
|
|
id_variation int null,
|
|
pieces int not null,
|
|
constraint reclamations_suppliers_items_reclamations_id_fk
|
|
foreign key (id_reclamation) references reclamations (id)
|
|
on update cascade on delete set null,
|
|
constraint reclamations_suppliers_items_reclamations_suppliers_id_fk
|
|
foreign key (id_reclamation_supplier) references reclamations_suppliers (id)
|
|
on update cascade on delete cascade
|
|
);
|
|
');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_ReclamationsSuppliersSuppliersForeignKey()
|
|
{
|
|
return $this->checkForeignKeyExists('reclamations_suppliers', 'id_supplier');
|
|
}
|
|
|
|
public function upgrade_ReclamationsSuppliersSuppliersForeignKey()
|
|
{
|
|
sqlQuery('
|
|
alter table reclamations_suppliers add
|
|
constraint reclamations_suppliers_suppliers_id_fk
|
|
foreign key (id_supplier) references suppliers (id)
|
|
on update cascade on delete cascade
|
|
');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_ReclamationsSuppliersItemsCustomData()
|
|
{
|
|
return $this->checkColumnExists('reclamations_suppliers_items', 'data');
|
|
}
|
|
|
|
public function upgrade_ReclamationsSuppliersItemsCustomData()
|
|
{
|
|
sqlQuery('
|
|
alter table reclamations_suppliers_items
|
|
add data longtext null;
|
|
');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
|
|
public function check_ReclamationsSuppliersCustomData()
|
|
{
|
|
return $this->checkColumnExists('reclamations_suppliers', 'data');
|
|
}
|
|
|
|
public function upgrade_ReclamationsSuppliersCustomData()
|
|
{
|
|
sqlQuery('
|
|
alter table reclamations_suppliers
|
|
add data longtext null;
|
|
');
|
|
|
|
$this->upgradeOK();
|
|
}
|
|
}
|