Skip to content
This repository was archived by the owner on Jan 1, 2021. It is now read-only.

Commit 8f9185f

Browse files
committedJun 8, 2017
Added DB Migrations
1 parent aa5faf2 commit 8f9185f

10 files changed

+758
-7
lines changed
 

‎app/Providers/AppServiceProvider.php

+4
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,9 @@ public function boot()
2424
public function register()
2525
{
2626
//
27+
if ($this->app->environment() == 'local') {
28+
$this->app->register(\Way\Generators\GeneratorsServiceProvider::class);
29+
$this->app->register(\Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class);
30+
}
2731
}
2832
}

‎composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"filp/whoops": "^2.1",
1919
"fzaninotto/faker": "~1.4",
2020
"mockery/mockery": "0.9.*",
21-
"phpunit/phpunit": "~5.7"
21+
"phpunit/phpunit": "~5.7",
22+
"xethron/migrations-generator": "^2.0"
2223
},
2324
"autoload": {
2425
"classmap": [

‎composer.lock

+507-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class CreateEventsTable extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::connection('mappings_mysql')->create('events', function(Blueprint $table)
16+
{
17+
$table->increments('id');
18+
$table->integer('type')->unsigned();
19+
$table->integer('mappings_id')->unsigned()->index('FK_mappings_events');
20+
$table->timestamp('date')->default(DB::raw('CURRENT_TIMESTAMP'));
21+
});
22+
}
23+
24+
25+
/**
26+
* Reverse the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function down()
31+
{
32+
Schema::connection('mappings_mysql')->drop('events');
33+
}
34+
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class CreateIpAdressesTable extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::connection('mappings_mysql')->create('ip_adresses', function(Blueprint $table)
16+
{
17+
$table->increments('id');
18+
$table->string('ip', 32)->default('');
19+
$table->integer('mappingsid')->unsigned()->index('FK_mappingsid_ip');
20+
});
21+
}
22+
23+
24+
/**
25+
* Reverse the migrations.
26+
*
27+
* @return void
28+
*/
29+
public function down()
30+
{
31+
Schema::connection('mappings_mysql')->drop('ip_adresses');
32+
}
33+
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class CreateMappingsTable extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::connection('mappings_mysql')->create('mappings', function(Blueprint $table)
16+
{
17+
$table->increments('id');
18+
$table->integer('tmdbid');
19+
$table->string('imdbid', 9)->default('');
20+
$table->integer('report_count')->default(1);
21+
$table->boolean('locked')->default(0);
22+
$table->integer('total_reports')->default(1);
23+
$table->string('mapable_type', 20)->default('');
24+
$table->integer('mapable_id')->unsigned();
25+
});
26+
}
27+
28+
29+
/**
30+
* Reverse the migrations.
31+
*
32+
* @return void
33+
*/
34+
public function down()
35+
{
36+
Schema::connection('mappings_mysql')->drop('mappings');
37+
}
38+
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class CreateTitleMappingsTable extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::connection('mappings_mysql')->create('title_mappings', function(Blueprint $table)
16+
{
17+
$table->increments('id');
18+
$table->text('aka_title', 65535);
19+
$table->text('aka_clean_title', 65535);
20+
});
21+
}
22+
23+
24+
/**
25+
* Reverse the migrations.
26+
*
27+
* @return void
28+
*/
29+
public function down()
30+
{
31+
Schema::connection('mappings_mysql')->drop('title_mappings');
32+
}
33+
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class CreateYearMappingsTable extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::connection('mappings_mysql')->create('year_mappings', function(Blueprint $table)
16+
{
17+
$table->increments('id');
18+
$table->smallInteger('aka_year');
19+
});
20+
}
21+
22+
23+
/**
24+
* Reverse the migrations.
25+
*
26+
* @return void
27+
*/
28+
public function down()
29+
{
30+
Schema::connection('mappings_mysql')->drop('year_mappings');
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class AddForeignKeysToEventsTable extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::connection('mappings_mysql')->table('events', function(Blueprint $table)
16+
{
17+
$table->foreign('mappings_id', 'FK_mappings_events')->references('id')->on('mappings')->onUpdate('CASCADE')->onDelete('CASCADE');
18+
});
19+
}
20+
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
Schema::connection('mappings_mysql')->table('events', function(Blueprint $table)
30+
{
31+
$table->dropForeign('FK_mappings_events');
32+
});
33+
}
34+
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class AddForeignKeysToIpAdressesTable extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::connection('mappings_mysql')->table('ip_adresses', function(Blueprint $table)
16+
{
17+
$table->foreign('mappingsid', 'FK_mappingsid_ip')->references('id')->on('mappings')->onUpdate('CASCADE')->onDelete('CASCADE');
18+
});
19+
}
20+
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
Schema::connection('mappings_mysql')->table('ip_adresses', function(Blueprint $table)
30+
{
31+
$table->dropForeign('FK_mappingsid_ip');
32+
});
33+
}
34+
35+
}

0 commit comments

Comments
 (0)
This repository has been archived.