create_shipping_tables.php.stub 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * This file is part of ibrand/shipping.
  4. *
  5. * (c) iBrand <https://www.ibrand.cc>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. use Illuminate\Support\Facades\Schema;
  11. use Illuminate\Database\Schema\Blueprint;
  12. use Illuminate\Database\Migrations\Migration;
  13. class CreateShippingTables extends Migration
  14. {
  15. /**
  16. * Run the migrations.
  17. *
  18. * @return void
  19. */
  20. public function up()
  21. {
  22. $prefix = config('ibrand.app.database.prefix') ?? 'ibrand_';
  23. if(!Schema::hasTable($prefix . 'shipping_method')) {
  24. Schema::create($prefix . 'shipping_method', function (Blueprint $table) {
  25. $table->increments('id');
  26. $table->string('code');
  27. $table->string('name');
  28. $table->string('url')->nullable();
  29. $table->boolean('is_enabled')->default(true);
  30. $table->timestamps();
  31. $table->softDeletes();
  32. });
  33. }
  34. if(!Schema::hasTable($prefix . 'shipping')) {
  35. Schema::create($prefix . 'shipping', function (Blueprint $table) {
  36. $table->increments('id');
  37. $table->integer('method_id');
  38. $table->integer('order_id');
  39. $table->string('tracking')->nullable(); //快递单号
  40. $table->timestamp('delivery_time')->nullable();
  41. $table->timestamps();
  42. $table->softDeletes();
  43. });
  44. }
  45. }
  46. /**
  47. * Reverse the migrations.
  48. *
  49. * @return void
  50. */
  51. public function down()
  52. {
  53. $prefix = config('ibrand.app.database.prefix') ?? 'ibrand_';
  54. Schema::dropIfExists($prefix . 'shipping');
  55. Schema::dropIfExists($prefix . 'shipping_method');
  56. }
  57. }