2019_08_07_184030_create_places_table.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreatePlacesTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('places', function (Blueprint $table) {
  15. $table->bigIncrements('id');
  16. $table->string('slug')->index();
  17. $table->string('name')->index();
  18. $table->string('country')->index();
  19. $table->json('aliases')->nullable();
  20. $table->decimal('lat', 9, 6)->nullable();
  21. $table->decimal('long', 9, 6)->nullable();
  22. $table->unique(['slug', 'country', 'lat', 'long']);
  23. $table->timestamps();
  24. });
  25. Schema::table('statuses', function (Blueprint $table) {
  26. $table->bigInteger('place_id')->unsigned()->nullable()->index();
  27. });
  28. }
  29. /**
  30. * Reverse the migrations.
  31. *
  32. * @return void
  33. */
  34. public function down()
  35. {
  36. Schema::dropIfExists('places');
  37. Schema::table('statuses', function (Blueprint $table) {
  38. $table->dropColumn('place_id');
  39. });
  40. }
  41. }