Schema::create('table', function($table)
{
$table->increments('id');
});
// Specify a ConnectionSchema::connection('foo')->create('table', function($table){});
Schema::rename($from, $to);
Schema::drop('table');
Schema::dropIfExists('table');
Schema::hasTable('table');
Schema::hasColumn('table', 'column');
// Update an existing tableSchema::table('table', function($table){});
// Renaming 'enum' column types is not supported$table->renameColumn('from', 'to');
$table->dropColumn(string|array);
$table->dropSoftDeletes();
$table->dropTimestamps();
$table->engine = 'InnoDB';
// Only work on MySQL$table->string('name')->after('email');
Indexes
$table->string('column')->unique();
$table->primary('column');
// Creates a dual primary key$table->primary(['first', 'last']);
$table->unique('column');
$table->unique('column', 'key_name');
// Creates a dual unique index$table->unique(['first', 'last']);
$table->unique(['first', 'last'], 'key_name');
$table->index('column');
$table->index('column', 'key_name');
// Creates a dual index$table->index(['first', 'last']);
$table->index(['first', 'last'], 'key_name');
$table->dropPrimary('table_column_primary');
$table->dropUnique('table_column_unique');
$table->dropIndex('table_column_index');
Foreign Keys
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->dropForeign('posts_user_id_foreign');
Column Types
$table->increments('id');
$table->bigIncrements('id');
$table->string('email');
$table->string('name', 100);
$table->text('description');
$table->mediumText('description');
$table->longText('description');
$table->tinyInteger('numbers');
$table->smallInteger('numbers');
$table->mediumInteger('numbers');
$table->integer('numbers');
$table->bigInteger('numbers');
$table->float('amount');
$table->double('column', 15, 8);
$table->decimal('amount', 5, 2);
$table->date('created_at');
$table->dateTime('created_at');
$table->time('sunrise');
$table->timestamp('added_on');
// Adds 'created_at' and 'updated_at' columns$table->timestamps();
$table->nullableTimestamps();
$table->boolean('confirmed');
// Adds 'deleted_at' column for soft deletes$table->softDeletes();
$table->binary('data');
$table->enum('choices', ['foo', 'bar']);
// Adds INTEGER 'parent_id' and STRING 'parent_type'$table->morphs('parent');
->nullable()
->default($value)
->unsigned()
No comments:
Post a Comment