migrations/Finance/Version20200511102738_FinanceInvoice.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Finance;
use App\Doctrine\Type\Finance\InvoiceType;
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 Version20200511102738_FinanceInvoice extends AbstractMigration
{
public function getDescription() : string
{
return 'Add invoice table';
}
public function up(Schema $schema) : void
{
$invoiceTypeType = InvoiceType::getName();
$payableStatusType = PayableStatus::getName();
$this->addSql("CREATE TABLE finance_invoice (
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_quote_id INTEGER REFERENCES public.finance_invoice (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 {$invoiceTypeType} NOT NULL,
status {$payableStatusType} NOT NULL,
created_by INTEGER 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_invoice_original_quote_id_key UNIQUE (original_quote_id),
CONSTRAINT finance_invoice_identifier_key UNIQUE (identifier),
CONSTRAINT finance_invoice_number_key UNIQUE (number),
CONSTRAINT finance_invoice_external_reference_key UNIQUE (external_reference)
)");
$this->addSql("COMMENT ON COLUMN finance_invoice.identifier IS '(DC2Type:ulid)'");
$this->addSql("CREATE INDEX finance_invoice_shipping_plan_id_idx ON finance_invoice (shipping_plan_id)");
$this->addSql("CREATE INDEX finance_invoice_payable_to_idx ON finance_invoice (payable_to)");
$this->addSql("CREATE INDEX finance_invoice_payable_by_idx ON finance_invoice (payable_by)");
$this->addSql("CREATE INDEX finance_invoice_created_by_idx ON finance_invoice (created_by)");
$this->addSql("CREATE INDEX finance_invoice_updated_by_idx ON finance_invoice (updated_by)");
}
public function down(Schema $schema) : void
{
$this->addSql("DROP TABLE IF EXISTS finance_invoice");
}
}