CreateEpisodesTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 9.2
cc 1
eloc 17
nc 1
nop 0
1
<?php
2
3
namespace CosmicRadioTV\Podcast\updates;
4
5
use DB;
6
use Illuminate\Database\Schema\Blueprint;
7
use October\Rain\Database\Updates\Migration;
8
use Schema;
9
10
class CreateEpisodesTable extends Migration
11
{
12
13
    /**
14
     * Migration
15
     */
16
    public function up()
17
    {
18
        DB::transaction(function () {
19
            Schema::create('cosmicradiotv_podcast_episodes', function (Blueprint $table) {
20
                $table->engine = 'InnoDB';
21
                $table->increments('id');
22
                $table->unsignedInteger('show_id');
23
                $table->string('title');
24
                $table->string('slug');
25
                $table->text('summary')->nullable();
26
                $table->text('content')->nullable();
27
                $table->integer('length');
28
                $table->dateTime('release')->nullable();
29
                $table->boolean('published')->default(false);
30
                $table->timestamps();
31
32
                $table->foreign('show_id')->references('id')->on('cosmicradiotv_podcast_shows')
33
                      ->onUpdate('cascade');
34
                $table->unique(['show_id', 'slug']);
35
            });
36
        });
37
    }
38
39
    /**
40
     * Rollback
41
     */
42
    public function down()
43
    {
44
        DB::transaction(function () {
45
            Schema::drop('cosmicradiotv_podcast_episodes');
46
        });
47
    }
48
}