<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

class AddTickedCodeToOffer extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {

        DB::statement("
            ALTER TABLE `offer`
            ADD COLUMN `ticket_code` varchar(10) NOT NULL AFTER `property_id`,
            MODIFY COLUMN `offer_code` varchar(50)  NOT NULL AFTER `ticket_code`;
        ");

        DB::statement("
            UPDATE `offer` SET
            ticket_code =  CONCAT_WS('', 'TCK', id);
        ");

        DB::statement("
            ALTER TABLE `offer`
            ADD UNIQUE INDEX(`ticket_code`)
        ");



    }


}
