rename() public static méthode

Rename a table on the schema.
public static rename ( string $from, string $to ) : Illuminate\Database\Schema\Blueprint
$from string
$to string
Résultat Illuminate\Database\Schema\Blueprint
 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);
 }
 /**
  * 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');
     });
 }
 /**
  * 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');
     });
 }
 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');
 }
 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');
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::rename('redirecturls', 'promourls');
     Schema::table('promourls', function ($table) {
         $table->dropColumn('redirect_type');
     });
 }
 /**
  * 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');
     });
 }
 /**
  * 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');
 }
 /**
  * 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');
 }
 /**
  * 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');
     });
 }
 /**
  * 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');
 }
 /**
  * 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']);
     });
 }
 /**
  * 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');
     });
 }
 /**
  * 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');
     });
 }
 /**
  * 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();
         });
     }
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('farmacia.aso_exames', function (Blueprint $table) {
         $table->dropColumn('exame_id');
         $table->dropColumn('validade');
     });
     DB::statement('alter table farmacia.aso_exames set schema public');
     Schema::rename('aso_exames', 'farmacia_exames');
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('farmacia.ocorrencias', function (Blueprint $table) {
         $table->dropColumn('sesmt');
     });
     DB::statement('alter table farmacia.ocorrencias set schema public');
     DB::statement('alter table farmacia.ocorrencia_medicacaos set schema public');
     Schema::rename('ocorrencias', 'farmacia_ocorrencias');
     Schema::rename('ocorrencia_medicacaos', 'farmacia_ocorrencia_medicacaos');
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     //
     Schema::rename('datasources', 'data_sources');
     Schema::table('data_source_syncs', function ($table) {
         $table->renameColumn('datasource_id', 'data_source_id');
     });
     Schema::table('projects', function ($table) {
         $table->renameColumn('datasource_id', 'data_source_id');
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::create('tags_old', function ($table) {
         $table->integer('post_id');
         $table->string('tag');
         $table->unique(array('post_id', 'tag'));
     });
     DB::statement('INSERT INTO tags_old(`post_id`, `tag`) SELECT `post_id`, `tag` FROM tags');
     Schema::drop('tags');
     Schema::rename('tags_old', 'tags');
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::rename('images', 'imageables');
     Schema::table('imageables', function (Blueprint $table) {
         $table->renameColumn('resource_id', 'imageable_id');
         $table->renameColumn('resource_model', 'imageable_type');
         $table->renameColumn('original_image', 'file');
         $table->dropColumn('retina_factor');
         $table->dropColumn('image_type');
         $table->integer('orientation')->after('original_image');
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::drop('joint_permissions');
     Schema::rename('role_permissions', 'permissions');
     Schema::rename('entity_permissions', 'restrictions');
     // Delete the public role
     DB::table('roles')->where('system_name', '=', 'public')->delete();
     Schema::table('roles', function (Blueprint $table) {
         $table->dropColumn('system_name');
         $table->dropColumn('hidden');
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     // Undo the renaming of the tables
     Schema::rename('input_csvextract', 'csvextract');
     Schema::rename('input_xmlextract', 'xmlextract');
     Schema::rename('input_jsonextract', 'jsonextract');
     Schema::rename('input_shpextract', 'shpextract');
     Schema::rename('input_rdfmap', 'rdfmap');
     Schema::rename('input_sparqlload', 'sparqlload');
     Schema::rename('input_tdtpublish', 'tdtpublisher');
     Schema::rename('input_job', 'job');
     Schema::rename('input_graph', 'graphs');
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('activities', function (Blueprint $table) {
         $table->dropColumn('organizing_commitee');
     });
     Schema::table('committees_activities', function (Blueprint $table) {
         $table->renameColumn('activity_id', 'event_id');
     });
     Schema::rename('committees_activities', 'committees_events');
     Schema::table('activities_users', function (Blueprint $table) {
         $table->renameColumn('committees_activities_id', 'committees_events_id');
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     // Restore non-standard convention migration
     if (Schema::hasTable('user_password_reminders')) {
         Schema::rename('user_password_reminders', 'password_reminders');
     }
     if (Schema::hasTable('user_social')) {
         Schema::rename('user_social', 'users_social');
     }
     if (Schema::hasTable('user_meta')) {
         Schema::rename('user_meta', 'users_meta');
     }
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::rename('uploads', 'images');
     Schema::table('images', function (Blueprint $table) {
         $table->string('href');
         $table->string('href_thumb');
         $table->integer('imageable_id');
         $table->string('imageable_type');
         $table->integer('image_type_id');
         $table->dropColumn('path');
         $table->dropColumn('upload_type');
         $table->dropColumn('user_id');
     });
 }
 public function up()
 {
     Schema::create('table_should_not_appear_create');
     Schema::table('changing_table', function ($table) {
         // Changing stuff here
     });
     Schema::rename('renaming_table', 'new_name_table');
     Schema::drop('dropping_table');
     Schema::dropIfExists('dropping_table_if_exists');
     // Schema::drop('table_should_not_appear_single_line_comment');
     /*
     				Schema::drop('table_should_not_appear_multi_line_comment');
     */
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('product_lines', function (Blueprint $table) {
         $table->foreign('product_category_id')->references('id')->on('product_categories');
         $table->integer('product_category_id')->unsigned()->change();
     });
     Schema::table('products', function (Blueprint $table) {
         $table->renameColumn('product_catalog_id', 'product_category_id');
         $table->renameColumn('master_class', 'master_class_id');
     });
     Schema::table('products', function (Blueprint $table) {
         $table->foreign('product_category_id')->references('id')->on('product_categories');
         $table->integer('product_category_id')->unsigned()->change();
         $table->foreign('product_line_id')->references('id')->on('product_lines');
         $table->integer('product_line_id')->unsigned()->change();
         $table->foreign('master_class_id')->references('id')->on('master_classes');
         $table->integer('master_class_id')->unsigned()->change();
     });
     Schema::table('master_class_steps', function (Blueprint $table) {
         $table->foreign('master_class_id')->references('id')->on('master_classes');
         $table->integer('master_class_id')->unsigned()->change();
     });
     Schema::table('product_colors', function (Blueprint $table) {
         $table->foreign('product_id')->references('id')->on('products');
         $table->integer('product_id')->unsigned()->change();
     });
     Schema::table('product_reviews', function (Blueprint $table) {
         $table->foreign('product_id')->references('id')->on('products');
         $table->integer('product_id')->unsigned()->change();
     });
     Schema::table('course_program_items', function (Blueprint $table) {
         $table->foreign('course_id')->references('id')->on('courses');
         $table->integer('course_id')->unsigned()->change();
     });
     Schema::table('course_gallery_items', function (Blueprint $table) {
         $table->foreign('course_id')->references('id')->on('courses');
         $table->integer('course_id')->unsigned()->change();
     });
     Schema::rename('feedback_feedback_tag', 'review_review_tag');
     Schema::table('review_review_tag', function (Blueprint $table) {
         $table->renameColumn('feedback_id', 'review_id');
         $table->renameColumn('feedback_tag_id', 'review_tag_id');
     });
     Schema::table('review_review_tag', function (Blueprint $table) {
         $table->foreign('review_id')->references('id')->on('reviews');
         $table->integer('review_id')->unsigned()->change();
         $table->foreign('review_tag_id')->references('id')->on('review_tags');
         $table->integer('review_tag_id')->unsigned()->change();
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::rename('projects_taggables', 'taggables');
     Schema::rename('projects_categoryables', 'categorables');
     Schema::table('categorables', function ($table) {
         $table->renameColumn('project_category_id', 'category_id');
         $table->renameColumn('projects_categoryables_id', 'categorable_id');
         $table->renameColumn('projects_categoryables_type', 'categorable_type');
     });
     Schema::table('taggables', function ($table) {
         $table->renameColumn('project_tag_id', 'tag_id');
         $table->renameColumn('projects_taggable_id', 'taggable_id');
         $table->renameColumn('projects_taggable_type', 'taggable_type');
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::rename('farmacia_natureza_lesao', 'natureza_lesao');
     Schema::rename('farmacia_parte_corpo', 'parte_corpo');
     DB::statement('alter table natureza_lesao set schema farmacia');
     DB::statement('alter table parte_corpo set schema farmacia');
     Schema::table('sesmt.investigacaos', function (Blueprint $table) {
         $table->string('tipo_ocorrencia')->nullable();
         $table->string('classificacao')->nullable();
         $table->string('potencial_risco')->nullable();
         $table->string('probabilidade')->nullable();
         $table->date('data_acidente')->nullable();
         $table->time('horas_trabalhadas')->nullable();
         $table->string('local_acidente')->nullable();
         $table->string('tipo_lesao')->nullable();
         $table->boolean('houve_afastamento')->nullable();
         $table->integer('dias_afastamento')->nullable();
         $table->boolean('houve_instrucao_tarefa')->nullable();
         $table->boolean('ferramenta_boa_condicao')->nullable();
         $table->boolean('colaborador_reincidente')->nullable();
         $table->boolean('fez_treinamento_prevencionista')->nullable();
         $table->boolean('colaborador_usava_epi')->nullable();
         $table->boolean('colaborador_possui_ferias')->nullable();
         $table->boolean('fez_hora_extra')->nullable();
         $table->boolean('outros_colaboradores_tarefa')->nullable();
         $table->boolean('houve_instrucao_prevencionista')->nullable();
         $table->integer('natureza_lesao_id')->nullable();
         $table->boolean('parte_corpo_id')->nullable();
         $table->string('fator_potencial')->nullable();
         $table->string('rota_acidente')->nullable();
         $table->text('descricao_acidente')->nullable();
         $table->boolean('testemunhas')->nullable();
         $table->boolean('houve_remocao_especializada')->nullable();
         $table->string('local_assistencia_medica')->nullable();
         $table->time('horario_atendimento')->nullable();
         $table->string('cid')->nullable();
         $table->boolean('devera_afastar')->nullable();
         $table->boolean('qtde_dias')->nullable();
     });
     Schema::create('sesmt.investigacao_acoes', function (Blueprint $table) {
         $table->increments('id');
         $table->integer('investigacao_id');
         $table->text('acao');
         $table->string('quem');
         $table->date('quando');
         $table->string('status');
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::rename('users', 'users_sentry');
     Schema::create('users', function (Blueprint $table) {
         $table->increments('id');
         $table->string('email');
         $table->string('password');
         $table->text('permissions')->nullable();
         $table->timestamp('last_login')->nullable();
         $table->string('first_name')->nullable();
         $table->string('last_name')->nullable();
         $table->timestamps();
         $table->engine = 'InnoDB';
         $table->unique('email');
     });
 }