“Laravel Drop -Säule” Code-Antworten

Laravel -Migration entfernen Säule

public function up()
{
  Schema::table('table', function($table) {
    $table->dropColumn('column_name');
  });
}
Faithful Fish

Laravel Fremdschlüssel

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
OR
Schema::table('posts', function (Blueprint $table) {
    $table->foreignId('user_id')->constrained();
});
Courageous Cod

Laravel -Migration eindeutige Säule hinzufügen

Schema::table('tableName', function($table)
{
    $table->string('column-name')->unique(); //notice the parenthesis I added
});
Sore Seal

Laravel vor der Migration

Schema::table('users', function ($table) {
    $table->string('email')->after('id')->nullable();
});
Courageous Cod

Laravel Drop -Säule

// To drop a column, use the dropColumn method on the schema builder.
// Before dropping columns from a SQLite database, you will need to add
// the doctrine/dbal dependency to your composer.json file and run the
// composer update command in your terminal to install the library:

Schema::table('users', function (Blueprint $table) {
    $table->dropColumn('votes');
});
Yingfufu

Drop -Säulenmigration Laravel

 Class RemoveCommentViewCount extends Migration
  {
      public function up()
      {
          Schema::table('articles', function($table) {
             $table->dropColumn('comment_count');
             $table->dropColumn('view_count');
          });
      }

      public function down()
      {
          Schema::table('articles', function($table) {
             $table->integer('comment_count');
             $table->integer('view_count');
          });
      }
  }
Lazy Book

Ähnliche Antworten wie “Laravel Drop -Säule”

Fragen ähnlich wie “Laravel Drop -Säule”

Weitere verwandte Antworten zu “Laravel Drop -Säule” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen