<?php 
/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
?>
<?php

use yii\db\Migration;

/**
 * Handles the creation of table `{{%booking}}`.
 */
class m240206_183800_create_booking_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('{{%booking}}', [
            'id' => $this->primaryKey(),
            'vehicle_id' => $this->integer()->notNull(),
            'booking_date' => $this->date()->notNull(),
            'start_date' => $this->date()->notNull(),
            'end_date' => $this->date()->notNull(),
            'total_days' => $this->integer(),
            'rate' => $this->decimal(20,2),
            'total_amount' => $this->decimal(20,2),
            'status' => $this->integer()

        ]);

        // creates index for column `vehicle_id`
        $this->createIndex(
            '{{%idx-booking-vehicle_id}}',
            '{{%booking}}',
            'vehicle_id'
        );

        // add foreign key for table `{{%booking}}`
        $this->addForeignKey(
            '{{%fk-booking-vehicle_id}}',
            '{{%booking}}',
            'vehicle_id',
            '{{%vehicle}}',
            'id',
            'CASCADE'
        );
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%booking}}');
    }
}
