CreateMovieEarningsTable::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 6
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
3
use Illuminate\Database\Schema\Blueprint;
4
use Illuminate\Database\Migrations\Migration;
5
6
class CreateMovieEarningsTable extends Migration {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
8
	/**
9
	 * Run the migrations.
10
	 *
11
	 * @return void
12
	 */
13 9
	public function up() {
14
		DB::transaction(function () {
15
			Schema::create('movie_earnings', function (Blueprint $table) {
16 9
				$table->increments('id');
17 9
				$table->unsignedInteger('movie_id');
18 9
				$table->date('date');
19 9
				$table->unsignedBigInteger('domestic')->nullable();
20 9
				$table->unsignedBigInteger('worldwide')->nullable();
21 9
				$table->timestamps();
22
23 9
				$table->foreign('movie_id')->references('id')->on('movies')->onUpdate('cascade')->onDelete('cascade');
24 9
			});
25
26
			Schema::table('movies', function (Blueprint $table) {
27 9
				$table->foreign('latest_earnings_id')->references('id')->on('movie_earnings')->onUpdate('set null')
28 9
				      ->onDelete('cascade');
29 9
			});
30
31 9
		});
32 9
	}
33
34
	/**
35
	 * Reverse the migrations.
36
	 *
37
	 * @return void
38
	 */
39
	public function down() {
40
		DB::transaction(function () {
41
			Schema::table('movies', function (Blueprint $table) {
42
				$table->dropForeign('movies_latest_earnings_id_foreign');
43
			});
44
45
			Schema::drop('movie_earnings');
46
		});
47
	}
48
49
}
50