12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- use Illuminate\Support\Facades\Schema;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Database\Migrations\Migration;
- class AddColUsersTable extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- if(!Schema::hasColumn('users','wechat_id')){
- Schema::table('users', function (Blueprint $table) {
- $table->string('wechat_id')->after('id')->nullable()->comment('微信id');
- });
- }
- if(!Schema::hasColumn('users','mobile')){
- Schema::table('users', function (Blueprint $table) {
- $table->char('mobile',11)->after('email')->index()->comment('手机');
- });
- }
- if(!Schema::hasColumn('users','nickname')){
- Schema::table('users', function (Blueprint $table) {
- $table->string('nickname')->after('name')->nullable()->comment('昵称');
- });
- }
- if(!Schema::hasColumn('users','avatar')){
- Schema::table('users', function (Blueprint $table) {
- $table->string('avatar')->after('mobile')->nullable()->comment('头像');
- });
- }
- if(!Schema::hasColumn('users','school_id')){
- Schema::table('users', function (Blueprint $table) {
- $table->string('school_id')->after('avatar')->nullable()->comment('头像');
- });
- }
- if(!Schema::hasColumn('sclass_id','sclass')){
- Schema::table('users', function (Blueprint $table) {
- $table->integer('sclass_id')->after('school_id')->nullable()->comment('班级');
- });
- }
- if(!Schema::hasColumn('grade_id','grade')){
- Schema::table('users', function (Blueprint $table) {
- $table->integer('grade_id')->after('class_id')->nullable()->comment('班级');
- });
- }
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- if(Schema::hasColumn('users','mobile')){
- Schema::table('users', function (Blueprint $table) {
- $table->dropColumn('mobile');
- });
- }
- if(Schema::hasColumn('users','nickname')){
- Schema::table('users', function (Blueprint $table) {
- $table->dropColumn('nickname');
- });
- }
- if(Schema::hasColumn('users','avatar')){
- Schema::table('users', function (Blueprint $table) {
- $table->dropColumn('avatar');
- });
- }
- }
- }
|