2019_01_21_111731_add_order_invoice.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class AddOrderInvoice extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. //添加字段
  15. if (Schema::hasTable('yz_order')) {
  16. if (!Schema::hasColumn('yz_order', 'invoice')) {
  17. Schema::table('yz_order', function (Blueprint $table) {
  18. $table->integer('invoice_type')->nullable();
  19. $table->integer('rise_type')->nullable();
  20. $table->string('call')->nullable();
  21. $table->integer('company_number')->nullable();
  22. $table->string('invoice')->nullable();
  23. });
  24. }
  25. }
  26. }
  27. /**
  28. * Reverse the migrations.
  29. *
  30. * @return void
  31. */
  32. public function down()
  33. {
  34. if (Schema::hasTable('yz_order')) {
  35. if (Schema::hasColumn('yz_order', 'invoice')) {
  36. Schema::table('yz_order', function (Blueprint $table) {
  37. $table->dropColumn('invoice_type');
  38. $table->dropColumn('rise_type');
  39. $table->dropColumn('call');
  40. $table->dropColumn('company_number');
  41. $table->dropColumn('invoice');
  42. });
  43. }
  44. }
  45. //
  46. }
  47. }