| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Schema;
- class CreateTaxRatesTable extends Migration
- {
- protected $values = [
- 0,3,6,11
- ];
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('tax_rates', function (Blueprint $table) {
- $table->id();
- $table->decimal("value",5,2)->unique()->comment("值");
- $table->timestamps();
- });
- Schema::table('owners', function (Blueprint $table) {
- $table->dropColumn("tax_rate");
- $table->bigInteger("tax_rate_id")->nullable()->comment("外键税率");
- $table->string("relevance")->nullable()->comment("关联模型的JSON数组");
- });
- foreach ($this->values as $value) DB::insert(DB::raw("INSERT INTO tax_rates(value) VALUES(?)"),[$value]);
- Schema::table('warehouses', function (Blueprint $table) {
- $table->decimal("production_capacity")->default(0)->comment("产能");
- $table->integer("reduced_production_capacity_coefficient")->default(0)->comment("SKU减产系数");
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('tax_rates');
- Schema::table('owners', function (Blueprint $table) {
- $table->dropColumn("tax_rate_id");
- $table->decimal("tax_rate")->nullable()->comment("税率");
- $table->dropColumn("relevance");
- });
- Schema::table('warehouses', function (Blueprint $table) {
- $table->dropColumn("production_capacity");
- $table->dropColumn("reduced_production_capacity_coefficient");
- });
- }
- }
|