Skip to content

Commit fdee193

Browse files
committed
Make path field unique in invoices and update migration logic
1 parent 919f848 commit fdee193

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

config/doctrine/Invoice.orm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<field name="localeCode" column="locale_code" />
1111
<field name="total" column="total" type="integer" />
1212
<field name="paymentState" column="payment_state" />
13-
<field name="path" column="path" />
13+
<field name="path" column="path" unique="true" />
1414

1515
<one-to-one field="billingData" target-entity="Sylius\InvoicingPlugin\Entity\BillingDataInterface">
1616
<cascade>

src/Generator/InvoiceFileNameGeneratorInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
namespace Sylius\InvoicingPlugin\Generator;
1515

16-
use Sylius\InvoicingPlugin\Entity\InvoiceInterface;
17-
1816
interface InvoiceFileNameGeneratorInterface
1917
{
2018
public function generateForPdf(string $invoiceNumber): string;

src/Migrations/Version20251023082457.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ final class Version20251023082457 extends AbstractMigration
2020
{
2121
public function getDescription(): string
2222
{
23-
return 'Add path column to sylius_invoicing_plugin_invoice table to store invoice file paths';
23+
return 'Add path field to sylius_invoicing_plugin_invoice table';
2424
}
2525

2626
public function up(Schema $schema): void
2727
{
2828
$this->addSql('ALTER TABLE sylius_invoicing_plugin_invoice ADD path VARCHAR(255) NOT NULL');
29+
$this->addSql('CREATE UNIQUE INDEX UNIQ_3AA279BFB548B0F ON sylius_invoicing_plugin_invoice (path)');
2930
}
3031

3132
public function down(Schema $schema): void
3233
{
34+
$this->addSql('DROP INDEX UNIQ_3AA279BFB548B0F ON sylius_invoicing_plugin_invoice');
3335
$this->addSql('ALTER TABLE sylius_invoicing_plugin_invoice DROP path');
3436
}
3537
}

0 commit comments

Comments
 (0)