diff --git a/src/Entity/Attachments/Attachment.php b/src/Entity/Attachments/Attachment.php index 0310f7db..52b079ba 100644 --- a/src/Entity/Attachments/Attachment.php +++ b/src/Entity/Attachments/Attachment.php @@ -34,7 +34,15 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Table(name="`attachments`") * @ORM\InheritanceType("SINGLE_TABLE") * @ORM\DiscriminatorColumn(name="class_name", type="string") - * @ORM\DiscriminatorMap({"PartDB\Part" = "PartAttachment", "Part" = "PartAttachment"}) + * @ORM\DiscriminatorMap({ + * "PartDB\Part" = "PartAttachment", "Part" = "PartAttachment", + * "PartDB\Device" = "DeviceAttachment", "Device" = "DeviceAttachment", + * "AttachmentType" = "AttachmentTypeAttachment", "Category" = "CategoryAttachment", + * "Footprint" = "FootprintAttachment", "Manufacturer" = "ManufacturerAttachment", + * "Currency" = "CurrencyAttachment", "Group" = "GroupAttachment", + * "MeasurementUnit" = "MeasurementUnitAttachment", "Storelocation" = "StorelocationAttachment", + * "Supplier" = "SupplierAttachment", "User" = "UserAttachment" + * }) * @ORM\EntityListeners({"App\EntityListeners\AttachmentDeleteListener"}) * */ @@ -56,11 +64,17 @@ abstract class Attachment extends NamedDBElement protected $show_in_table = false; /** - * @var string The filename using the %BASE% variable - * @ORM\Column(type="string", name="filename") + * @var string The path to the file relative to a placeholder path like %MEDIA% + * @ORM\Column(type="string", name="path") */ protected $path = ''; + /** + * @var string The original filenamethe file had, when the user uploaded it. + * @ORM\Column(type="string", nullable=true) + */ + protected $original_filename; + /** * ORM mapping is done in sub classes (like PartAttachment) */ @@ -68,7 +82,7 @@ abstract class Attachment extends NamedDBElement /** * @var AttachmentType - * @ORM\ManyToOne(targetEntity="AttachmentType", inversedBy="attachments") + * @ORM\ManyToOne(targetEntity="AttachmentType", inversedBy="attachments_with_type") * @ORM\JoinColumn(name="type_id", referencedColumnName="id") * @Selectable() */ diff --git a/src/Entity/Attachments/AttachmentContainingDBElement.php b/src/Entity/Attachments/AttachmentContainingDBElement.php index 1f696746..806f7323 100644 --- a/src/Entity/Attachments/AttachmentContainingDBElement.php +++ b/src/Entity/Attachments/AttachmentContainingDBElement.php @@ -52,16 +52,20 @@ declare(strict_types=1); namespace App\Entity\Attachments; +use App\Entity\Base\MasterAttachmentTrait; use App\Entity\Base\NamedDBElement; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\MappedSuperclass() */ abstract class AttachmentContainingDBElement extends NamedDBElement { + use MasterAttachmentTrait; + /** * @var Attachment[] * //TODO diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index 4c4991f9..f366899a 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -66,11 +66,17 @@ use Doctrine\ORM\Mapping as ORM; class AttachmentType extends StructuralDBElement { /** - * @var ArrayCollection - * @ORM\OneToMany(targetEntity="Attachment", mappedBy="attachment_type") + * @var Collection|AttachmentTypeAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\AttachmentTypeAttachment", mappedBy="element") */ protected $attachments; + /** + * @var Collection|Attachment[] + * @ORM\OneToMany(targetEntity="Attachment", mappedBy="attachment_type") + */ + protected $attachments_with_type; + /** * @ORM\OneToMany(targetEntity="AttachmentType", mappedBy="parent", cascade={"persist"}) */ diff --git a/src/Entity/Attachments/AttachmentTypeAttachment.php b/src/Entity/Attachments/AttachmentTypeAttachment.php new file mode 100644 index 00000000..79877e1e --- /dev/null +++ b/src/Entity/Attachments/AttachmentTypeAttachment.php @@ -0,0 +1,61 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Attachments/CategoryAttachment.php b/src/Entity/Attachments/CategoryAttachment.php new file mode 100644 index 00000000..2b2a70eb --- /dev/null +++ b/src/Entity/Attachments/CategoryAttachment.php @@ -0,0 +1,63 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Attachments/CurrencyAttachment.php b/src/Entity/Attachments/CurrencyAttachment.php new file mode 100644 index 00000000..e8bba1e7 --- /dev/null +++ b/src/Entity/Attachments/CurrencyAttachment.php @@ -0,0 +1,67 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Attachments/DeviceAttachment.php b/src/Entity/Attachments/DeviceAttachment.php new file mode 100644 index 00000000..76e1dfd2 --- /dev/null +++ b/src/Entity/Attachments/DeviceAttachment.php @@ -0,0 +1,62 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Attachments/FootprintAttachment.php b/src/Entity/Attachments/FootprintAttachment.php new file mode 100644 index 00000000..99c2f614 --- /dev/null +++ b/src/Entity/Attachments/FootprintAttachment.php @@ -0,0 +1,63 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Attachments/GroupAttachment.php b/src/Entity/Attachments/GroupAttachment.php new file mode 100644 index 00000000..83064a7a --- /dev/null +++ b/src/Entity/Attachments/GroupAttachment.php @@ -0,0 +1,69 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Attachments/ManufacturerAttachment.php b/src/Entity/Attachments/ManufacturerAttachment.php new file mode 100644 index 00000000..5eb1517e --- /dev/null +++ b/src/Entity/Attachments/ManufacturerAttachment.php @@ -0,0 +1,63 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Attachments/MeasurementUnitAttachment.php b/src/Entity/Attachments/MeasurementUnitAttachment.php new file mode 100644 index 00000000..d8aa0cbd --- /dev/null +++ b/src/Entity/Attachments/MeasurementUnitAttachment.php @@ -0,0 +1,64 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Attachments/PartAttachment.php b/src/Entity/Attachments/PartAttachment.php index 4601372e..ee147495 100644 --- a/src/Entity/Attachments/PartAttachment.php +++ b/src/Entity/Attachments/PartAttachment.php @@ -35,7 +35,7 @@ use App\Entity\Parts\Part; use Doctrine\ORM\Mapping as ORM; /** - * Class PartAttachment + * A attachment attached to a part element. * @package App\Entity * @ORM\Entity() */ @@ -43,7 +43,7 @@ class PartAttachment extends Attachment { /** - * + * @var Part The element this attachment is associated with. * @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="attachments") * @ORM\JoinColumn(name="element_id", referencedColumnName="id", nullable=false, onDelete="CASCADE"). */ @@ -56,7 +56,6 @@ class PartAttachment extends Attachment } $this->element = $element; - return $this; } } \ No newline at end of file diff --git a/src/Entity/Attachments/StorelocationAttachment.php b/src/Entity/Attachments/StorelocationAttachment.php new file mode 100644 index 00000000..0edd9749 --- /dev/null +++ b/src/Entity/Attachments/StorelocationAttachment.php @@ -0,0 +1,65 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Attachments/SupplierAttachment.php b/src/Entity/Attachments/SupplierAttachment.php new file mode 100644 index 00000000..78199bda --- /dev/null +++ b/src/Entity/Attachments/SupplierAttachment.php @@ -0,0 +1,66 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Attachments/UserAttachment.php b/src/Entity/Attachments/UserAttachment.php new file mode 100644 index 00000000..5874aca1 --- /dev/null +++ b/src/Entity/Attachments/UserAttachment.php @@ -0,0 +1,68 @@ +element = $element; + return $this; + } +} \ No newline at end of file diff --git a/src/Entity/Parts/PartTraits/MasterAttachmentTrait.php b/src/Entity/Base/MasterAttachmentTrait.php similarity index 93% rename from src/Entity/Parts/PartTraits/MasterAttachmentTrait.php rename to src/Entity/Base/MasterAttachmentTrait.php index 4b76f9cc..2637e187 100644 --- a/src/Entity/Parts/PartTraits/MasterAttachmentTrait.php +++ b/src/Entity/Base/MasterAttachmentTrait.php @@ -29,12 +29,13 @@ * */ -namespace App\Entity\Parts\PartTraits; +namespace App\Entity\Base; use App\Entity\Attachments\Attachment; use App\Entity\Parts\Part; use App\Security\Annotations\ColumnSecurity; +use Symfony\Component\Validator\Constraints as Assert; /** * A entity with this class has a master attachment, which is used as a preview image for this object. @@ -45,7 +46,7 @@ trait MasterAttachmentTrait /** * @var Attachment * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\Attachment") - * @ORM\JoinColumn(name="id_master_picture_attachement", referencedColumnName="id") + * @ORM\JoinColumn(name="id_preview_attachement", referencedColumnName="id") * @Assert\Expression("value == null or value.isPicture()", message="part.master_attachment.must_be_picture") * @ColumnSecurity(prefix="attachments", type="object") */ diff --git a/src/Entity/Devices/Device.php b/src/Entity/Devices/Device.php index 665ce3c8..9670c059 100644 --- a/src/Entity/Devices/Device.php +++ b/src/Entity/Devices/Device.php @@ -61,7 +61,10 @@ declare(strict_types=1); namespace App\Entity\Devices; +use App\Entity\Attachments\AttachmentTypeAttachment; +use App\Entity\Attachments\DeviceAttachment; use App\Entity\Base\PartsContainingDBElement; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** @@ -72,6 +75,13 @@ use Doctrine\ORM\Mapping as ORM; */ class Device extends PartsContainingDBElement { + + /** + * @var Collection|DeviceAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\DeviceAttachment", mappedBy="element") + */ + protected $attachments; + /** * @ORM\OneToMany(targetEntity="Device", mappedBy="parent") */ diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index 79f218eb..07ddc0ba 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -52,7 +52,9 @@ declare(strict_types=1); namespace App\Entity\Parts; +use App\Entity\Attachments\CategoryAttachment; use App\Entity\Base\PartsContainingDBElement; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** @@ -63,6 +65,13 @@ use Doctrine\ORM\Mapping as ORM; */ class Category extends PartsContainingDBElement { + + /** + * @var Collection|CategoryAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element") + */ + protected $attachments; + /** * @ORM\OneToMany(targetEntity="Category", mappedBy="parent") */ diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index 10b98410..4c05cb72 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -61,7 +61,10 @@ declare(strict_types=1); namespace App\Entity\Parts; +use App\Entity\Attachments\Attachment; +use App\Entity\Attachments\FootprintAttachment; use App\Entity\Base\PartsContainingDBElement; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** @@ -72,6 +75,12 @@ use Doctrine\ORM\Mapping as ORM; */ class Footprint extends PartsContainingDBElement { + /** + * @var Collection|FootprintAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\FootprintAttachment", mappedBy="element") + */ + protected $attachments; + /** * @ORM\OneToMany(targetEntity="Footprint", mappedBy="parent") */ @@ -83,22 +92,17 @@ class Footprint extends PartsContainingDBElement */ protected $parent; - /** - * @var string - * @ORM\Column(type="text") - */ - protected $filename; - /** * @ORM\OneToMany(targetEntity="Part", mappedBy="footprint", fetch="EXTRA_LAZY") */ protected $parts; /** - * @var string - * @ORM\Column(type="text") + * @var FootprintAttachment + * @ORM\ManyToOne(targetEntity="App\Entity\Attachments\FootprintAttachment") + * @ORM\JoinColumn(name="id_footprint_3d", referencedColumnName="id") */ - protected $filename_3d; + protected $footprint_3d; /** * Returns the ID as an string, defined by the element class. diff --git a/src/Entity/Parts/Manufacturer.php b/src/Entity/Parts/Manufacturer.php index 01d7535f..ed1619fe 100644 --- a/src/Entity/Parts/Manufacturer.php +++ b/src/Entity/Parts/Manufacturer.php @@ -61,7 +61,10 @@ declare(strict_types=1); namespace App\Entity\Parts; +use App\Entity\Attachments\FootprintAttachment; +use App\Entity\Attachments\ManufacturerAttachment; use App\Entity\Base\Company; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** @@ -72,6 +75,13 @@ use Doctrine\ORM\Mapping as ORM; */ class Manufacturer extends Company { + /** + * @var Collection|ManufacturerAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element") + */ + protected $attachments; + + /** * @ORM\OneToMany(targetEntity="Manufacturer", mappedBy="parent") */ diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index 810814f7..f4595764 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -32,7 +32,10 @@ namespace App\Entity\Parts; +use App\Entity\Attachments\ManufacturerAttachment; +use App\Entity\Attachments\MeasurementUnitAttachment; use App\Entity\Base\PartsContainingDBElement; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Validator\Constraints as Assert; @@ -49,6 +52,12 @@ use Symfony\Component\Validator\Constraints as Assert; class MeasurementUnit extends PartsContainingDBElement { + /** + * @var Collection|MeasurementUnitAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\MeasurementUnitAttachment", mappedBy="element") + */ + protected $attachments; + /** * @var string The unit symbol that should be used for the Unit. This could be something like "", g (for gramms) * or m (for meters). diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php index 53a862af..34d370e5 100644 --- a/src/Entity/Parts/Part.php +++ b/src/Entity/Parts/Part.php @@ -64,7 +64,7 @@ namespace App\Entity\Parts; use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Devices\Device; use App\Entity\Parts\PartTraits\AdvancedPropertyTrait; -use App\Entity\Parts\PartTraits\MasterAttachmentTrait; +use App\Entity\Base\MasterAttachmentTrait; use App\Entity\Parts\PartTraits\BasicPropertyTrait; use App\Entity\Parts\PartTraits\InstockTrait; use App\Entity\Parts\PartTraits\ManufacturerTrait; @@ -87,7 +87,7 @@ use Symfony\Component\Validator\Constraints as Assert; class Part extends AttachmentContainingDBElement { use AdvancedPropertyTrait; - use MasterAttachmentTrait; + //use MasterAttachmentTrait; use BasicPropertyTrait; use InstockTrait; use ManufacturerTrait; diff --git a/src/Entity/Parts/Storelocation.php b/src/Entity/Parts/Storelocation.php index 9c67ea36..5f937a83 100644 --- a/src/Entity/Parts/Storelocation.php +++ b/src/Entity/Parts/Storelocation.php @@ -61,7 +61,10 @@ declare(strict_types=1); namespace App\Entity\Parts; +use App\Entity\Attachments\ManufacturerAttachment; +use App\Entity\Attachments\StorelocationAttachment; use App\Entity\Base\PartsContainingDBElement; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** @@ -72,6 +75,13 @@ use Doctrine\ORM\Mapping as ORM; */ class Storelocation extends PartsContainingDBElement { + + /** + * @var Collection|StorelocationAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element") + */ + protected $attachments; + /** * @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent") */ diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index 4c57b0bd..ee3b03e0 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -61,9 +61,12 @@ declare(strict_types=1); namespace App\Entity\Parts; +use App\Entity\Attachments\ManufacturerAttachment; +use App\Entity\Attachments\SupplierAttachment; use App\Entity\Base\Company; use App\Entity\PriceInformations\Currency; use App\Validator\Constraints\Selectable; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -75,6 +78,12 @@ use Symfony\Component\Validator\Constraints as Assert; */ class Supplier extends Company { + /** + * @var Collection|SupplierAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element") + */ + protected $attachments; + /** * @ORM\OneToMany(targetEntity="Supplier", mappedBy="parent") */ diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index 695c8612..ac9f63b9 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -32,7 +32,10 @@ namespace App\Entity\PriceInformations; +use App\Entity\Attachments\CurrencyAttachment; +use App\Entity\Attachments\SupplierAttachment; use App\Entity\Base\StructuralDBElement; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Validator\Constraints as Assert; @@ -49,6 +52,12 @@ class Currency extends StructuralDBElement public const PRICE_SCALE = 5; + /** + * @var Collection|CurrencyAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\CurrencyAttachment", mappedBy="element") + */ + protected $attachments; + /** * @var string The 3 letter ISO code of the currency. * @ORM\Column(type="string") diff --git a/src/Entity/UserSystem/Group.php b/src/Entity/UserSystem/Group.php index 2d5eb8f2..e321480a 100644 --- a/src/Entity/UserSystem/Group.php +++ b/src/Entity/UserSystem/Group.php @@ -31,9 +31,12 @@ namespace App\Entity\UserSystem; +use App\Entity\Attachments\GroupAttachment; +use App\Entity\Attachments\SupplierAttachment; use App\Entity\Base\StructuralDBElement; use App\Security\Interfaces\HasPermissionsInterface; use App\Validator\Constraints\ValidPermission; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** @@ -44,6 +47,13 @@ use Doctrine\ORM\Mapping as ORM; */ class Group extends StructuralDBElement implements HasPermissionsInterface { + + /** + * @var Collection|GroupAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\ManufacturerAttachment", mappedBy="element") + */ + protected $attachments; + /** * @ORM\OneToMany(targetEntity="Group", mappedBy="parent") */ diff --git a/src/Entity/UserSystem/User.php b/src/Entity/UserSystem/User.php index 3e8c615a..b695c579 100644 --- a/src/Entity/UserSystem/User.php +++ b/src/Entity/UserSystem/User.php @@ -61,11 +61,15 @@ declare(strict_types=1); namespace App\Entity\UserSystem; +use App\Entity\Attachments\AttachmentContainingDBElement; +use App\Entity\Attachments\SupplierAttachment; +use App\Entity\Attachments\UserAttachment; use App\Entity\Base\NamedDBElement; use App\Entity\PriceInformations\Currency; use App\Security\Interfaces\HasPermissionsInterface; use App\Validator\Constraints\Selectable; use App\Validator\Constraints\ValidPermission; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\UserInterface; @@ -79,11 +83,17 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Table("`users`") * @UniqueEntity("name", message="validator.user.username_already_used") */ -class User extends NamedDBElement implements UserInterface, HasPermissionsInterface +class User extends AttachmentContainingDBElement implements UserInterface, HasPermissionsInterface { /** The User id of the anonymous user */ public const ID_ANONYMOUS = 1; + /** + * @var Collection|UserAttachment[] + * @ORM\OneToMany(targetEntity="App\Entity\Attachments\UserAttachment", mappedBy="element") + */ + protected $attachments; + /** * @ORM\Id() * @ORM\GeneratedValue() @@ -190,11 +200,6 @@ class User extends NamedDBElement implements UserInterface, HasPermissionsInterf */ protected $permissions; - /** - * @ORM\Column(type="text", name="config_image_path") - */ - protected $image_path = ''; - /** * @ORM\Column(type="text", name="config_instock_comment_w") */ @@ -205,8 +210,28 @@ class User extends NamedDBElement implements UserInterface, HasPermissionsInterf */ protected $instock_comment_a = ''; + /** + * @var string|null The hash of a token the user must provide when he wants to reset his password. + * @ORM\Column(type="string", nullable=true) + */ + protected $pw_reset_token = null; + + /** + * @var \DateTime The time until the password reset token is valid. + * @ORM\Column(type="datetime", nullable=true) + */ + protected $pw_reset_expires = null; + + /** + * @var bool Determines if the user is disabled (user can not log in) + * @ORM\Column(type="boolean") + */ + protected $disabled = false; + + public function __construct() { + parent::__construct(); $this->permissions = new PermissionsEmbed(); } diff --git a/src/Migrations/Version20190924113252.php b/src/Migrations/Version20190924113252.php new file mode 100644 index 00000000..2ac537eb --- /dev/null +++ b/src/Migrations/Version20190924113252.php @@ -0,0 +1,117 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE users ADD id_preview_attachement INT DEFAULT NULL, ADD pw_reset_token VARCHAR(255) DEFAULT NULL, ADD pw_reset_expires DATETIME DEFAULT NULL, ADD disabled TINYINT(1) NOT NULL, DROP config_image_path'); + $this->addSql('ALTER TABLE users ADD CONSTRAINT FK_1483A5E96DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_1483A5E96DEDCEC2 ON users (id_preview_attachement)'); + $this->addSql('ALTER TABLE attachment_types ADD id_preview_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE attachment_types ADD CONSTRAINT FK_EFAED7196DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_EFAED7196DEDCEC2 ON attachment_types (id_preview_attachement)'); + $this->addSql('ALTER TABLE categories ADD id_preview_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE categories ADD CONSTRAINT FK_3AF346686DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_3AF346686DEDCEC2 ON categories (id_preview_attachement)'); + $this->addSql('ALTER TABLE currencies ADD id_preview_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE currencies ADD CONSTRAINT FK_37C446936DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_37C446936DEDCEC2 ON currencies (id_preview_attachement)'); + $this->addSql('ALTER TABLE devices ADD id_preview_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE devices ADD CONSTRAINT FK_11074E9A6DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_11074E9A6DEDCEC2 ON devices (id_preview_attachement)'); + $this->addSql('ALTER TABLE footprints ADD id_footprint_3d INT DEFAULT NULL, ADD id_preview_attachement INT DEFAULT NULL, DROP filename, DROP filename_3d'); + $this->addSql('ALTER TABLE footprints ADD CONSTRAINT FK_A34D68A232A38C34 FOREIGN KEY (id_footprint_3d) REFERENCES `attachments` (id)'); + $this->addSql('ALTER TABLE footprints ADD CONSTRAINT FK_A34D68A26DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_A34D68A232A38C34 ON footprints (id_footprint_3d)'); + $this->addSql('CREATE INDEX IDX_A34D68A26DEDCEC2 ON footprints (id_preview_attachement)'); + $this->addSql('ALTER TABLE manufacturers ADD id_preview_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE manufacturers ADD CONSTRAINT FK_94565B126DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_94565B126DEDCEC2 ON manufacturers (id_preview_attachement)'); + $this->addSql('ALTER TABLE measurement_units ADD id_preview_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE measurement_units ADD CONSTRAINT FK_F5AF83CF6DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_F5AF83CF6DEDCEC2 ON measurement_units (id_preview_attachement)'); + $this->addSql('ALTER TABLE storelocations ADD id_preview_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE storelocations ADD CONSTRAINT FK_75170206DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_75170206DEDCEC2 ON storelocations (id_preview_attachement)'); + $this->addSql('ALTER TABLE suppliers ADD id_preview_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE suppliers ADD CONSTRAINT FK_AC28B95C6DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_AC28B95C6DEDCEC2 ON suppliers (id_preview_attachement)'); + $this->addSql('ALTER TABLE attachments DROP FOREIGN KEY FK_47C4FAD61F1F2A24'); + $this->addSql('ALTER TABLE attachments ADD original_filename VARCHAR(255) DEFAULT NULL, CHANGE filename path VARCHAR(255) NOT NULL'); + $this->addSql('ALTER TABLE `groups` ADD id_preview_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE `groups` ADD CONSTRAINT FK_F06D39706DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_F06D39706DEDCEC2 ON `groups` (id_preview_attachement)'); + $this->addSql('ALTER TABLE parts DROP FOREIGN KEY FK_6940A7FEEBBCC786'); + $this->addSql('DROP INDEX IDX_6940A7FEEBBCC786 ON parts'); + $this->addSql('ALTER TABLE parts CHANGE id_master_picture_attachement id_preview_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE parts ADD CONSTRAINT FK_6940A7FE6DEDCEC2 FOREIGN KEY (id_preview_attachement) REFERENCES `attachments` (id)'); + $this->addSql('CREATE INDEX IDX_6940A7FE6DEDCEC2 ON parts (id_preview_attachement)'); + } + + 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 `attachment_types` DROP FOREIGN KEY FK_EFAED7196DEDCEC2'); + $this->addSql('DROP INDEX IDX_EFAED7196DEDCEC2 ON `attachment_types`'); + $this->addSql('ALTER TABLE `attachment_types` DROP id_preview_attachement'); + $this->addSql('ALTER TABLE `attachments` DROP original_filename, CHANGE path filename VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci'); + $this->addSql('ALTER TABLE `attachments` ADD CONSTRAINT FK_47C4FAD61F1F2A24 FOREIGN KEY (element_id) REFERENCES parts (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE `categories` DROP FOREIGN KEY FK_3AF346686DEDCEC2'); + $this->addSql('DROP INDEX IDX_3AF346686DEDCEC2 ON `categories`'); + $this->addSql('ALTER TABLE `categories` DROP id_preview_attachement'); + $this->addSql('ALTER TABLE currencies DROP FOREIGN KEY FK_37C446936DEDCEC2'); + $this->addSql('DROP INDEX IDX_37C446936DEDCEC2 ON currencies'); + $this->addSql('ALTER TABLE currencies DROP id_preview_attachement'); + $this->addSql('ALTER TABLE `devices` DROP FOREIGN KEY FK_11074E9A6DEDCEC2'); + $this->addSql('DROP INDEX IDX_11074E9A6DEDCEC2 ON `devices`'); + $this->addSql('ALTER TABLE `devices` DROP id_preview_attachement'); + $this->addSql('ALTER TABLE `footprints` DROP FOREIGN KEY FK_A34D68A232A38C34'); + $this->addSql('ALTER TABLE `footprints` DROP FOREIGN KEY FK_A34D68A26DEDCEC2'); + $this->addSql('DROP INDEX IDX_A34D68A232A38C34 ON `footprints`'); + $this->addSql('DROP INDEX IDX_A34D68A26DEDCEC2 ON `footprints`'); + $this->addSql('ALTER TABLE `footprints` ADD filename MEDIUMTEXT NOT NULL COLLATE utf8_unicode_ci, ADD filename_3d MEDIUMTEXT NOT NULL COLLATE utf8_unicode_ci, DROP id_footprint_3d, DROP id_preview_attachement'); + $this->addSql('ALTER TABLE `groups` DROP FOREIGN KEY FK_F06D39706DEDCEC2'); + $this->addSql('DROP INDEX IDX_F06D39706DEDCEC2 ON `groups`'); + $this->addSql('ALTER TABLE `groups` DROP id_preview_attachement'); + $this->addSql('ALTER TABLE `manufacturers` DROP FOREIGN KEY FK_94565B126DEDCEC2'); + $this->addSql('DROP INDEX IDX_94565B126DEDCEC2 ON `manufacturers`'); + $this->addSql('ALTER TABLE `manufacturers` DROP id_preview_attachement'); + $this->addSql('ALTER TABLE `measurement_units` DROP FOREIGN KEY FK_F5AF83CF6DEDCEC2'); + $this->addSql('DROP INDEX IDX_F5AF83CF6DEDCEC2 ON `measurement_units`'); + $this->addSql('ALTER TABLE `measurement_units` DROP id_preview_attachement'); + $this->addSql('ALTER TABLE `parts` DROP FOREIGN KEY FK_6940A7FE6DEDCEC2'); + $this->addSql('DROP INDEX IDX_6940A7FE6DEDCEC2 ON `parts`'); + $this->addSql('ALTER TABLE `parts` CHANGE id_preview_attachement id_master_picture_attachement INT DEFAULT NULL'); + $this->addSql('ALTER TABLE `parts` ADD CONSTRAINT FK_6940A7FEEBBCC786 FOREIGN KEY (id_master_picture_attachement) REFERENCES attachments (id)'); + $this->addSql('CREATE INDEX IDX_6940A7FEEBBCC786 ON `parts` (id_master_picture_attachement)'); + $this->addSql('ALTER TABLE `storelocations` DROP FOREIGN KEY FK_75170206DEDCEC2'); + $this->addSql('DROP INDEX IDX_75170206DEDCEC2 ON `storelocations`'); + $this->addSql('ALTER TABLE `storelocations` DROP id_preview_attachement'); + $this->addSql('ALTER TABLE `suppliers` DROP FOREIGN KEY FK_AC28B95C6DEDCEC2'); + $this->addSql('DROP INDEX IDX_AC28B95C6DEDCEC2 ON `suppliers`'); + $this->addSql('ALTER TABLE `suppliers` DROP id_preview_attachement'); + $this->addSql('ALTER TABLE `users` DROP FOREIGN KEY FK_1483A5E96DEDCEC2'); + $this->addSql('DROP INDEX IDX_1483A5E96DEDCEC2 ON `users`'); + $this->addSql('ALTER TABLE `users` ADD config_image_path TEXT NOT NULL COLLATE utf8_general_ci, DROP id_preview_attachement, DROP pw_reset_token, DROP pw_reset_expires, DROP disabled'); + } +}