123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
-
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
-
- return new class extends Migration
- {
- /**
- * Run the migrations.
- */
- public function up(): void
- {
- Schema::create('contacts', function (Blueprint $table) {
- $table->id();
- $table->foreignId('company_id')->constrained()->onDelete('cascade');
- $table->string('entity')->default('individual');
- $table->string('type');
- $table->string('name');
- $table->string('email')->nullable();
- $table->string('tax_number')->nullable();
- $table->string('phone')->nullable();
- $table->text('address')->nullable();
- $table->string('city')->nullable();
- $table->string('zip_code')->nullable();
- $table->string('state')->nullable();
- $table->string('country')->nullable();
- $table->string('website')->nullable();
- $table->string('currency_code')->default('USD');
- $table->string('reference')->nullable();
- $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
- $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
- $table->timestamps();
-
- $table->index(['company_id', 'type']);
- $table->unique(['company_id', 'type', 'email']);
- $table->foreign('currency_code')->references('code')->on('currencies')->restrictOnDelete();
- });
- }
-
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- Schema::dropIfExists('contacts');
- }
- };
|