<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateProvincesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('provinces', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name',50)->unique()->comment('名称');
            $table->timestamps();
        });
        $provinces=['陕西','甘肃','宁夏','青海','新疆','江苏','浙江','安徽','江西','福建','重庆','四川','云南',
            '贵州','西藏','黑龙江','吉林','辽宁','山东','北京','天津','广西','广东','河北','山西','内蒙古',
            '湖北','湖南','河南','海南','香港','澳门','台湾','上海'];
        for ($i=0;$i<count($provinces);$i++){
            \App\Province::create([
                'name'=>$provinces[$i]
            ]);
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('provinces');
    }
}
