Answers for "laravel migration timestamp"

PHP
21

laravel foreign key

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();
});
Posted by: Guest on December-09-2020
4

mysql timestamp in laravel migration

$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
Posted by: Guest on August-04-2020
3

laravel migration integer

$table->bigInteger('votes');
Posted by: Guest on May-22-2020
0

on update current timestamp laravel migration

$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
Posted by: Guest on November-05-2021

Code answers related to "laravel migration timestamp"

Browse Popular Code Answers by Language