| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
-
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
-
- return new class extends Migration
- {
- /**
- * EasyParcel: the merchant's connected account, where parcels are collected from, and the courier booked for an order.
- */
- public function up(): void
- {
- Schema::create('easyparcel_accounts', function (Blueprint $table) {
- $table->id();
- $table->foreignId('store_id')->unique()->constrained()->cascadeOnDelete();
- $table->string('account_name')->nullable();
- // Kept encrypted. They let us act on the merchant's EasyParcel account.
- $table->text('access_token');
- $table->text('refresh_token')->nullable();
- $table->timestamp('expires_at')->nullable();
- $table->timestamps();
- });
-
- Schema::table('stores', function (Blueprint $table) {
- // Where couriers collect parcels from: name, phone, line1, line2, city, postcode, state.
- $table->json('pickup_address')->nullable()->after('free_shipping_over');
- // The usual parcel, used to fill in the booking form: weight in grams, size in cm.
- $table->unsignedInteger('parcel_weight')->default(1000)->after('pickup_address');
- $table->json('parcel_size')->nullable()->after('parcel_weight');
- });
-
- Schema::table('orders', function (Blueprint $table) {
- $table->string('shipment_number')->nullable()->after('tracking_number');
- $table->string('shipment_order_number')->nullable()->after('shipment_number');
- $table->unsignedInteger('shipment_cost')->nullable()->after('shipment_order_number');
- $table->text('label_url')->nullable()->after('shipment_cost');
- $table->text('tracking_url')->nullable()->after('label_url');
- });
- }
-
- public function down(): void
- {
- Schema::table('orders', function (Blueprint $table) {
- $table->dropColumn(['shipment_number', 'shipment_order_number', 'shipment_cost', 'label_url', 'tracking_url']);
- });
-
- Schema::table('stores', function (Blueprint $table) {
- $table->dropColumn(['pickup_address', 'parcel_weight', 'parcel_size']);
- });
-
- Schema::dropIfExists('easyparcel_accounts');
- }
- };
|