CreateReleasesTable::up()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 22

Duplication

Lines 10
Ratio 31.25 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 32
rs 8.8571
cc 1
eloc 22
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 CreateReleasesTable extends Migration {
11
12
    /**
13
     * Migration
14
     */
15
    public function up()
16
    {
17
        DB::transaction(function() {
18 View Code Duplication
            Schema::create('cosmicradiotv_podcast_release_types', function (Blueprint $table) {
19
                $table->engine = 'InnoDB';
20
                $table->increments('id');
21
                $table->string('name');
22
                $table->string('slug');
23
                $table->string('type');
24
                $table->string('filetype');
25
26
                $table->unique('slug');
27
            });
28
29
            Schema::create('cosmicradiotv_podcast_releases', function (Blueprint $table) {
30
                $table->engine = 'InnoDB';
31
                $table->increments('id');
32
                $table->unsignedInteger('episode_id');
33
                $table->unsignedInteger('release_type_id');
34
                $table->text('url');
35
                $table->bigInteger('size');
36
                $table->timestamps();
37
38
                $table->foreign('episode_id')->references('id')->on('cosmicradiotv_podcast_episodes')
39
                      ->onUpdate('cascade');
40
                $table->foreign('release_type_id')->references('id')->on('cosmicradiotv_podcast_release_types')
41
                      ->onUpdate('cascade');
42
43
            });
44
        });
45
46
    }
47
48
    /**
49
     * Rollback
50
     */
51
    public function down()
52
    {
53
        DB::transaction(function () {
54
            Schema::drop('cosmicradiotv_podcast_releases');
55
            Schema::drop('cosmicradiotv_podcast_release_types');
56
        });
57
    }
58
}