123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?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('addresses', function (Blueprint $table) {
- $table->id();
- $table->foreignId('company_id')->constrained()->cascadeOnDelete();
- $table->foreignId('parent_address_id')->nullable()->constrained('addresses')->nullOnDelete();
- $table->morphs('addressable');
- $table->string('type'); // billing, shipping, etc.
- $table->string('recipient')->nullable();
- $table->string('phone')->nullable();
- $table->string('address_line_1')->nullable();
- $table->string('address_line_2')->nullable();
- $table->string('city')->nullable();
- $table->smallInteger('state_id')->nullable();
- $table->string('postal_code')->nullable();
- $table->string('country_code');
- $table->text('notes')->nullable();
- $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
- $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
- $table->timestamps();
- });
- }
-
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- Schema::dropIfExists('addresses');
- }
- };
|