2018_04_04_153109_create_advertises_table.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateAdvertisesTable extends Migration
  6. {
  7. protected $table = 'advertises';
  8. protected $tb_adsTypes = 'advertise_types';
  9. /**
  10. * Run the migrations.
  11. *
  12. * @return void
  13. */
  14. public function up()
  15. {
  16. Schema::create($this->table, function (Blueprint $table) {
  17. $table->increments('id')->comment('唯一标识')->unsigned();
  18. $table->string('name', 50)->comment('名称');
  19. $table->integer('tpid')->comment('所属广告位种类id');
  20. $table->tinyInteger('sort')->comment('排序');
  21. $table->string('image')->comment('图片相对路径');
  22. $table->string('href')->comment('链接');
  23. $table->timestamps();
  24. $table->foreign('tpid')->references('id')->on($this->tb_adsTypes);
  25. });
  26. DB::statement("ALTER TABLE ".$this->table." comment'广告位信息表'");
  27. }
  28. /**
  29. * Reverse the migrations.
  30. *
  31. * @return void
  32. */
  33. public function down()
  34. {
  35. Schema::dropIfExists($this->table);
  36. }
  37. }