/** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasColumn('011_225_booking', 'n_rooms_225')) { Schema::table('011_225_booking', function ($table) { $table->smallInteger('n_rooms_225')->unsigned()->nullable()->after('n_children_225'); }); } if (!Schema::hasColumn('011_225_booking', 'nights_225')) { Schema::table('011_225_booking', function ($table) { $table->smallInteger('nights_225')->unsigned()->nullable()->after('check_out_date_text_225'); }); } if (Schema::hasColumn('011_225_booking', 'room_description_225')) { Schema::table('011_225_booking', function ($table) { $table->renameColumn('room_description_225', 'object_description_225'); }); } if (Schema::hasColumn('011_225_booking', 'n_adult_225')) { Schema::table('011_225_booking', function ($table) { $table->renameColumn('n_adult_225', 'n_adults_225'); }); } if (Schema::hasColumn('011_225_booking', 'temporary_bed_225')) { Schema::table('011_225_booking', function ($table) { $table->renameColumn('temporary_bed_225', 'temporary_beds_225'); }); } }
/** * Test table was created based from config * @group entity */ public function testTableWasCreatedFromConfig() { $this->assertTrue(Schema::hasTable('users')); $this->assertTrue(Schema::hasTable('users_profile')); $this->assertTrue(Schema::hasColumn('users', 'email')); $this->assertTrue(Schema::hasColumn('users_profile', 'first_name')); }
public function run() { Model::unguard(); DB::table('users')->delete(); DB::table('roles')->delete(); DB::table('role_user')->delete(); DB::table('permission_role')->delete(); DB::table('permissions')->delete(); if (!Schema::hasColumn('permissions', 'isDisplay')) { Schema::table('permissions', function ($table) { $table->tinyInteger('isDisplay')->comment('是否显示在左侧菜单'); }); } if (!Schema::hasColumn('permissions', 'power')) { Schema::table('permissions', function ($table) { $table->string('power')->comment('权限正则'); }); } $user = User::create(['email' => '*****@*****.**', 'name' => 'admin', 'password' => bcrypt('admin')]); // 创建组 $admin = parent::createRole($this->roleName, "超级管理员组"); $menuIds = array(); $perant_id = parent::createPermission("/admin", "", "管理后台", 1, '$'); $menuIds[] = $perant_id; $menuArray = [["name" => "admin/user", "display_name" => $perant_id, "description" => "账号管理", "isDisplay" => 1, "power" => '(.*)'], ["name" => "admin/role", "display_name" => $perant_id, "description" => "角色管理", "isDisplay" => 1, "power" => '(.*)'], ["name" => "admin/menu", "display_name" => $perant_id, "description" => "菜单管理", "isDisplay" => 1, "power" => '(.*)']]; foreach ($menuArray as $value) { $menuIds[] = self::createPermission($value['name'], $value['display_name'], $value['description'], $value['isDisplay'], $value['power']); } // 添加用户组权限 $admin->perms()->sync($menuIds); $user->attachRole($admin); // // 检查 print_r("true\n"); Model::reguard(); }
/** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasTable('company')) { Schema::create('company', function ($table) { $table->increments('id'); $table->unsignedInteger('cluster_id'); $table->string('name'); $table->string('domains'); $table->string('logo_url'); $table->timestamps(); }); } else { if (!Schema::hasColumn('company', 'name')) { Schema::table('company', function ($table) { $table->string('name'); }); } if (!Schema::hasColumn('company', 'domains')) { Schema::table('company', function ($table) { $table->string('domains'); }); } if (!Schema::hasColumn('company', 'logo_url')) { Schema::table('company', function ($table) { $table->string('logo_url'); }); } } }
/** * Run the migrations. * * @return void */ public function up() { DB::transaction(function () { $newDate = '2016-01-01 00:00:00'; if (Schema::hasTable('comments')) { if (!Schema::hasColumn('comments', 'companionship_id')) { Schema::table('comments', function (Blueprint $table) { $table->integer('companionship_id')->unsigned()->after('member_id'); }); } DB::update('UPDATE comments SET created_at = ?, updated_at = ? WHERE created_at = ?', [$newDate, $newDate, '0000-00-00 00:00:00']); DB::update('UPDATE ward_companions SET created_at = ?, updated_at = ? WHERE created_at = ?', [$newDate, $newDate, '0000-00-00 00:00:00']); $companionships = DB::select(' SELECT c.id AS commentId, c.member_id AS commentMemberId, c.companion_id AS commentCompanion, wc.*, c.family_id FROM comments AS c LEFT JOIN ward_companions AS wc ON (ht_one_id = c.member_id OR ht_one_id = c.companion_id) AND (ht_two_id = c.member_id OR ht_two_id = c.companion_id) ORDER BY commentId ASC'); $date = '2000-01-01 00:00:00'; foreach ($companionships as $companionship) { if (empty($companionship->id)) { $member = DB::table('members')->find($companionship->commentMemberId); DB::table('ward_companions')->insert(['ht_one_id' => $companionship->commentMemberId, 'ht_two_id' => $companionship->commentCompanion, 'ward_id' => $member->ward_id, 'district_id' => 0, 'quorum_id' => $member->quorum_id, 'family_id' => $companionship->family_id, 'created_at' => $date, 'updated_at' => $date, 'deleted_at' => $date]); $companionship->id = DB::getPdo()->lastInsertId(); } DB::update('UPDATE comments SET companionship_id = ? WHERE id = ?', [$companionship->id, $companionship->commentId]); } Schema::table('comments', function (Blueprint $table) { $table->dropColumn(['ward_id', 'companion_id']); }); } }); }
/** * Reverse the migrations. * * @return void */ public function down() { // Remove columns from products if (Schema::hasTable('products')) { Schema::table('products', function (Blueprint $table) { if (Schema::hasColumn('products', 'weight_unit')) { $table->dropColumn('weight_unit'); } if (Schema::hasColumn('products', 'volume_unit')) { $table->dropColumn('volume_unit'); } if (Schema::hasColumn('products', 'length')) { $table->dropColumn('length'); } if (Schema::hasColumn('products', 'width')) { $table->dropColumn('width'); } if (Schema::hasColumn('products', 'height')) { $table->dropColumn('height'); } if (Schema::hasColumn('products', 'weight')) { $table->dropColumn('weight'); } }); } }
/** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasTable('groups')) { Schema::create('groups', function ($table) { $table->increments('id'); $table->string('name', 255); $table->timestamp('created_at')->default('0000-00-00 00:00:00'); $table->timestamp('updated_at')->default('0000-00-00 00:00:00'); }); } else { Schema::table('groups', function ($table) { if (!Schema::hasColumn('groups', 'id')) { $table->increments('id'); } if (!Schema::hasColumn('groups', 'name')) { $table->string('name', 255); } if (!Schema::hasColumn('groups', 'created_at')) { $table->timestamp('created_at')->default('0000-00-00 00:00:00'); } if (!Schema::hasColumn('groups', 'updated_at')) { $table->timestamp('updated_at')->default('0000-00-00 00:00:00'); } }); } }
/** * Run the migrations. * * @return void */ public function up() { Schema::table('invoices', function ($table) { if (Schema::hasColumn('invoices', 'tax_rate')) { $table->decimal('tax_rate', 13, 3)->change(); } }); Schema::table('invoice_items', function ($table) { if (Schema::hasColumn('invoice_items', 'tax_rate')) { $table->decimal('tax_rate', 13, 3)->change(); } }); Schema::table('invoices', function ($table) { if (Schema::hasColumn('invoices', 'tax_rate')) { $table->renameColumn('tax_rate', 'tax_rate1'); $table->renameColumn('tax_name', 'tax_name1'); } $table->string('tax_name2')->nullable(); $table->decimal('tax_rate2', 13, 3); }); Schema::table('invoice_items', function ($table) { if (Schema::hasColumn('invoice_items', 'tax_rate')) { $table->renameColumn('tax_rate', 'tax_rate1'); $table->renameColumn('tax_name', 'tax_name1'); } $table->string('tax_name2')->nullable(); $table->decimal('tax_rate2', 13, 3); }); Schema::table('accounts', function ($table) { $table->boolean('enable_client_portal_dashboard')->default(true); }); }
/** * Run the migrations. * * @return void */ public function up() { // checking the existence of the user table before adding if (!Schema::hasTable('user')) { Schema::create('user', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); $table->string('username'); $table->string('password'); $table->integer('rights'); }); } else { if (!Schema::hasColumn('user', 'username')) { Schema::table('user', function ($table) { $table->string('username'); }); } if (!Schema::hasColumn('user', 'password')) { Schema::table('user', function ($table) { $table->string('password'); }); } if (!Schema::hasColumn('user', 'rights')) { Schema::table('user', function ($table) { $table->integer('rights'); }); } } }
/** * Run the migrations. * * @return void */ public function up() { // *********************** // 012_116_order // *********************** if (Schema::hasColumn('012_116_order', 'tax_amount_116')) { // tax_amount_116 DBLibrary::renameColumn('012_116_order', 'tax_amount_116', 'tax_amount_116', 'DECIMAL', '12,4', false, false); } if (Schema::hasColumn('012_116_order', 'total_discount_amount_116')) { // total_discount_amount_116 DBLibrary::renameColumn('012_116_order', 'total_discount_amount_116', 'discount_amount_116', 'DECIMAL', '12,4', false, false); } if (Schema::hasColumn('012_116_order', 'shipping_116')) { // shipping_116 DBLibrary::renameColumn('012_116_order', 'shipping_116', 'shipping_amount_116', 'DECIMAL', '12,4', false, false); } if (!Schema::hasColumn('012_116_order', 'subtotal_with_discounts_116')) { Schema::table('012_116_order', function (Blueprint $table) { $table->decimal('subtotal_with_discounts_116', 12, 4)->after('discount_amount_116'); }); } // *********************** // 012_117_order_row // *********************** if (Schema::hasColumn('012_117_order_row', 'gift_117')) { // gift_117 DBLibrary::renameColumn('012_117_order_row', 'gift_117', 'has_gift_117', 'TINYINT', 1, false, false); } }
private function processInstructions() { /** @var Blueprint $table */ $table = $this->table; // Add timestamps if not yet added if (!\Schema::hasColumn($this->tableName, 'created_at')) { $table->timestamps(); } foreach ($this->assemblyInstructionSet->assemblyInstructions as $assemblyInstruction) { /** @var AssemblyInstruction $assemblyInstruction */ switch ($assemblyInstruction->tag) { case '@property': if (!\Schema::hasColumn($this->tableName, $assemblyInstruction->name)) { if (!$assemblyInstruction->hasHashtags()) { $table->{$assemblyInstruction->type}($assemblyInstruction->name); } else { $table->{$assemblyInstruction->getTypeTag()}($assemblyInstruction->name); } } else { if (!$assemblyInstruction->hasHashtags()) { $table->{$assemblyInstruction->type}($assemblyInstruction->name)->change(); } else { $table->{$assemblyInstruction->getTypeTag()}($assemblyInstruction->name)->change(); } } break; } } }
/** * Run the migrations. * * @return void */ public function up() { if (Schema::hasTable('users')) { // Add remember_token column to existing table if (!Schema::hasColumn('users', 'remember_token')) { Schema::table('users', function ($table) { $table->rememberToken(); }); } } else { // Continue support of Cartalyst/Sentry schema Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('email')->unique(); $table->string('password', 60); $table->rememberToken(); $table->timestamps(); $table->text('permissions')->nullable(); $table->boolean('activated')->default(0); $table->string('activation_code')->nullable(); $table->timestamp('activated_at')->nullable(); $table->timestamp('last_login')->nullable(); $table->string('persist_code')->nullable(); $table->string('reset_password_code')->nullable(); $table->string('first_name')->nullable(); $table->string('last_name')->nullable(); // We'll need to ensure that MySQL uses the InnoDB engine to // support the indexes, other engines aren't affected. $table->engine = 'InnoDB'; $table->index('activation_code'); $table->index('reset_password_code'); }); } }
/** * Run the migrations. * * @return void */ public function up() { if (Schema::hasColumn('012_111_product', 'price_111')) { // price_111 DBLibrary::renameColumn('012_111_product', 'price_111', 'subtotal_111', 'DECIMAL', '12,4', false, true); } }
/** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasTable('cluster')) { Schema::create('cluster', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); $table->string('clustername'); $table->string('password'); $table->integer('user_id'); }); } else { if (!Schema::hasColumn('cluster', 'clustername')) { Schema::table('cluster', function ($table) { $table->string('clustername'); }); } if (!Schema::hasColumn('cluster', 'password')) { Schema::table('cluster', function ($table) { $table->string('password'); }); } if (!Schema::hasColumn('cluster', 'user_id')) { Schema::table('cluster', function ($table) { $table->integer('user_id'); }); } } }
/** * Run the migrations. * * @return void */ public function up() { Schema::table('tax_rates', function ($table) { if (Schema::hasColumn('tax_rates', 'rate')) { $table->decimal('rate', 13, 3)->change(); } }); }
/** * Reverse the migrations. * * @return void */ public function down() { if (Schema::hasColumn('entries', 'user_id')) { Schema::table('entries', function ($table) { $table->dropColumn('user_id'); }); } }
/** * Reverse the migrations. * * @return void */ public function down() { Schema::table('oauth_clients', function (Blueprint $table) { if (Schema::hasColumn('oauth_clients', 'user_id')) { $table->dropColumn('user_id'); } }); }
/** * Reverse the migrations. * * @return void */ public function down() { if (Schema::hasColumn('users', 'api_token')) { Schema::table('users', function (Blueprint $table) { $table->dropColumn('api_token'); }); } }
/** * Reverse the migrations. * * @return void */ public function down() { if (Schema::hasTable('ward_comments') && Schema::hasColumn('ward_comments', 'deleted_at')) { Schema::table('ward_comments', function ($table) { $table->dropColumn('deleted_at'); }); } }
/** * Reverse the migrations. * * @return void */ public function down() { if (!Schema::hasColumn('short_term_trainees', 'occupation_id')) { Schema::table('short_term_trainees', function (Blueprint $table) { $table->dropColumn('occupation_id'); }); } }
/** * Reverse the migrations. * * @return void */ public function down() { Schema::table('companies', function (Blueprint $table) { if (Schema::hasColumn('companies', 'email')) { $table->dropColumn('email'); } }); }
/** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasColumn('response_ratings', 'observations')) { Schema::table('response_ratings', function (Blueprint $table) { $table->mediumText('observations')->nullable(); }); } }
/** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasColumn('013_352_category', 'slug_352')) { Schema::table('013_352_category', function ($table) { $table->string('slug_352')->nullable()->after('name_352'); }); } }
/** * Reverse the migrations. * * @return void */ public function down() { if (Schema::hasColumn('events', 'public')) { Schema::table('events', function ($table) { $table->dropColumn('public'); }); } }
/** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasColumn('011_226_voucher', 'has_used_226')) { Schema::table('011_226_voucher', function (Blueprint $table) { $table->boolean('has_used_226')->default(false)->after('active_226'); }); } }
/** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasColumn('orders', 'orders_pending_date')) { Schema::table('orders', function (Blueprint $table) { $table->dateTime('orders_pending_date')->nullable(); }); } }
/** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasColumn('observations', 'area_group_user')) { Schema::table('area_group_user', function (Blueprint $table) { $table->mediumText('observations')->nullable(); }); } }
/** * Reverse the migrations. * * @return void */ public function down() { if (Schema::hasColumn('users', 'city')) { Schema::table('users', function ($table) { $table->dropColumn('city'); }); } }
/** * Reverse the migrations. * * @return void */ public function down() { if (Schema::hasColumn('quiz_questions', 'required')) { Schema::table('quiz_questions', function ($table) { $table->dropColumn('required'); }); } }
/** * Run the migrations. * * @return void */ public function up() { if (!Schema::hasColumn('008_072_product', 'active_072')) { Schema::table('008_072_product', function (Blueprint $table) { $table->boolean('active_072')->after('name_072'); }); } }