<?php namespace jasonwilliams\feed\Updates;

use Schema;
use October\Rain\Database\Updates\Migration;

class JasonwilliamsFeedInitialSetup extends Migration
{
    public function up()
    {
        Schema::create('jasonwilliams_feed_', function($table)
        {
            $table->engine = 'InnoDB';
            $table->increments('id')->unsigned();
            $table->integer('timestamp')->unsigned();
            $table->integer('channel_id')->unsigned();
            $table->string('title', 512)->nullable();
            $table->string('link', 256)->nullable();
            $table->text('body')->nullable();
            $table->text('extra');
        });

        Schema::create('jasonwilliams_feed_tags', function($table)
        {
            $table->engine = 'InnoDB';
            $table->increments('id')->unsigned();
            $table->string('tag', 128);
            $table->integer('feed_item_id')->unsigned();
        });

        Schema::create('jasonwilliams_feed_links', function($table)
        {
            $table->engine = 'InnoDB';
            $table->increments('id')->unsigned();
            $table->string('addr', 256);
            $table->string('display', 256);
            $table->integer('feed_item_id')->unsigned();
        });

        Schema::create('jasonwilliams_feed_channels', function($table)
        {
            $table->engine = 'InnoDB';
            $table->increments('id')->unsigned();
            $table->string('title', 64);
            $table->string('slug', 64);
            $table->string('icon', 128)->nullable();
            $table->string('colour', 7)->nullable();
        });
    }

    public function down()
    {
        Schema::dropIfExists('jasonwilliams_feed_');
        Schema::dropIfExists('jasonwilliams_feed_tags');
        Schema::dropIfExists('jasonwilliams_feed_links');
        Schema::dropIfExists('jasonwilliams_feed_channels');
    }
}