diff --git a/src/Command/SetPasswordCommand.php b/src/Command/SetPasswordCommand.php index a4398a97..b5ad8f52 100644 --- a/src/Command/SetPasswordCommand.php +++ b/src/Command/SetPasswordCommand.php @@ -2,7 +2,7 @@ namespace App\Command; -use App\Entity\User; +use App\Entity\UserSystem\User; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; diff --git a/src/Controller/TreeController.php b/src/Controller/TreeController.php index 32d5ecb2..8a7d05cc 100644 --- a/src/Controller/TreeController.php +++ b/src/Controller/TreeController.php @@ -29,8 +29,8 @@ namespace App\Controller; +use App\Entity\Devices\Device; use App\Entity\Parts\Category; -use App\Entity\Device; use App\Entity\Parts\Footprint; use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Storelocation; diff --git a/src/DataTables/PartsDataTable.php b/src/DataTables/PartsDataTable.php index e2ca6183..16c7a606 100644 --- a/src/DataTables/PartsDataTable.php +++ b/src/DataTables/PartsDataTable.php @@ -29,7 +29,7 @@ namespace App\DataTables; -use App\Entity\Part; +use App\Entity\Parts\Part; use App\Services\EntityURLGenerator; use Doctrine\ORM\QueryBuilder; use Omines\DataTablesBundle\Adapter\Doctrine\ORM\SearchCriteriaProvider; @@ -65,7 +65,7 @@ class PartsDataTable implements DataTableTypeInterface ->add('category', TextColumn::class, ['field' => 'category.name', 'label' => 'category.label']) ->add('instock', TextColumn::class, ['label' => 'instock.label_short']) ->add('mininstock', TextColumn::class, ['label' => 'mininstock.label_short']) - ->add('storelocation', TextColumn::class, ['field' => 'storelocation.name', 'label' => 'storelocation.label']) + //->add('storelocation', TextColumn::class, ['field' => 'storelocation.name', 'label' => 'storelocation.label']) ->addOrderBy('name') ->createAdapter(ORMAdapter::class, [ 'entity' => Part::class, diff --git a/src/Entity/Base/NamedDBElement.php b/src/Entity/Base/NamedDBElement.php index b3467a65..c433a9ac 100644 --- a/src/Entity/Base/NamedDBElement.php +++ b/src/Entity/Base/NamedDBElement.php @@ -64,6 +64,9 @@ use Symfony\Component\Serializer\Annotation\Groups; */ abstract class NamedDBElement extends DBElement { + + use TimestampTrait; + /** * @var string The name of this element. * @ORM\Column(type="string") @@ -72,20 +75,6 @@ abstract class NamedDBElement extends DBElement */ protected $name = ''; - /** - * @var \DateTime The date when this element was modified the last time. - * @ORM\Column(type="datetimetz", name="last_modified") - * @Groups({"extended", "full"}) - */ - protected $lastModified; - - /** - * @var \DateTime The date when this element was created. - * @ORM\Column(type="datetimetz", name="datetime_added") - * @Groups({"extended", "full"}) - */ - protected $addedDate; - /******************************************************************************** * * Getters @@ -105,28 +94,6 @@ abstract class NamedDBElement extends DBElement return $this->name; } - /** - * Returns the last time when the element was modified. - * Returns null if the element was not yet saved to DB yet. - * - * @return \DateTime|null The time of the last edit. - */ - public function getLastModified(): ?\DateTime - { - return $this->lastModified; - } - - /** - * Returns the date/time when the element was created. - * Returns null if the element was not yet saved to DB yet. - * - * @return \DateTime|null The creation time of the part. - */ - public function getAddedDate(): ?\DateTime - { - return $this->addedDate; - } - /******************************************************************************** * * Setters @@ -157,19 +124,7 @@ abstract class NamedDBElement extends DBElement * ******************************************************************************/ - /** - * Helper for updating the timestamp. It is automatically called by doctrine before persisting. - * - * @ORM\PrePersist - * @ORM\PreUpdate - */ - public function updatedTimestamps(): void - { - $this->lastModified = new \DateTime('now'); - if (null === $this->addedDate) { - $this->addedDate = new \DateTime('now'); - } - } + public function __toString() { diff --git a/src/Entity/Base/TimestampTrait.php b/src/Entity/Base/TimestampTrait.php new file mode 100644 index 00000000..e989a45b --- /dev/null +++ b/src/Entity/Base/TimestampTrait.php @@ -0,0 +1,92 @@ +lastModified; + } + + /** + * Returns the date/time when the element was created. + * Returns null if the element was not yet saved to DB yet. + * + * @return \DateTime|null The creation time of the part. + */ + public function getAddedDate(): ?\DateTime + { + return $this->addedDate; + } + + /** + * Helper for updating the timestamp. It is automatically called by doctrine before persisting. + * + * @ORM\PrePersist + * @ORM\PreUpdate + */ + public function updatedTimestamps(): void + { + $this->lastModified = new \DateTime('now'); + if (null === $this->addedDate) { + $this->addedDate = new \DateTime('now'); + } + } +} \ No newline at end of file diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php index 0fc81501..379808c3 100644 --- a/src/Entity/Parts/Part.php +++ b/src/Entity/Parts/Part.php @@ -101,15 +101,6 @@ class Part extends AttachmentContainingDBElement */ protected $footprint; - /** - * @var Storelocation|null - * @ORM\ManyToOne(targetEntity="Storelocation", inversedBy="parts") - * @ORM\JoinColumn(name="id_storelocation", referencedColumnName="id") - * - * @ColumnSecurity(prefix="storelocation", type="object") - */ - protected $storelocation; - /** * @var Manufacturer|null * @ORM\ManyToOne(targetEntity="Manufacturer", inversedBy="parts") diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php index f467a668..7c974c87 100644 --- a/src/Entity/Parts/PartLot.php +++ b/src/Entity/Parts/PartLot.php @@ -32,7 +32,9 @@ namespace App\Entity\Parts; +use App\Entity\Base\DBElement; use App\Entity\Base\NamedDBElement; +use App\Entity\Base\TimestampTrait; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -42,10 +44,13 @@ use Symfony\Component\Validator\Constraints as Assert; * @package App\Entity\Parts * @ORM\Entity() * @ORM\Table(name="part_lots") + * @ORM\HasLifecycleCallbacks() */ -class PartLot extends NamedDBElement +class PartLot extends DBElement { + use TimestampTrait; + /** * @var string A short description about this lot, shown in table * @ORM\Column(type="text") diff --git a/src/Form/BaseEntityAdminForm.php b/src/Form/BaseEntityAdminForm.php index 38645cf9..2a81a279 100644 --- a/src/Form/BaseEntityAdminForm.php +++ b/src/Form/BaseEntityAdminForm.php @@ -32,8 +32,8 @@ namespace App\Form; -use App\Entity\NamedDBElement; -use App\Entity\StructuralDBElement; +use App\Entity\Base\NamedDBElement; +use App\Entity\Base\StructuralDBElement; use FOS\CKEditorBundle\Form\Type\CKEditorType; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; diff --git a/src/Form/CategoryAdminForm.php b/src/Form/CategoryAdminForm.php index 6e2ecdbd..eaf658ab 100644 --- a/src/Form/CategoryAdminForm.php +++ b/src/Form/CategoryAdminForm.php @@ -32,7 +32,7 @@ namespace App\Form; -use App\Entity\NamedDBElement; +use App\Entity\Base\NamedDBElement; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/Form/CompanyForm.php b/src/Form/CompanyForm.php index c3867d19..27b9eca6 100644 --- a/src/Form/CompanyForm.php +++ b/src/Form/CompanyForm.php @@ -32,7 +32,7 @@ namespace App\Form; -use App\Entity\NamedDBElement; +use App\Entity\Base\NamedDBElement; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\TelType; diff --git a/src/Form/ImportType.php b/src/Form/ImportType.php index f3d06596..e4c61ca8 100644 --- a/src/Form/ImportType.php +++ b/src/Form/ImportType.php @@ -32,7 +32,7 @@ namespace App\Form; -use App\Entity\StructuralDBElement; +use App\Entity\Base\StructuralDBElement; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bundle\MakerBundle\Str; use Symfony\Component\Form\AbstractType; diff --git a/src/Form/PartType.php b/src/Form/PartType.php index c119eddf..597ed97c 100644 --- a/src/Form/PartType.php +++ b/src/Form/PartType.php @@ -29,10 +29,10 @@ namespace App\Form; -use App\Entity\Category; -use App\Entity\Manufacturer; -use App\Entity\Part; -use App\Entity\Storelocation; +use App\Entity\Parts\Category; +use App\Entity\Parts\Manufacturer; +use App\Entity\Parts\Part; +use App\Entity\Parts\Storelocation; use FOS\CKEditorBundle\Form\Type\CKEditorType; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; diff --git a/src/Form/StorelocationAdminForm.php b/src/Form/StorelocationAdminForm.php index 7608a800..ef9dab18 100644 --- a/src/Form/StorelocationAdminForm.php +++ b/src/Form/StorelocationAdminForm.php @@ -32,7 +32,7 @@ namespace App\Form; -use App\Entity\NamedDBElement; +use App\Entity\Base\NamedDBElement; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/Form/UserAdminForm.php b/src/Form/UserAdminForm.php index 9b8ab2a5..089dc54c 100644 --- a/src/Form/UserAdminForm.php +++ b/src/Form/UserAdminForm.php @@ -32,9 +32,9 @@ namespace App\Form; -use App\Entity\Group; -use App\Entity\NamedDBElement; -use App\Entity\StructuralDBElement; +use App\Entity\UserSystem\Group; +use App\Entity\Base\NamedDBElement; +use App\Entity\Base\StructuralDBElement; use FOS\CKEditorBundle\Form\Type\CKEditorType; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; diff --git a/src/Form/UserSettingsType.php b/src/Form/UserSettingsType.php index 63116e7a..2ceecbb5 100644 --- a/src/Form/UserSettingsType.php +++ b/src/Form/UserSettingsType.php @@ -2,7 +2,7 @@ namespace App\Form; -use App\Entity\User; +use App\Entity\UserSystem\User; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\EmailType; diff --git a/src/Migrations/Version20190812154222.php b/src/Migrations/Version20190812154222.php new file mode 100644 index 00000000..64a11126 --- /dev/null +++ b/src/Migrations/Version20190812154222.php @@ -0,0 +1,104 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE `measurement_units` (id INT AUTO_INCREMENT NOT NULL, unit VARCHAR(255) NOT NULL, is_integer TINYINT(1) NOT NULL, use_si_prefix TINYINT(1) NOT NULL, comment LONGTEXT NOT NULL, parent_id INT DEFAULT NULL, not_selectable TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, last_modified DATETIME NOT NULL, datetime_added DATETIME NOT NULL, UNIQUE INDEX UNIQ_F5AF83CFDCBB0C53 (unit), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + $this->addSql('CREATE TABLE part_lots (id INT AUTO_INCREMENT NOT NULL, id_store_location INT DEFAULT NULL, id_part INT DEFAULT NULL, description LONGTEXT NOT NULL, comment LONGTEXT NOT NULL, expiration_date DATETIME DEFAULT NULL, instock_unknown TINYINT(1) NOT NULL, instock INT DEFAULT NULL, amount DOUBLE PRECISION DEFAULT NULL, needs_refill TINYINT(1) NOT NULL, last_modified DATETIME NOT NULL, datetime_added DATETIME NOT NULL, INDEX IDX_EBC8F9435D8F4B37 (id_store_location), INDEX IDX_EBC8F943C22F6CC4 (id_part), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + $this->addSql('CREATE TABLE currencies (id INT AUTO_INCREMENT NOT NULL, iso_code VARCHAR(255) DEFAULT NULL, exchange_rate NUMERIC(11, 5) NOT NULL, comment LONGTEXT NOT NULL, parent_id INT DEFAULT NULL, not_selectable TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, last_modified DATETIME NOT NULL, datetime_added DATETIME NOT NULL, UNIQUE INDEX UNIQ_37C4469362B6A45E (iso_code), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB'); + $this->addSql('ALTER TABLE part_lots ADD CONSTRAINT FK_EBC8F9435D8F4B37 FOREIGN KEY (id_store_location) REFERENCES `storelocations` (id)'); + $this->addSql('ALTER TABLE part_lots ADD CONSTRAINT FK_EBC8F943C22F6CC4 FOREIGN KEY (id_part) REFERENCES `parts` (id)'); + + /** Migrate the part locations for parts with known instock */ + $this->addSql( + 'INSERT INTO part_lots (id_part, id_store_location, instock, instock_unknown, last_modified, datetime_added) ' . + 'SELECT parts.id, parts.id_storelocation, parts.instock, 0, NOW(), NOW() FROM parts ' . + 'WHERE parts.instock >= 0 AND parts.id_storelocation IS NOT NULL' + ); + + //Migrate part locations for parts with unknown instock + $this->addSql( + 'INSERT INTO part_lots (id_part, id_store_location, instock, instock_unknown, last_modified, datetime_added) ' . + 'SELECT parts.id, parts.id_storelocation, 0, 1, NOW(), NOW() FROM parts ' . + 'WHERE parts.instock = -2 AND parts.id_storelocation IS NOT NULL' + ); + + $this->addSql('ALTER TABLE attachements CHANGE element_id element_id INT DEFAULT NULL, CHANGE type_id type_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('ALTER TABLE attachement_types ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE categories ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE devices ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE footprints ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE filename filename MEDIUMTEXT NOT NULL, CHANGE filename_3d filename_3d MEDIUMTEXT NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE manufacturers ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE storelocations ADD storage_type_id INT DEFAULT NULL, ADD only_single_part TINYINT(1) NOT NULL, ADD limit_to_existing_parts TINYINT(1) NOT NULL, ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE storelocations ADD CONSTRAINT FK_7517020B270BFF1 FOREIGN KEY (storage_type_id) REFERENCES `measurement_units` (id)'); + $this->addSql('CREATE INDEX IDX_7517020B270BFF1 ON storelocations (storage_type_id)'); + $this->addSql('ALTER TABLE suppliers ADD default_currency_id INT DEFAULT NULL, ADD shipping_costs NUMERIC(10, 0) DEFAULT NULL, ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE suppliers ADD CONSTRAINT FK_AC28B95CECD792C0 FOREIGN KEY (default_currency_id) REFERENCES currencies (id)'); + $this->addSql('CREATE INDEX IDX_AC28B95CECD792C0 ON suppliers (default_currency_id)'); + $this->addSql('ALTER TABLE parts DROP FOREIGN KEY parts_id_storelocation_fk'); + $this->addSql('DROP INDEX IDX_6940A7FE8DF69834 ON parts'); + $this->addSql('ALTER TABLE parts ADD id_part_unit INT DEFAULT NULL, ADD minamount DOUBLE PRECISION NOT NULL, ADD manufacturer_product_number VARCHAR(255) NOT NULL, ADD needs_review TINYINT(1) NOT NULL, ADD tags LONGTEXT NOT NULL, ADD mass DOUBLE PRECISION DEFAULT NULL, DROP id_storelocation, DROP instock, CHANGE id_category id_category INT DEFAULT NULL, CHANGE id_footprint id_footprint INT DEFAULT NULL, CHANGE order_orderdetails_id order_orderdetails_id INT DEFAULT NULL, CHANGE id_manufacturer id_manufacturer INT DEFAULT NULL, CHANGE id_master_picture_attachement id_master_picture_attachement INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE parts ADD CONSTRAINT FK_6940A7FE2626CEF9 FOREIGN KEY (id_part_unit) REFERENCES `measurement_units` (id)'); + $this->addSql('CREATE INDEX IDX_6940A7FE2626CEF9 ON parts (id_part_unit)'); + $this->addSql('ALTER TABLE users CHANGE group_id group_id INT DEFAULT NULL, CHANGE password password VARCHAR(255) DEFAULT NULL, CHANGE first_name first_name VARCHAR(255) DEFAULT NULL, CHANGE last_name last_name VARCHAR(255) DEFAULT NULL, CHANGE department department VARCHAR(255) DEFAULT NULL, CHANGE email email VARCHAR(255) DEFAULT NULL, CHANGE config_language config_language VARCHAR(255) DEFAULT NULL, CHANGE config_timezone config_timezone VARCHAR(255) DEFAULT NULL, CHANGE config_theme config_theme VARCHAR(255) DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE device_parts CHANGE id_part id_part INT DEFAULT NULL, CHANGE id_device id_device INT DEFAULT NULL'); + $this->addSql('ALTER TABLE orderdetails CHANGE part_id part_id INT DEFAULT NULL, CHANGE id_supplier id_supplier INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('ALTER TABLE pricedetails ADD id_currency INT DEFAULT NULL, CHANGE orderdetails_id orderdetails_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE pricedetails ADD CONSTRAINT FK_C68C4459398D64AA FOREIGN KEY (id_currency) REFERENCES currencies (id)'); + $this->addSql('CREATE INDEX IDX_C68C4459398D64AA ON pricedetails (id_currency)'); + $this->addSql('ALTER TABLE groups ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE `storelocations` DROP FOREIGN KEY FK_7517020B270BFF1'); + $this->addSql('ALTER TABLE `parts` DROP FOREIGN KEY FK_6940A7FE2626CEF9'); + $this->addSql('ALTER TABLE `suppliers` DROP FOREIGN KEY FK_AC28B95CECD792C0'); + $this->addSql('ALTER TABLE `pricedetails` DROP FOREIGN KEY FK_C68C4459398D64AA'); + $this->addSql('DROP TABLE `measurement_units`'); + $this->addSql('DROP TABLE part_lots'); + $this->addSql('DROP TABLE currencies'); + $this->addSql('ALTER TABLE `attachement_types` DROP not_selectable, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('ALTER TABLE `attachements` CHANGE type_id type_id INT DEFAULT NULL, CHANGE element_id element_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('ALTER TABLE `categories` DROP not_selectable, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('ALTER TABLE `device_parts` CHANGE id_device id_device INT DEFAULT NULL, CHANGE id_part id_part INT DEFAULT NULL'); + $this->addSql('ALTER TABLE `devices` DROP not_selectable, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('ALTER TABLE `footprints` DROP not_selectable, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE filename filename MEDIUMTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE filename_3d filename_3d MEDIUMTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('ALTER TABLE `groups` DROP not_selectable, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('ALTER TABLE `manufacturers` DROP not_selectable, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('ALTER TABLE `orderdetails` CHANGE part_id part_id INT DEFAULT NULL, CHANGE id_supplier id_supplier INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('DROP INDEX IDX_6940A7FE2626CEF9 ON `parts`'); + $this->addSql('ALTER TABLE `parts` ADD id_storelocation INT DEFAULT NULL, ADD instock INT NOT NULL, DROP id_part_unit, DROP minamount, DROP manufacturer_product_number, DROP needs_review, DROP tags, DROP mass, CHANGE id_category id_category INT DEFAULT NULL, CHANGE id_footprint id_footprint INT DEFAULT NULL, CHANGE id_manufacturer id_manufacturer INT DEFAULT NULL, CHANGE id_master_picture_attachement id_master_picture_attachement INT DEFAULT NULL, CHANGE order_orderdetails_id order_orderdetails_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE `parts` ADD CONSTRAINT parts_id_storelocation_fk FOREIGN KEY (id_storelocation) REFERENCES storelocations (id)'); + $this->addSql('CREATE INDEX IDX_6940A7FE8DF69834 ON `parts` (id_storelocation)'); + $this->addSql('DROP INDEX IDX_C68C4459398D64AA ON `pricedetails`'); + $this->addSql('ALTER TABLE `pricedetails` DROP id_currency, CHANGE orderdetails_id orderdetails_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('DROP INDEX IDX_7517020B270BFF1 ON `storelocations`'); + $this->addSql('ALTER TABLE `storelocations` DROP storage_type_id, DROP only_single_part, DROP limit_to_existing_parts, DROP not_selectable, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('DROP INDEX IDX_AC28B95CECD792C0 ON `suppliers`'); + $this->addSql('ALTER TABLE `suppliers` DROP default_currency_id, DROP shipping_costs, DROP not_selectable, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + $this->addSql('ALTER TABLE `users` CHANGE group_id group_id INT DEFAULT NULL, CHANGE password password VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8_general_ci, CHANGE first_name first_name VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8_general_ci, CHANGE last_name last_name VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8_general_ci, CHANGE department department VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8_general_ci, CHANGE email email VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8_general_ci, CHANGE config_language config_language VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8_general_ci, CHANGE config_timezone config_timezone VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8_general_ci, CHANGE config_theme config_theme VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8_general_ci, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL'); + } +} diff --git a/src/Services/AttachmentHelper.php b/src/Services/AttachmentHelper.php index 42dfc05e..78c136d0 100644 --- a/src/Services/AttachmentHelper.php +++ b/src/Services/AttachmentHelper.php @@ -32,7 +32,7 @@ namespace App\Services; -use App\Entity\Attachment; +use App\Entity\Attachments\Attachment; use Doctrine\ORM\EntityManagerInterface; use SebastianBergmann\CodeCoverage\Node\File; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; diff --git a/src/Services/EntityExporter.php b/src/Services/EntityExporter.php index 13d30434..e18681e8 100644 --- a/src/Services/EntityExporter.php +++ b/src/Services/EntityExporter.php @@ -32,7 +32,7 @@ namespace App\Services; -use App\Entity\NamedDBElement; +use App\Entity\Base\NamedDBElement; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\ResponseHeaderBag; diff --git a/src/Services/EntityImporter.php b/src/Services/EntityImporter.php index 9fb1b103..a76e9955 100644 --- a/src/Services/EntityImporter.php +++ b/src/Services/EntityImporter.php @@ -32,7 +32,7 @@ namespace App\Services; -use App\Entity\StructuralDBElement; +use App\Entity\Base\StructuralDBElement; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\MakerBundle\Str; use Symfony\Component\HttpFoundation\File\File; diff --git a/src/Services/EntityURLGenerator.php b/src/Services/EntityURLGenerator.php index ae6f21db..110549d8 100644 --- a/src/Services/EntityURLGenerator.php +++ b/src/Services/EntityURLGenerator.php @@ -29,17 +29,17 @@ namespace App\Services; -use App\Entity\Attachment; -use App\Entity\AttachmentType; -use App\Entity\Category; -use App\Entity\Device; -use App\Entity\Footprint; -use App\Entity\Manufacturer; -use App\Entity\NamedDBElement; -use App\Entity\Part; -use App\Entity\Storelocation; -use App\Entity\Supplier; -use App\Entity\User; +use App\Entity\Attachments\Attachment; +use App\Entity\Attachments\AttachmentType; +use App\Entity\Parts\Category; +use App\Entity\Devices\Device; +use App\Entity\Parts\Footprint; +use App\Entity\Parts\Manufacturer; +use App\Entity\Base\NamedDBElement; +use App\Entity\Parts\Part; +use App\Entity\Parts\Storelocation; +use App\Entity\Parts\Supplier; +use App\Entity\UserSystem\User; use App\Exceptions\EntityNotSupported; use Symfony\Component\HttpKernel\HttpCache\Store; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; diff --git a/src/Services/PermissionResolver.php b/src/Services/PermissionResolver.php index a7cac28d..8f92cbe0 100644 --- a/src/Services/PermissionResolver.php +++ b/src/Services/PermissionResolver.php @@ -30,7 +30,7 @@ namespace App\Services; use App\Configuration\PermissionsConfiguration; -use App\Entity\User; +use App\Entity\UserSystem\User; use App\Security\Interfaces\HasPermissionsInterface; use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\Definition\Processor; diff --git a/src/Services/StructuralElementRecursionHelper.php b/src/Services/StructuralElementRecursionHelper.php index 33e64913..d5681bb9 100644 --- a/src/Services/StructuralElementRecursionHelper.php +++ b/src/Services/StructuralElementRecursionHelper.php @@ -32,7 +32,7 @@ namespace App\Services; -use App\Entity\StructuralDBElement; +use App\Entity\Base\StructuralDBElement; use Doctrine\ORM\EntityManagerInterface; class StructuralElementRecursionHelper diff --git a/src/Services/TreeBuilder.php b/src/Services/TreeBuilder.php index 3d7b2987..fb3d51aa 100644 --- a/src/Services/TreeBuilder.php +++ b/src/Services/TreeBuilder.php @@ -31,9 +31,9 @@ namespace App\Services; -use App\Entity\DBElement; -use App\Entity\NamedDBElement; -use App\Entity\StructuralDBElement; +use App\Entity\Base\DBElement; +use App\Entity\Base\NamedDBElement; +use App\Entity\Base\StructuralDBElement; use App\Helpers\TreeViewNode; use App\Repository\StructuralDBElementRepository; use Doctrine\ORM\EntityManagerInterface; diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index 469e966d..549823eb 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -29,8 +29,8 @@ namespace App\Twig; -use App\Entity\Attachment; -use App\Entity\DBElement; +use App\Entity\Attachments\Attachment; +use App\Entity\Base\DBElement; use App\Services\EntityURLGenerator; use App\Services\MoneyFormatter; use App\Services\TreeBuilder; diff --git a/src/Validator/Constraints/NoneOfItsChildrenValidator.php b/src/Validator/Constraints/NoneOfItsChildrenValidator.php index d521cad7..5340772c 100644 --- a/src/Validator/Constraints/NoneOfItsChildrenValidator.php +++ b/src/Validator/Constraints/NoneOfItsChildrenValidator.php @@ -32,7 +32,7 @@ namespace App\Validator\Constraints; -use App\Entity\StructuralDBElement; +use App\Entity\Base\StructuralDBElement; use Symfony\Bundle\MakerBundle\Str; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Constraint;