<?php

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

class CreateMediasTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('medias', function (Blueprint $table) {
            $table->id();
            $table->string('code_ecu', 20);
            $table->unsignedBigInteger('chap_id');
            $table->longText('sequences');
            $table->string('titre');
            $table->text('description');
            $table->string('miniature')->nullable();
            $table->string('ext', 10);
            $table->string('url');
            $table->time('duree_video');
            $table->integer('ordre')->length(5);
            $table->tinyInteger('is_live')->length(1)->default(0);
            $table->tinyInteger('downloadable')->length(1)->default(0);
            $table->enum('statut', ['PUBLISHED','PENDING','DELETED','SIGNALED'])->default('PUBLISHED');
            $table->timestamp('published_at');
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('medias');
    }
}
