Skip to content

Commit fe74f64

Browse files
committed
2 parents df5ef05 + 563a282 commit fe74f64

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace LaravelEnso\Core\app\Commands\DatabaseUpgrades;
4+
5+
use Illuminate\Support\Facades\Schema;
6+
use Illuminate\Database\Schema\Blueprint;
7+
8+
class CompaniesFiscalCodeUpgrade extends DatabaseUpgrade
9+
{
10+
protected function isMigrated()
11+
{
12+
return Schema::getConnection()
13+
->getDoctrineSchemaManager()
14+
->listTableDetails('companies')
15+
->hasIndex('companies_fiscal_code_unique');
16+
}
17+
18+
public function migrateTable()
19+
{
20+
Schema::table('companies', function (Blueprint $table) {
21+
$table->unique('reg_com_nr');
22+
$table->unique('fiscal_code');
23+
});
24+
}
25+
}

src/app/Commands/Upgrade.php

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use LaravelEnso\Core\app\Commands\DatabaseUpgrades\InvoiceLineUpgrade;
1414
use LaravelEnso\Core\app\Commands\DatabaseUpgrades\RoAddressesUpgrade;
1515
use LaravelEnso\Core\app\Commands\DatabaseUpgrades\DataImportIndexUpgrade;
16+
use LaravelEnso\Core\app\Commands\DatabaseUpgrades\CompaniesFiscalCodeUpgrade;
1617
use LaravelEnso\Core\app\Commands\DatabaseUpgrades\AddingInvoiceLinePermissions;
1718

1819
class Upgrade extends Command
@@ -41,5 +42,7 @@ private function upgrade()
4142
(new InvoiceLineUpgrade())->migrate();
4243
(new AddingInvoiceLinePermissions())->migrate();
4344
}
45+
46+
//(new CompaniesFiscalCodeUpgrade())->handle();
4447
}
4548
}

0 commit comments

Comments
 (0)