create_advert_tables.php.stub 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. * This file is part of ibrand/advert.
  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 CreateAdvertTables 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 . 'advert')) {
  24. Schema::create($prefix . 'advert', function (Blueprint $table) {
  25. $table->increments('id');
  26. $table->string('code')->unique();
  27. $table->string('name');
  28. $table->timestamps();
  29. });
  30. Schema::create($prefix . 'advert_item', function (Blueprint $table) {
  31. $table->increments('id');
  32. $table->unsignedInteger('advert_id');
  33. $table->string('name');
  34. $table->string('image');
  35. $table->string('link');
  36. $table->integer('sort')->default(99);//排序
  37. $table->text('meta')->nullable();//存储json数据格式,主要用来存储一些额外的信息,预留字段
  38. $table->timestamps();
  39. });
  40. }
  41. }
  42. /**
  43. * Reverse the migrations.
  44. *
  45. * @return void
  46. */
  47. public function down()
  48. {
  49. $prefix = config('ibrand.app.database.prefix', 'ibrand_');
  50. Schema::dropIfExists($prefix.'advert_item');
  51. Schema::dropIfExists($prefix.'advert');
  52. }
  53. }