migrations/Finance/Version20200511100550_FinanceBill.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Finance;
use App\Doctrine\Type\Finance\BillType;
use App\Doctrine\Type\Finance\PayableStatus;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200511100550_FinanceBill extends AbstractMigration
{
public function getDescription() : string
{
return 'Add bill table';
}
public function up(Schema $schema) : void
{
$billTypeType = BillType::getName();
$payableStatusType = PayableStatus::getName();
$this->addSql("CREATE TABLE finance_bill (
id SERIAL PRIMARY KEY,
identifier UUID NOT NULL,
shipping_plan_id INTEGER NOT NULL REFERENCES public.expediting_shipping_plan (id),
payable_to INTEGER NOT NULL REFERENCES public.company (id),
payable_by INTEGER NOT NULL REFERENCES public.company (id),
original_bill_id INTEGER REFERENCES public.finance_bill (id),
number CHARACTER VARYING NOT NULL,
external_reference CHARACTER VARYING,
lines_sum DECIMAL(18, 2),
taxes_sum DECIMAL(18, 2),
total DECIMAL(18, 2),
due_on DATE,
paid_on DATE,
type {$billTypeType} NOT NULL,
status {$payableStatusType} NOT NULL,
created_by INTEGER NOT NULL REFERENCES public.user (id),
updated_by INTEGER REFERENCES public.user (id),
created_at TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP(0) WITH TIME ZONE,
deleted_at TIMESTAMP(0) WITH TIME ZONE,
CONSTRAINT finance_bill_identifier_key UNIQUE (identifier),
CONSTRAINT finance_bill_number_key UNIQUE (number),
CONSTRAINT finance_bill_external_reference_key UNIQUE (external_reference)
)");
$this->addSql("COMMENT ON COLUMN finance_bill.identifier IS '(DC2Type:ulid)'");
$this->addSql("CREATE INDEX finance_bill_original_bill_id_idx ON finance_bill (original_bill_id)");
$this->addSql("CREATE INDEX finance_bill_shipping_plan_id_idx ON finance_bill (shipping_plan_id)");
$this->addSql("CREATE INDEX finance_bill_payable_by_idx ON finance_bill (payable_by)");
$this->addSql("CREATE INDEX finance_bill_payable_to_idx ON finance_bill (payable_to)");
$this->addSql("CREATE INDEX finance_bill_created_by_idx ON finance_bill (created_by)");
$this->addSql("CREATE INDEX finance_bill_updated_by_idx ON finance_bill (updated_by)");
}
public function down(Schema $schema) : void
{
$this->addSql("DROP TABLE IF EXISTS finance_bill");
}
}