<?php

/*
 * This file is part of the VITICORE2 package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Cart\Model;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\UuidInterface;

#[ORM\Entity(readOnly: true)]
#[ORM\Table(name: 'cart_legacy_order_import_map')]
#[ORM\Index(name: 'idx_legacy_order_import_map_run', columns: ['run_id'])]
#[ORM\UniqueConstraint(name: 'uniq_legacy_order_import_map_cart', columns: ['source_key', 'source_cart_id'])]
#[ORM\UniqueConstraint(name: 'uniq_legacy_order_import_map_checkout', columns: ['source_key', 'source_checkout_id'])]
#[ORM\UniqueConstraint(name: 'uniq_legacy_order_import_map_target', columns: ['target_cart_id'])]
class LegacyOrderImportMap
{
    #[ORM\Id]
    #[ORM\Column(type: 'uuid')]
    private UuidInterface $id;

    #[ORM\ManyToOne(targetEntity: LegacyOrderImportRun::class)]
    #[ORM\JoinColumn(name: 'run_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
    private LegacyOrderImportRun $run;

    #[ORM\Column(type: Types::STRING, length: 64)]
    private string $sourceKey;

    #[ORM\Column(type: Types::STRING, length: 36)]
    private string $sourceCheckoutId;

    #[ORM\Column(type: Types::STRING, length: 36)]
    private string $sourceCartId;

    #[ORM\ManyToOne(targetEntity: Cart::class)]
    #[ORM\JoinColumn(name: 'target_cart_id', referencedColumnName: 'id', nullable: false)]
    private Cart $targetCart;

    #[ORM\Column(type: Types::STRING, length: 64)]
    private string $sourceChecksum;

    #[ORM\Column(type: Types::DATETIME_MUTABLE)]
    private \DateTimeInterface $importedAt;
}
