当前位置: 首页>>代码示例>>PHP>>正文


PHP Schema::rename方法代码示例

本文整理汇总了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);
 }
开发者ID:joshreisner,项目名称:avalon,代码行数:28,代码来源:ObjectController.php

示例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');
     });
 }
开发者ID:elazar,项目名称:symposium,代码行数:37,代码来源:2015_05_24_113910_drop_versions.php

示例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');
 }
开发者ID:iaincollins,项目名称:madison,代码行数:29,代码来源:2014_07_01_181718_drop_unused_user_fields.php

示例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');
 }
开发者ID:krues8dr,项目名称:madison,代码行数:25,代码来源:2014_03_18_071119_drop_annotation_meta_columns.php

示例6: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::rename('redirecturls', 'promourls');
     Schema::table('promourls', function ($table) {
         $table->dropColumn('redirect_type');
     });
 }
开发者ID:coandacms,项目名称:coanda-core,代码行数:12,代码来源:2014_09_02_135343_rename_promo_url_table.php

示例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');
     });
 }
开发者ID:kuell,项目名称:buriti,代码行数:13,代码来源:2015_07_22_123255_alter_farmacia_asos_add_ficha_id.php

示例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');
 }
开发者ID:konato-events,项目名称:web,代码行数:13,代码来源:2015_12_05_034647_fix_session_fields.php

示例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');
     });
 }
开发者ID:manogi,项目名称:gfw-qm,代码行数:13,代码来源:2015_09_22_122128_rename_setting_translatable.php

示例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');
 }
开发者ID:paulboco,项目名称:laravel,代码行数:13,代码来源:2016_01_18_000000_import_shiphed_database.php

示例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']);
     });
 }
开发者ID:philsquare,项目名称:laramanager,代码行数:13,代码来源:2016_03_01_162651_update_files_to_images.php

示例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');
     });
 }
开发者ID:daninoz,项目名称:kontas-server,代码行数:13,代码来源:2016_01_10_233059_create_statements_table.php

示例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();
         });
     }
 }
开发者ID:shaikhatik0786,项目名称:Masteranime,代码行数:63,代码来源:2014_08_11_194536_user_anime_library.php


注:本文中的Schema::rename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。