Added migration from old Database to new database.

This commit is contained in:
Jan Böhmer 2019-08-06 13:18:29 +02:00
parent 42c8222e35
commit 2f39ac90a2
19 changed files with 391 additions and 31 deletions

View file

@ -30,9 +30,13 @@ use Symfony\Component\Intl\Exception\NotImplementedException;
* Class Attachment.
*
* @ORM\Entity
* @ORM\Table(name="attachements")
* @ORM\Table(name="`attachements`")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="class_name", type="string")
* @ORM\DiscriminatorMap({"PartDB\Part" = "PartAttachment", "Part" = "PartAttachment"})
*
*/
class Attachment extends NamedDBElement
abstract class Attachment extends NamedDBElement
{
/**
* @var bool
@ -47,9 +51,7 @@ class Attachment extends NamedDBElement
protected $filename;
/**
* //TODO
* //@ORM\ManyToOne(targetEntity="AttachmentContainingDBElement", inversedBy="attachment")
* //@ORM\JoinColumn(name="element_id", referencedColumnName="id").
* ORM mapping is done in sub classes (like PartAttachment)
*/
protected $element;

View file

@ -34,7 +34,9 @@ abstract class AttachmentContainingDBElement extends NamedDBElement
/**
* @var
* //TODO
* @ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
* //@ORM\OneToMany(targetEntity="Attachment", mappedBy="element")
*
* Mapping is done in sub classes like part
*/
protected $attachments;

View file

@ -32,7 +32,7 @@ use Doctrine\ORM\Mapping as ORM;
* Class AttachmentType.
*
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
* @ORM\Table(name="attachement_types")
* @ORM\Table(name="`attachement_types`")
*/
class AttachmentType extends StructuralDBElement
{

View file

@ -29,7 +29,7 @@ use Doctrine\ORM\Mapping as ORM;
* Class AttachmentType.
*
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
* @ORM\Table(name="categories")
* @ORM\Table(name="`categories`")
*/
class Category extends PartsContainingDBElement
{
@ -51,13 +51,13 @@ class Category extends PartsContainingDBElement
/**
* @var string
* @ORM\Column(type="string")
* @ORM\Column(type="text")
*/
protected $partname_hint = "";
/**
* @var string
* @ORM\Column(type="string")
* @ORM\Column(type="text")
*/
protected $partname_regex = "";
@ -87,13 +87,13 @@ class Category extends PartsContainingDBElement
/**
* @var string
* @ORM\Column(type="string")
* @ORM\Column(type="text")
*/
protected $default_description = "";
/**
* @var string
* @ORM\Column(type="string")
* @ORM\Column(type="text")
*/
protected $default_comment = "";

View file

@ -38,7 +38,7 @@ use Doctrine\ORM\Mapping as ORM;
* Class AttachmentType.
*
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
* @ORM\Table(name="devices")
* @ORM\Table(name="`devices`")
*/
class Device extends PartsContainingDBElement
{

View file

@ -37,7 +37,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* Class DevicePart.
*
* @ORM\Table("device_parts")
* @ORM\Table("`device_parts`")
* @ORM\Entity()
*/
class DevicePart extends DBElement
@ -49,9 +49,26 @@ class DevicePart extends DBElement
*/
protected $device;
//TODO
/**
* @var Part
* @ORM\ManyToOne(targetEntity="Part")
* @ORM\JoinColumn(name="id_part", referencedColumnName="id")
*/
protected $part;
/**
* @var int
* @ORM\Column(type="integer", name="quantity")
*/
protected $quantity;
/**
* @var string
* @ORM\Column(type="text", name="mountnames")
*/
protected $mountnames;
/**
* Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14.

View file

@ -38,7 +38,7 @@ use Doctrine\ORM\Mapping as ORM;
* Class Footprint.
*
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
* @ORM\Table("footprints")
* @ORM\Table("`footprints`")
*/
class Footprint extends PartsContainingDBElement
{
@ -55,7 +55,7 @@ class Footprint extends PartsContainingDBElement
/**
* @var string
* @ORM\Column(type="string")
* @ORM\Column(type="string", length=65536)
*/
protected $filename;
@ -66,7 +66,7 @@ class Footprint extends PartsContainingDBElement
/**
* @var string
* @ORM\Column(type="string")
* @ORM\Column(type="string", length=65536)
*/
protected $filename_3d;

View file

@ -38,7 +38,7 @@ use Doctrine\ORM\Mapping as ORM;
* Class Manufacturer.
*
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
* @ORM\Table("manufacturers")
* @ORM\Table("`manufacturers`")
*/
class Manufacturer extends Company
{

View file

@ -39,7 +39,7 @@ use Exception;
/**
* Class Orderdetail.
*
* @ORM\Table("orderdetails")
* @ORM\Table("`orderdetails`")
* @ORM\Entity()
*/
class Orderdetail extends DBElement

View file

@ -42,12 +42,17 @@ use Symfony\Component\Validator\Constraints as Assert;
* Class Part.
*
* @ORM\Entity(repositoryClass="App\Repository\PartRepository")
* @ORM\Table("parts")
* @ORM\Table("`parts`")
*/
class Part extends AttachmentContainingDBElement
{
public const INSTOCK_UNKNOWN = -2;
/**
* @ORM\OneToMany(targetEntity="PartAttachment", mappedBy="element")
*/
protected $attachments;
/**
* @var Category
* @ORM\ManyToOne(targetEntity="Category", inversedBy="parts")
@ -138,7 +143,7 @@ class Part extends AttachmentContainingDBElement
/**
* @var string
* @ORM\Column(type="string")
* @ORM\Column(type="text")
*
* @ColumnSecurity(prefix="description")
*/
@ -164,7 +169,7 @@ class Part extends AttachmentContainingDBElement
/**
* @var string
* @ORM\Column(type="string")
* @ORM\Column(type="text")
* @ColumnSecurity(prefix="comment")
*/
protected $comment = '';

View file

@ -0,0 +1,51 @@
<?php
/**
*
* part-db version 0.1
* Copyright (C) 2005 Christoph Lechner
* http://www.cl-projects.de/
*
* part-db version 0.2+
* Copyright (C) 2009 K. Jacobs and others (see authors.php)
* http://code.google.com/p/part-db/
*
* Part-DB Version 0.4+
* Copyright (C) 2016 - 2019 Jan Böhmer
* https://github.com/jbtronics
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class PartAttachment
* @package App\Entity
* @ORM\Entity()
*/
class PartAttachment extends Attachment
{
/**
*
* @ORM\ManyToOne(targetEntity="Part", inversedBy="attachments")
* @ORM\JoinColumn(name="element_id", referencedColumnName="id").
*/
protected $element;
}

View file

@ -39,7 +39,7 @@ use Webmozart\Assert\Assert;
* Class Pricedetail.
*
* @ORM\Entity()
* @ORM\Table("pricedetails")
* @ORM\Table("`pricedetails`")
*/
class Pricedetail extends DBElement
{

View file

@ -38,7 +38,7 @@ use Doctrine\ORM\Mapping as ORM;
* Class Storelocation.
*
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
* @ORM\Table("storelocations")
* @ORM\Table("`storelocations`")
*/
class Storelocation extends PartsContainingDBElement
{

View file

@ -67,10 +67,10 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
/**
* @var string The comment info for this element
* @ORM\Column(type="string", nullable=true)
* @ORM\Column(type="text")
* @Groups({"simple", "extended", "full"})
*/
protected $comment;
protected $comment = "";
/**
* @var int

View file

@ -38,7 +38,7 @@ use Doctrine\ORM\Mapping as ORM;
* Class Supplier.
*
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
* @ORM\Table("suppliers")
* @ORM\Table("`suppliers`")
*/
class Supplier extends Company
{

View file

@ -42,7 +42,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* Also this entity is able to save some informations about the user, like the names, email-address and other info.
*
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @ORM\Table("users")
* @ORM\Table("`users`")
*/
class User extends NamedDBElement implements UserInterface, HasPermissionsInterface
{
@ -134,6 +134,26 @@ class User extends NamedDBElement implements UserInterface, HasPermissionsInterf
*/
protected $permissions;
/**
* @ORM\Column(type="string", name="config_currency")
*/
protected $currency;
/**
* @ORM\Column(type="text", name="config_image_path")
*/
protected $image_path;
/**
* @ORM\Column(type="text", name="config_instock_comment_w")
*/
protected $instock_comment_w;
/**
* @ORM\Column(type="text", name="config_instock_comment_a")
*/
protected $instock_comment_a;
/**
* Checks if the current user, is the user which represents the not logged in (anonymous) users.
*