I want to move timestamps columns to a specific location. Let’s pretend I already have an app running on a production server with the following schema:
ORDERS
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
So after a few days, I added the following columns:
$table->foreignId('user_id')->constrained('users');
$table->foreignId('address_id')->constrained('user_addresses');
$table->string('payment_method')->nullable();
$table->string('payment_status')->default('pending');
$table->string('order_status')->default('in_cart');
$table->text('note')->nullable();
$table->decimal('total', 8, 2)->default(0);
$table->string('waybill')->nullable();
$table->string('logistic')->nullable();
$table->dateTime('payment_at')->nullable();
The problem here is that all these columns are added after timestamps, but I don’t want to add them after timestamps. I want to add them between id and timestamps. Also, I don’t want to lose already created timestamps.