本文整理汇总了PHP中Schema::rename方法的典型用法代码示例。如果您正苦于以下问题:PHP Schema::rename方法的具体用法?PHP Schema::rename怎么用?PHP Schema::rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Schema
的用法示例。
在下文中一共展示了Schema::rename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update($object_name)
{
//rename table if necessary
$object = DB::table(DB_OBJECTS)->where('name', $object_name)->first();
$new_name = Str::slug(Input::get('name'), '_');
if ($object->name != $new_name) {
Schema::rename($object->name, $new_name);
}
//enforce predence always ascending
$order_by = Input::get('order_by');
$direction = Input::get('direction');
if ($order_by == 'precedence') {
$direction = 'asc';
}
//not sure why it's necessary, doesn't like empty value all of a sudden
$group_by_field = Input::has('group_by_field') ? Input::get('group_by_field') : null;
//linked objects
DB::table(DB_OBJECT_LINKS)->where('object_id', $object->id)->delete();
if (Input::has('related_objects')) {
foreach (Input::get('related_objects') as $linked_id) {
DB::table(DB_OBJECT_LINKS)->insert(['object_id' => $object->id, 'linked_id' => $linked_id]);
}
}
//update objects table
DB::table(DB_OBJECTS)->where('id', $object->id)->update(['title' => Input::get('title'), 'name' => $new_name, 'model' => Input::get('model'), 'url' => Input::get('url'), 'order_by' => $order_by, 'direction' => $direction, 'singleton' => Input::has('singleton') ? 1 : 0, 'can_see' => Input::has('can_see') ? 1 : 0, 'can_create' => Input::has('can_create') ? 1 : 0, 'can_edit' => Input::has('can_edit') ? 1 : 0, 'list_grouping' => Input::get('list_grouping'), 'group_by_field' => $group_by_field, 'list_help' => trim(Input::get('list_help')), 'form_help' => trim(Input::get('form_help'))]);
self::saveSchema();
return Redirect::action('InstanceController@index', $new_name);
}
示例2: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// No data preservation on the "down" side of this one.
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
foreach (['favorites', 'conferences', 'submissions', 'talk_revisions', 'talks'] as $table) {
DB::table($table)->truncate();
}
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
Schema::table('talks', function (Blueprint $table) {
$table->string('title')->unique();
$table->text('description');
});
Schema::create('talk_versions', function (Blueprint $table) {
$table->string('id', 36)->unique();
$table->string('nickname', 150);
$table->timestamps();
$table->string('talk_id', 36);
$table->foreign('talk_id')->references('id')->on('talks')->onDelete('cascade');
});
Schema::rename('talk_revisions', 'talk_version_revisions');
Schema::table('talk_version_revisions', function (Blueprint $table) {
$table->dropForeign('talk_revisions_talk_id_foreign');
$table->dropColumn('talk_id');
$table->string('talk_version_id', 36);
$table->foreign('talk_version_id')->references('id')->on('talk_versions')->onDelete('cascade');
});
Schema::table('submissions', function (Blueprint $table) {
$table->dropForeign('submissions_talk_revision_id_foreign');
$table->renameColumn('talk_revision_id', 'talk_version_revision_id');
$table->foreign('talk_version_revision_id')->references('id')->on('talk_version_revisions')->onDelete('cascade');
});
}
示例3: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// break relations
Schema::table('opportunities', function ($table) {
$table->dropForeign('opportunities_beneficiary_id_foreign');
});
// rename tables and fields
Schema::rename('beneficiaries', 'partners');
Schema::rename('beneficiary_attributes', 'partner_attributes');
Schema::table('partner_attributes', function ($table) {
$table->renameColumn("beneficiary_id", "partner_id");
});
Schema::table('opportunities', function ($table) {
$table->renameColumn("beneficiary_id", "partner_id");
});
Schema::table('attributes', function ($table) {
$table->dropColumn('for');
});
Schema::table('attributes', function ($table) {
$table->enum('for', ['partner,opportunity']);
});
Schema::table('configs', function ($table) {
$table->renameColumn('show_filter_beneficiary', 'show_filter_partner');
});
// remake relations
Schema::table('opportunities', function ($table) {
$table->foreign('partner_id')->references('id')->on('partners');
});
Schema::table('partner_attributes', function ($table) {
$table->foreign('partner_id')->references('id')->on('partners');
});
}
开发者ID:npmweb,项目名称:service-opportunities,代码行数:37,代码来源:2014_08_01_065531_rename-partners-to-beneficiaries.php
示例4: downSQLite
public function downSQLite()
{
DB::statement('PRAGMA foreign_keys = OFF');
Schema::create('users_temp', function ($table) {
$table->engine = "InnoDB";
$table->increments('id');
$table->string('email')->unique();
$table->string('password', 100);
$table->string('fname');
$table->string('lname');
$table->string('phone')->nullable();
$table->integer('org_id')->unsigned()->nullable();
$table->string('position')->nullable();
$table->string('location')->nullable();
$table->string('url')->nullable();
$table->string('token', 25);
$table->text('likes')->nullable();
$table->text('dislikes')->nullable();
$table->text('flags')->nullable();
$table->timestamp('last_login')->nullable();
$table->timestamps();
//Set foreign keys
$table->foreign('org_id')->references('id')->on('organizations')->on_delete('set null');
});
DB::statement('INSERT INTO `users_temp` (`id`, `email`, `password`, `fname`, `lname`, `phone`, `org_id`, `position`, `location`, `url`, `token`, `likes`, `dislikes`, `flags`, `last_login`, `created_at`, `updated_at`) SELECT `id`, `email`, `password`, `fname`, `lname`, `phone`, `org_id`, `position`, `location`, `url`, `token`, `likes`, `dislikes`, `flags`, `last_login`, `created_at`, `updated_at` FROM `users`');
Schema::drop('users');
Schema::rename('users_temp', 'users');
DB::statement('PRAGMA foreign_keys = ON');
}
示例5: downSQLite
public function downSQLite()
{
DB::statement('PRAGMA foreign_keys = OFF');
Schema::create('annotations_temp', function ($table) {
$table->engine = "InnoDB";
$table->increments('id');
$table->string('search_id');
$table->integer('user_id')->unsigned();
$table->integer('doc')->unsigned();
$table->string('quote');
$table->string('text');
$table->string('uri');
$table->integer('likes');
$table->integer('dislikes');
$table->integer('flags');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('doc')->references('id')->on('docs');
$table->unique('search_id');
});
DB::statement('INSERT INTO `annotations_temp` (`id`, `search_id`, `user_id`, `doc`, `quote`, `text`, `uri`, `created_at`, `updated_at`) SELECT `id`, `search_id`, `user_id`, `doc`, `quote`, `text`, `uri`, `created_at`, `updated_at` FROM `annotations`');
Schema::drop('annotations');
Schema::rename('annotations_temp', 'annotations');
DB::statement('PRAGMA foreign_keys = ON');
}
示例6: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::rename('redirecturls', 'promourls');
Schema::table('promourls', function ($table) {
$table->dropColumn('redirect_type');
});
}
示例7: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::rename('farmacia.asos', 'farmacia_asos');
DB::statement('alter table farmacia.farmacia_asos set schema public');
Schema::table('farmacia_asos', function (Blueprint $table) {
$table->dropColumn('ficha_id');
});
}
示例8: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('sessions', function (Blueprint $table) {
$table->renameColumn('begin', 'time');
$table->dropColumn('end');
});
Schema::rename('session_speaker', 'speaker_session');
}
示例9: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('dropboxes', function ($table) {
$table->renameColumn('dropbox_id', 'user_id');
$table->renameColumn('dropbox_token', 'token');
});
Schema::rename('dropboxes', 'trees');
}
开发者ID:andrewpurkett,项目名称:demo-dropbox-rest-service,代码行数:13,代码来源:2014_01_28_173317_rename_trees_table_to_dropboxes.php
示例10: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::rename('setting_translateables', 'setting_translatables');
Schema::rename('setting_translateable_translations', 'setting_translatable_translations');
Schema::table('setting_translatable_translations', function (Blueprint $table) {
$table->renameColumn('setting_translateable_id', 'setting_translatable_id');
});
}
示例11: renameTables
/**
* Rename tables.
*
* @return void
*/
private function renameTables()
{
foreach ($this->renameTables as $table) {
Schema::rename($table, str_replace('rpm_', '', $table));
}
Schema::rename('rentals', 'properties');
Schema::rename('rental_utilities', 'property_utilities');
}
示例12: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::rename('images', 'files');
Schema::table('files', function (Blueprint $table) {
$table->dropColumn('size');
$table->enum('type', ['doc', 'image', 'pdf']);
});
}
示例13: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::rename('statements', 'credit_card_dates');
Schema::table('credit_card_dates', function (Blueprint $table) {
$table->drop('has_real_dates');
$table->drop('period');
});
}
示例14: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::rename('categories_products', 'product_categories');
Schema::table('product_categories', function (Blueprint $table) {
$table->renameColumn('products_id', 'product_id');
$table->renameColumn('categories_id', 'category_id');
});
}
开发者ID:rondarby,项目名称:laracomm,代码行数:13,代码来源:2015_08_13_120934_rename_product_categories_pivot_table.php
示例15: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('anime_favorites');
if (Schema::hasTable('lastwatched_anime')) {
if (Schema::hasColumn('lastwatched_anime', 'created_at')) {
Schema::table('lastwatched_anime', function ($table) {
$table->dropColumn('created_at');
});
}
if (!Schema::hasColumn('lastwatched_anime', 'last_watched_episode')) {
if (Schema::hasColumn('lastwatched_anime', 'episode')) {
Schema::table('lastwatched_anime', function ($table) {
$table->renameColumn('episode', 'last_watched_episode')->nullable()->default(null);
});
} else {
Schema::table('lastwatched_anime', function ($table) {
$table->string('last_watched_episode', 11)->nullable();
});
}
}
if (!Schema::hasColumn('lastwatched_anime', 'last_watched_time')) {
if (Schema::hasColumn('lastwatched_anime', 'updated_at')) {
Schema::table('lastwatched_anime', function ($table) {
$table->renameColumn('updated_at', 'last_watched_time')->nullable()->default(null);
});
} else {
Schema::table('lastwatched_anime', function ($table) {
$table->timestamp('last_watched_time')->nullable();
});
}
}
if (!Schema::hasColumn('lastwatched_anime', 'is_fav')) {
Schema::table('lastwatched_anime', function ($table) {
$table->tinyInteger('library_status')->default(0);
});
}
if (!Schema::hasColumn('lastwatched_anime', 'library_status')) {
Schema::table('lastwatched_anime', function ($table) {
$table->tinyInteger('library_status')->default(0);
});
}
Schema::rename('lastwatched_anime', 'user_anime_library');
Schema::table('user_anime_library', function ($table) {
$table->timestamps();
});
} else {
Schema::create('user_anime_library', function ($table) {
$table->increments('id');
$table->integer('user_id');
$table->integer('anime_id');
$table->boolean('is_fav')->default(false);
$table->tinyInteger('library_status')->default(0);
$table->string('last_watched_episode', 11)->nullable()->default(null);
$table->timestamp('last_watched_time')->nullable()->default(null);
$table->timestamps();
});
}
}