<?php

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

class CreateSongsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('songs', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title')->unique() ;
            $table->string('slug') ;
            $table->text('lyrics') ;
            $table->timestamps();
        });

        // Full Text Index (MySQL only, skipped for SQLite)
        if (config('database.default') !== 'sqlite') {
            DB::statement('ALTER TABLE songs ADD FULLTEXT fulltext_index (title,lyrics)');
        }
    }

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