1
database/.gitignore
vendored
Executable file
1
database/.gitignore
vendored
Executable file
@@ -0,0 +1 @@
|
||||
*.sqlite
|
||||
24
database/factories/ModelFactory.php
Executable file
24
database/factories/ModelFactory.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of your model factories. Model factories give
|
||||
| you a convenient way to create models for testing and seeding your
|
||||
| database. Just tell the factory how a default model should look.
|
||||
|
|
||||
*/
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
$factory->define(\App\Models\User::class, function (Faker\Generator $faker) {
|
||||
static $password;
|
||||
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'password' => $password ?: $password = bcrypt('secret'),
|
||||
'remember_token' => \Str::random(10),
|
||||
];
|
||||
});
|
||||
66
database/migrations/2013_12_06_201055_create_titles.php
Executable file
66
database/migrations/2013_12_06_201055_create_titles.php
Executable file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateTitles extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('titles', function(Blueprint $table)
|
||||
{
|
||||
$table->bigIncrements('id')->unsigned();
|
||||
$table->string('title')->nullable();
|
||||
$table->string('type', 15)->default('movie');
|
||||
$table->string('imdb_rating', 10)->nullable();
|
||||
$table->decimal('tmdb_rating', 3, 1)->nullable();
|
||||
$table->string('mc_user_score', 10)->nullable();
|
||||
$table->smallInteger('mc_critic_score')->nullable()->unsigned();
|
||||
$table->integer('mc_num_of_votes')->nullable()->unsigned();
|
||||
$table->bigInteger('imdb_votes_num')->nullable()->unsigned();
|
||||
$table->string('release_date', 25)->nullable();
|
||||
$table->smallInteger('year')->nullable()->unsigned();
|
||||
$table->text('plot')->nullable();
|
||||
$table->string('genre')->nullable();
|
||||
$table->string('tagline')->nullable();
|
||||
$table->string('poster')->nullable();
|
||||
$table->string('background')->nullable();
|
||||
$table->string('awards')->nullable();
|
||||
$table->string('runtime')->nullable();
|
||||
$table->string('trailer')->nullable();
|
||||
$table->string('budget')->nullable();
|
||||
$table->string('revenue')->nullable()->index();
|
||||
$table->bigInteger('views')->default(1);
|
||||
$table->integer('tmdb_popularity')->unsigned()->nullable();
|
||||
$table->string('imdb_id')->nullable();
|
||||
$table->bigInteger('tmdb_id')->unsigned()->nullable();
|
||||
$table->tinyInteger('season_number')->nullable()->unsigned();
|
||||
$table->tinyInteger('fully_scraped')->default(0)->unsigned();
|
||||
$table->tinyInteger('allow_update')->default(1)->unsigned();
|
||||
$table->tinyInteger('featured')->default(0)->unsigned();
|
||||
$table->tinyInteger('now_playing')->default(0)->unsigned();
|
||||
$table->timestamps();
|
||||
$table->string('temp_id', 30)->nullable();
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
$table->engine = 'InnoDB';
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('titles');
|
||||
}
|
||||
|
||||
}
|
||||
51
database/migrations/2013_12_07_105031_create_actors.php
Executable file
51
database/migrations/2013_12_07_105031_create_actors.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateActors extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('actors', function(Blueprint $table)
|
||||
{
|
||||
$table->BigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->text('bio')->nullable();
|
||||
$table->string('sex', 10)->nullable();
|
||||
$table->string('full_bio_link', 255)->nullable();
|
||||
$table->string('birth_date', 255)->nullable();
|
||||
$table->string('birth_place', 255)->nullable();
|
||||
$table->string('awards', 255)->nullable();
|
||||
$table->string('image', 255)->nullable();
|
||||
$table->string('imdb_id', 255)->nullable();
|
||||
$table->bigInteger('views')->default(1);
|
||||
$table->bigInteger('tmdb_id')->unsigned()->nullable()->unique();
|
||||
$table->tinyInteger('fully_scraped')->default(0)->unsigned();
|
||||
$table->tinyInteger('allow_update')->default(1)->unsigned();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
$table->string('temp_id', 30)->nullable();
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
$table->engine = 'InnoDB';
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('actors');
|
||||
}
|
||||
|
||||
}
|
||||
38
database/migrations/2013_12_07_105130_create_options.php
Executable file
38
database/migrations/2013_12_07_105130_create_options.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateOptions extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('options', function(Blueprint $table)
|
||||
{
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('value');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('options');
|
||||
}
|
||||
|
||||
}
|
||||
42
database/migrations/2013_12_07_105216_create_actors_titles.php
Executable file
42
database/migrations/2013_12_07_105216_create_actors_titles.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateActorsTitles extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('actors_titles', function(Blueprint $table)
|
||||
{
|
||||
$table->Bigincrements('id');
|
||||
$table->bigInteger('actor_id')->unsigned();
|
||||
$table->bigInteger('title_id')->unsigned();
|
||||
$table->string('char_name')->default('Unknown');
|
||||
$table->tinyInteger('known_for')->default(0)->unsigned();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
|
||||
$table->unique(array('actor_id','title_id'), 'actor_title_unique');
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('actors_titles');
|
||||
}
|
||||
|
||||
}
|
||||
48
database/migrations/2013_12_07_105324_create_episodes.php
Executable file
48
database/migrations/2013_12_07_105324_create_episodes.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateEpisodes extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('episodes', function(Blueprint $table)
|
||||
{
|
||||
$table->BigIncrements('id');
|
||||
$table->string('title', 255);
|
||||
$table->text('plot')->nullable();
|
||||
$table->string('poster', 255)->nullable();
|
||||
$table->string('release_date', 255)->nullable();
|
||||
$table->bigInteger('title_id')->unsigned();
|
||||
$table->bigInteger('season_id')->unsigned();
|
||||
$table->integer('season_number')->default(1)->unsigned();
|
||||
$table->integer('episode_number')->default(1)->unsigned();
|
||||
$table->tinyInteger('allow_update')->default(1)->unsigned();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
$table->string('temp_id', 30)->nullable();
|
||||
|
||||
$table->unique(array('episode_number', 'season_number', 'title_id'), 'ep_s_title_unique');
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('episodes');
|
||||
}
|
||||
|
||||
}
|
||||
42
database/migrations/2013_12_07_105409_create_images.php
Executable file
42
database/migrations/2013_12_07_105409_create_images.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateImages extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('images', function(Blueprint $table)
|
||||
{
|
||||
$table->increments('id');
|
||||
$table->string('local')->nullable();
|
||||
$table->string('web')->nullable();
|
||||
$table->integer('title_id')->unsigned()->nullable();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
|
||||
$table->unique('local');
|
||||
$table->unique('web');
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('images');
|
||||
}
|
||||
|
||||
}
|
||||
43
database/migrations/2013_12_07_105420_create_news.php
Executable file
43
database/migrations/2013_12_07_105420_create_news.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateNews extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('news', function(Blueprint $table)
|
||||
{
|
||||
$table->BigIncrements('id');
|
||||
$table->string('title');
|
||||
$table->string('image')->nullable();
|
||||
$table->text('body')->nullable();
|
||||
$table->string('source')->nullable();
|
||||
$table->string('full_url')->nullable();
|
||||
$table->string('author')->nullable();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
$table->string('temp_id', 30)->nullable();
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('news');
|
||||
}
|
||||
|
||||
}
|
||||
42
database/migrations/2013_12_07_105432_create_reviews.php
Executable file
42
database/migrations/2013_12_07_105432_create_reviews.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateReviews extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('reviews', function(Blueprint $table)
|
||||
{
|
||||
$table->bigIncrements('id');
|
||||
$table->text('body')->nullable();
|
||||
$table->integer('score')->nullable()->index();
|
||||
$table->integer('title_id')->unsigned()->index();
|
||||
$table->integer('user_id')->unsigned()->index();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
|
||||
$table->unique(['title_id', 'user_id']);
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('reviews');
|
||||
}
|
||||
|
||||
}
|
||||
49
database/migrations/2013_12_07_105447_create_seasons.php
Executable file
49
database/migrations/2013_12_07_105447_create_seasons.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateSeasons extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('seasons', function(Blueprint $table)
|
||||
{
|
||||
$table->BigIncrements('id');
|
||||
$table->string('title')->nullable();
|
||||
$table->string('release_date')->nullable();
|
||||
$table->string('poster')->nullable();
|
||||
$table->text('overview')->nullable();
|
||||
$table->integer('number')->default(1);
|
||||
$table->bigInteger('title_id')->unsigned()->nullable();
|
||||
$table->string('title_imdb_id')->nullable();
|
||||
$table->bigInteger('title_tmdb_id')->unsigned()->nullable();
|
||||
$table->tinyInteger('fully_scraped')->default(0)->unsigned();
|
||||
$table->tinyInteger('allow_update')->default(1)->unsigned();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
$table->string('temp_id', 30)->nullable();
|
||||
|
||||
$table->unique(array('title_id','number'), 'tile_number_unique');
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('seasons');
|
||||
}
|
||||
|
||||
}
|
||||
44
database/migrations/2013_12_07_120703_create_throttle.php
Executable file
44
database/migrations/2013_12_07_120703_create_throttle.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateThrottle extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('throttle', function(Blueprint $table)
|
||||
{
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->string('ip_address')->nullable();
|
||||
$table->integer('attempts')->default(0);
|
||||
$table->boolean('suspended')->default(0);
|
||||
$table->boolean('banned')->default(0);
|
||||
$table->timestamp('last_attempt_at')->nullable();
|
||||
$table->timestamp('suspended_at')->nullable();
|
||||
$table->timestamp('banned_at')->nullable();
|
||||
|
||||
$table->index('user_id');
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('throttle');
|
||||
}
|
||||
|
||||
}
|
||||
44
database/migrations/2014_01_02_134303_add_columns_to_titles.php
Executable file
44
database/migrations/2014_01_02_134303_add_columns_to_titles.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddColumnsToTitles extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('titles', function($table)
|
||||
{
|
||||
$table->string('language')->nullable();
|
||||
$table->string('country')->nullable();
|
||||
$table->string('original_title')->nullable();
|
||||
$table->string('affiliate_link')->nullable();
|
||||
$table->string('custom_field')->nullable();
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('titles', function($table)
|
||||
{
|
||||
$table->dropColumn('language');
|
||||
$table->dropColumn('country');
|
||||
$table->dropColumn('original_title');
|
||||
$table->dropColumn('affiliate_link');
|
||||
$table->dropColumn('custom_field');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
31
database/migrations/2014_01_02_211657_add_columns_to_news.php
Executable file
31
database/migrations/2014_01_02_211657_add_columns_to_news.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddColumnsToNews extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('news', function($table)
|
||||
{
|
||||
$table->tinyInteger('fully_scraped')->default(0)->unsigned();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$table->dropColumn('fully_scraped');
|
||||
}
|
||||
|
||||
}
|
||||
31
database/migrations/2014_06_16_148413_add_type_to_images_table.php
Executable file
31
database/migrations/2014_06_16_148413_add_type_to_images_table.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddTypeToImagesTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('images', function($table)
|
||||
{
|
||||
$table->string('type', 50)->default('external');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$table->dropColumn('type');
|
||||
}
|
||||
|
||||
}
|
||||
31
database/migrations/2014_06_17_145413_add_type_to_reviews_table.php
Executable file
31
database/migrations/2014_06_17_145413_add_type_to_reviews_table.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddTypeToReviewsTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('reviews', function($table)
|
||||
{
|
||||
$table->string('type', 50)->default('critic');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$table->dropColumn('type');
|
||||
}
|
||||
|
||||
}
|
||||
46
database/migrations/2014_06_29_2101055_create_links.php
Executable file
46
database/migrations/2014_06_29_2101055_create_links.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateLinks extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('links', function(Blueprint $table)
|
||||
{
|
||||
$table->bigIncrements('id')->unsigned();
|
||||
$table->string('url');
|
||||
$table->string('type')->default('embed');
|
||||
$table->string('label')->nullable();
|
||||
$table->bigInteger('title_id')->unsigned()->nullable();
|
||||
$table->integer('season')->unsigned()->nullable();
|
||||
$table->integer('episode')->unsigned()->nullable();
|
||||
$table->integer('reports')->unsigned()->default(0);
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
$table->string('temp_id', 30)->nullable();
|
||||
|
||||
$table->unique('url');
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('links');
|
||||
}
|
||||
|
||||
}
|
||||
33
database/migrations/2014_10_13_211658_add_columns_to_users.php
Executable file
33
database/migrations/2014_10_13_211658_add_columns_to_users.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddColumnsToUsers extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('users', 'background')) return;
|
||||
|
||||
Schema::table('users', function($table)
|
||||
{
|
||||
$table->string('background')->nullable();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$table->dropColumn('background');
|
||||
}
|
||||
|
||||
}
|
||||
52
database/migrations/2014_10_30_132541_add_indexes.php
Executable file
52
database/migrations/2014_10_30_132541_add_indexes.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use Common\Database\Traits\AddsIndexToExistingTable;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class AddIndexes extends Migration
|
||||
{
|
||||
use AddsIndexToExistingTable;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('actors_titles', function (Blueprint $table) {
|
||||
$this->addIndexIfDoesNotExist($table, 'actor_id');
|
||||
$this->addIndexIfDoesNotExist($table, 'title_id');
|
||||
});
|
||||
|
||||
Schema::table('episodes', function ($table) {
|
||||
$this->addIndexIfDoesNotExist($table, 'season_id');
|
||||
$this->addIndexIfDoesNotExist($table, 'episode_number');
|
||||
$this->addIndexIfDoesNotExist($table, 'season_number');
|
||||
});
|
||||
|
||||
Schema::table('seasons', function ($table) {
|
||||
$this->addIndexIfDoesNotExist($table, 'title_id');
|
||||
$this->addIndexIfDoesNotExist($table, 'title_tmdb_id');
|
||||
});
|
||||
|
||||
Schema::table('reviews', function ($table) {
|
||||
$this->addIndexIfDoesNotExist($table, 'title_id');
|
||||
});
|
||||
|
||||
Schema::table('images', function ($table) {
|
||||
$this->addIndexIfDoesNotExist($table, 'title_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
35
database/migrations/2015_07_24_132662_add_new_columns_to_links_table.php
Executable file
35
database/migrations/2015_07_24_132662_add_new_columns_to_links_table.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddNewColumnsToLinksTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('links', function($table)
|
||||
{
|
||||
$table->integer('positive_votes')->default(0);
|
||||
$table->integer('negative_votes')->default(0);
|
||||
$table->string('quality')->default('SD');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$table->dropColumn('positive_votes');
|
||||
$table->dropColumn('negative_votes');
|
||||
$table->dropColumn('quality');
|
||||
}
|
||||
|
||||
}
|
||||
43
database/migrations/2015_10_03_123936_drop_legacy_v1_tables.php
Executable file
43
database/migrations/2015_10_03_123936_drop_legacy_v1_tables.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class DropLegacyV1Tables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::dropIfExists('groups');
|
||||
Schema::dropIfExists('social');
|
||||
Schema::dropIfExists('categories');
|
||||
Schema::dropIfExists('categorizables');
|
||||
Schema::dropIfExists('group_activity');
|
||||
Schema::dropIfExists('options');
|
||||
Schema::dropIfExists('reports');
|
||||
Schema::dropIfExists('slides');
|
||||
Schema::dropIfExists('users_groups');
|
||||
Schema::dropIfExists('users_titles');
|
||||
Schema::dropIfExists('users_activity');
|
||||
Schema::dropIfExists('writers_titles');
|
||||
Schema::dropIfExists('writers');
|
||||
Schema::dropIfExists('directors_titles');
|
||||
Schema::dropIfExists('directors');
|
||||
Schema::dropIfExists('news');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
31
database/migrations/2015_10_25_136541_add_indexes_to_titles_table.php
Executable file
31
database/migrations/2015_10_25_136541_add_indexes_to_titles_table.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddIndexesToTitlesTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('titles', function($table)
|
||||
{
|
||||
$table->index('created_at');
|
||||
$table->index('release_date');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
30
database/migrations/2017_03_20_136542_add_index_to_tmdb_popularity_field.php
Executable file
30
database/migrations/2017_03_20_136542_add_index_to_tmdb_popularity_field.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddIndexToTmdbPopularityField extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('titles', function($table)
|
||||
{
|
||||
$table->index('tmdb_popularity');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
48
database/migrations/2018_10_04_123935_create_videos_table.php
Executable file
48
database/migrations/2018_10_04_123935_create_videos_table.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVideosTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('videos', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('thumbnail')->nullable();
|
||||
$table->text('url');
|
||||
$table->string('type', 50);
|
||||
$table->string('quality', 50)->nullable();
|
||||
$table->integer('title_id')->unsigned()->index();
|
||||
$table->integer('season')->nullable()->unsigned()->index();
|
||||
$table->integer('episode')->nullable()->unsigned()->index();
|
||||
$table->string('source')->default('local')->index();
|
||||
$table->integer('negative_votes')->unsigned()->default(0);
|
||||
$table->integer('positive_votes')->unsigned()->default(0);
|
||||
$table->integer('reports')->unsigned()->default(0);
|
||||
$table->integer('approved')->unsigned()->default(1)->index();
|
||||
$table->integer('order')->unsigned()->default(0)->index();
|
||||
$table->timestamps();
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('videos');
|
||||
}
|
||||
}
|
||||
41
database/migrations/2018_10_04_125553_update_images_table_to_v2.php
Executable file
41
database/migrations/2018_10_04_125553_update_images_table_to_v2.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class UpdateImagesTableToV2 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('images', function (Blueprint $table) {
|
||||
$table->string('url')->nullable();
|
||||
$table->string('source')->default('local')->index();
|
||||
$table->integer('model_id')->index();
|
||||
$table->string('model_type', 50)->index();
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('images', function (Blueprint $table) {
|
||||
$table->dropColumn('url');
|
||||
$table->dropColumn('source');
|
||||
$table->dropColumn('model_id');
|
||||
$table->dropColumn('model_type');
|
||||
});
|
||||
}
|
||||
}
|
||||
76
database/migrations/2018_10_04_131546_update_titles_table_to_v2.php
Executable file
76
database/migrations/2018_10_04_131546_update_titles_table_to_v2.php
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class UpdateTitlesTableToV2 extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// fix doctrine "enum" column issue
|
||||
DB::getDoctrineSchemaManager()
|
||||
->getDatabasePlatform()
|
||||
->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('titles', function (Blueprint $table) {
|
||||
$table->integer('runtime')->unsigned()->nullable()->change();
|
||||
$table->bigInteger('budget')->unsigned()->nullable()->change();
|
||||
$table->bigInteger('revenue')->unsigned()->nullable()->change();
|
||||
$table->decimal('tmdb_rating', 3, 1)->default(null)->nullable()->change();
|
||||
$table->integer('tmdb_vote_count')->unsigned()->nullable();
|
||||
$table->integer('tmdb_popularity')->unsigned()->nullable()->change();
|
||||
$table->string('certification', 50)->nullable()->index();
|
||||
|
||||
$table->integer('episode_count')->unsigned()->nullable();
|
||||
$table->boolean('series_ended')->unsigned()->default(0);
|
||||
$table->boolean('is_series')->unsigned()->default(0);
|
||||
$table->decimal('local_vote_average', 3, 1)->unsigned()->nullable();
|
||||
|
||||
$table->dropColumn('awards');
|
||||
$table->dropColumn('mc_user_score');
|
||||
$table->dropColumn('mc_critic_score');
|
||||
$table->dropColumn('mc_num_of_votes');
|
||||
$table->dropColumn('imdb_rating');
|
||||
$table->dropColumn('imdb_votes_num');
|
||||
$table->dropColumn('featured');
|
||||
$table->dropColumn('now_playing');
|
||||
$table->dropColumn('custom_field');
|
||||
$table->dropColumn('temp_id');
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
|
||||
Schema::table('titles', function(Blueprint $table) {
|
||||
$prefix = DB::getTablePrefix();
|
||||
DB::statement("ALTER TABLE {$prefix}titles CHANGE background backdrop varchar(255) NULL");
|
||||
DB::statement("ALTER TABLE {$prefix}titles CHANGE plot description text NULL");
|
||||
DB::statement("ALTER TABLE {$prefix}titles CHANGE tmdb_rating tmdb_vote_average decimal(3,1) NULL");
|
||||
DB::statement("ALTER TABLE {$prefix}titles CHANGE season_number season_count integer unsigned NULL");
|
||||
DB::statement("ALTER TABLE {$prefix}titles CHANGE title name varchar(255) NULL");
|
||||
DB::statement("ALTER TABLE {$prefix}titles CHANGE fully_scraped fully_synced tinyint unsigned default 0");
|
||||
DB::statement("ALTER TABLE {$prefix}titles CHANGE tmdb_popularity popularity integer unsigned null");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('titles', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
30
database/migrations/2018_10_04_133231_rename_actors_table.php
Executable file
30
database/migrations/2018_10_04_133231_rename_actors_table.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RenameActorsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::rename('actors', 'people');
|
||||
Schema::rename('actors_titles', 'creditables');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::rename('people', 'actors');
|
||||
Schema::rename('creditables', 'actors_titles');
|
||||
}
|
||||
}
|
||||
44
database/migrations/2018_10_04_133350_rename_person_title_columns.php
Executable file
44
database/migrations/2018_10_04_133350_rename_person_title_columns.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RenamePersonTitleColumns extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('creditables', function (Blueprint $table) {
|
||||
$table->integer('order')->unsigned()->default(0)->index();
|
||||
$table->string('department', 100)->nullable();
|
||||
$table->string('job', 100)->nullable();
|
||||
$table->string('char_name')->nullable()->default(null)->change();
|
||||
$table->string('creditable_type', 50)->nullable()->index();
|
||||
|
||||
$table->dropColumn('known_for');
|
||||
$table->dropColumn('created_at');
|
||||
$table->dropColumn('updated_at');
|
||||
|
||||
$table->renameColumn('actor_id', 'person_id');
|
||||
$table->renameColumn('title_id', 'creditable_id');
|
||||
$table->dropIndex('actor_title_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('person_title', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
32
database/migrations/2018_10_04_133351_rename_char_name_to_creditable.php
Executable file
32
database/migrations/2018_10_04_133351_rename_char_name_to_creditable.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RenameCharNameToCreditable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('creditables', function (Blueprint $table) {
|
||||
$table->renameColumn('char_name', 'character');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('creditables', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
49
database/migrations/2018_10_05_103825_update_people_table_to_v2.php
Executable file
49
database/migrations/2018_10_05_103825_update_people_table_to_v2.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class UpdatePeopleTableToV2 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('people', function (Blueprint $table) {
|
||||
$table->renameColumn('sex', 'gender');
|
||||
$table->renameColumn('bio', 'description');
|
||||
$table->renameColumn('image', 'poster');
|
||||
|
||||
$table->dropColumn('awards');
|
||||
$table->dropColumn('fully_scraped');
|
||||
$table->dropColumn('temp_id');
|
||||
$table->dropColumn('full_bio_link');
|
||||
|
||||
$table->boolean('fully_synced');
|
||||
$table->string('known_for', 50)->nullable();
|
||||
$table->integer('popularity')->default(0)->index();
|
||||
$table->string('death_date')->nullable();
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('people', function (Blueprint $table) {
|
||||
$table->renameColumn('gender', 'sex');
|
||||
$table->renameColumn('description', 'bio');
|
||||
$table->renameColumn('poster', 'image');
|
||||
});
|
||||
}
|
||||
}
|
||||
40
database/migrations/2018_10_09_131127_create_lists_table.php
Executable file
40
database/migrations/2018_10_09_131127_create_lists_table.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateListsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('lists', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->integer('user_id')->unsgined()->index();
|
||||
$table->boolean('system')->unsgined()->index()->default(0);
|
||||
$table->boolean('public')->unsgined()->index()->default(0);
|
||||
$table->string('auto_update', 40)->nullable()->index();
|
||||
$table->timestamps();
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('lists');
|
||||
}
|
||||
}
|
||||
40
database/migrations/2018_10_09_131254_create_listables_table.php
Executable file
40
database/migrations/2018_10_09_131254_create_listables_table.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateListablesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('listables', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('list_id')->unsigned()->index();
|
||||
$table->integer('listable_id')->unsigned()->index();
|
||||
$table->string('listable_type', 80)->index();
|
||||
$table->integer('order')->unsigned()->default(0)->index();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
|
||||
$table->unique(['list_id', 'listable_id', 'listable_type']);
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('listables');
|
||||
}
|
||||
}
|
||||
46
database/migrations/2018_10_13_125603_update_episodes_table_to_v2.php
Executable file
46
database/migrations/2018_10_13_125603_update_episodes_table_to_v2.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class UpdateEpisodesTableToV2 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('episodes', function (Blueprint $table) {
|
||||
$table->string('release_date')->nullable()->change();
|
||||
$table->integer('tmdb_vote_count')->unsigned()->nullable();
|
||||
$table->decimal('tmdb_vote_average', 3, 1)->nullable();
|
||||
$table->decimal('local_vote_average', 3, 1)->nullable();
|
||||
$table->smallInteger('year')->unsigned()->nullable();
|
||||
$table->integer('popularity')->unsigned()->nullable()->index();
|
||||
$table->renameColumn('plot', 'description');
|
||||
$table->renameColumn('title', 'name');
|
||||
$table->index('title_id');
|
||||
|
||||
if (Schema::hasColumn('episodes', 'promo')) {
|
||||
$table->dropColumn('promo');
|
||||
$table->dropColumn('temp_id');
|
||||
}
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
42
database/migrations/2018_10_20_121154_update_seasons_to_v2.php
Executable file
42
database/migrations/2018_10_20_121154_update_seasons_to_v2.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class UpdateSeasonsToV2 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('seasons', function (Blueprint $table) {
|
||||
$table->dropColumn('title');
|
||||
$table->dropColumn('fully_scraped');
|
||||
$table->dropColumn('temp_id');
|
||||
$table->dropColumn('title_imdb_id');
|
||||
$table->dropColumn('overview');
|
||||
|
||||
$table->integer('episode_count')->unsgined();
|
||||
$table->tinyInteger('fully_synced')->unsigned()->default(0);
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('seasons', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateWatchlistForExistingUsers extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
User::with('watchlist')
|
||||
->chunkById(50, function (Collection $users) {
|
||||
$records = $users->filter(function(User $user) {
|
||||
return !$user->watchlist;
|
||||
})->map(function(User $user) {
|
||||
return [
|
||||
'name' => 'watchlist',
|
||||
'user_id' => $user->id,
|
||||
'system' => 1,
|
||||
'public' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
if ($records->isNotEmpty()) {
|
||||
DB::table('lists')->insert($records->toArray());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
36
database/migrations/2018_11_18_124914_update_reviews_table_to_v2.php
Executable file
36
database/migrations/2018_11_18_124914_update_reviews_table_to_v2.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateReviewsTableToV2 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('reviews', function (Blueprint $table) {
|
||||
$table->renameColumn('title_id', 'reviewable_id');
|
||||
$table->string('reviewable_type')->nullable()->index();
|
||||
if (Schema::hasColumn('reviews', 'temp_id')) {
|
||||
$table->dropColumn('temp_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('reviews', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
40
database/migrations/2018_12_07_144126_create_video_ratings_table.php
Executable file
40
database/migrations/2018_12_07_144126_create_video_ratings_table.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVideoRatingsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('video_ratings', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('rating', 20);
|
||||
$table->integer('user_id')->unsigned()->nullable()->index();
|
||||
$table->integer('video_id')->unsigned()->index();
|
||||
$table->string('user_ip', 20)->index();
|
||||
|
||||
$table->unique(['user_id', 'video_id']);
|
||||
$table->unique(['user_ip', 'video_id']);
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('video_ratings');
|
||||
}
|
||||
}
|
||||
127
database/migrations/2018_12_26_145237_migrate_legacy_titles_table_data_to_v2.php
Executable file
127
database/migrations/2018_12_26_145237_migrate_legacy_titles_table_data_to_v2.php
Executable file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Image;
|
||||
use App\Models\Title;
|
||||
use App\Models\Video;
|
||||
use Common\Tags\Tag;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class MigrateLegacyTitlesTableDataToV2 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
foreach (
|
||||
Title::withoutGlobalScope('adult')
|
||||
->with('seasons')
|
||||
->cursor()
|
||||
as $title
|
||||
) {
|
||||
$updatedTitleData = [
|
||||
'fully_synced' => false,
|
||||
'tmdb_vote_average' => $title->tmdb_vote_average ?: null,
|
||||
'budget' => $title->budget ?: null,
|
||||
'revenue' => $title->revenue ?: null,
|
||||
'imdb_id' => $title->imdb_id ?: null,
|
||||
'tmdb_id' => $title->tmdb_id ?: null,
|
||||
'release_date' => $title->getOriginal('release_date') ?: null,
|
||||
'is_series' => $title->getOriginal('type') === 'series' ? 1 : 0,
|
||||
'season_count' => $title->seasons->count(),
|
||||
];
|
||||
|
||||
// trailer
|
||||
if ($title->trailer) {
|
||||
try {
|
||||
app(Video::class)->create([
|
||||
'name' => $title->name . ' - Trailer',
|
||||
'url' => $title->trailer,
|
||||
'type' => 'embed',
|
||||
'source' => 'tmdb',
|
||||
'title_id' => $title->id,
|
||||
]);
|
||||
} catch (QueryException $e) {
|
||||
// catch video exists errors
|
||||
}
|
||||
}
|
||||
|
||||
// genres
|
||||
$legacyGenres = trim(str_replace(' ', '', $title->genre));
|
||||
if ($legacyGenres) {
|
||||
$separator = str_contains($legacyGenres, '|') ? '|' : ',';
|
||||
$genreNames = explode($separator, $legacyGenres);
|
||||
|
||||
$values = collect($genreNames)->map(function ($genreName) {
|
||||
$name = $this->getGenreName($genreName);
|
||||
return [
|
||||
'name' => $name,
|
||||
'display_name' => ucwords($name),
|
||||
'type' => 'genre',
|
||||
];
|
||||
});
|
||||
|
||||
$tags = app(Tag::class)->insertOrRetrieve($values);
|
||||
$title->genres()->syncWithoutDetaching($tags->pluck('id'));
|
||||
}
|
||||
|
||||
$updatedTitleData['genre'] = null;
|
||||
$title->fill($updatedTitleData)->save();
|
||||
}
|
||||
|
||||
// images
|
||||
$cursor = app(Image::class)
|
||||
->where('model_id', '<', 1)
|
||||
->cursor();
|
||||
|
||||
foreach ($cursor as $image) {
|
||||
$image->update([
|
||||
'model_type' => Title::class,
|
||||
'model_id' => $image->title_id,
|
||||
'url' => $image->web,
|
||||
'web' => null,
|
||||
'type' => $image->type === 'external' ? 'tmdb' : 'local',
|
||||
]);
|
||||
}
|
||||
|
||||
// cast
|
||||
DB::table('creditables')
|
||||
->whereNull('creditable_type')
|
||||
->update([
|
||||
'creditable_type' => Title::class,
|
||||
'department' => 'cast',
|
||||
'job' => 'cast',
|
||||
]);
|
||||
}
|
||||
|
||||
private function getGenreName($originalName)
|
||||
{
|
||||
$name = strtolower($originalName);
|
||||
if ($name === 'sciencefiction') {
|
||||
return 'science fiction';
|
||||
}
|
||||
if ($name === 'action&adventure') {
|
||||
return 'action & adventure';
|
||||
}
|
||||
if ($name === 'sci-fi&fantasy') {
|
||||
return 'sci-fi & fantasy';
|
||||
}
|
||||
if ($name === 'war&politics') {
|
||||
return 'war & politics';
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
53
database/migrations/2018_12_28_130817_MigrateLegacyLinksToVideosTable.php
Executable file
53
database/migrations/2018_12_28_130817_MigrateLegacyLinksToVideosTable.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Video;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class MigrateLegacyLinksToVideosTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::table('links')->orderBy('id')->chunk(50, function (Collection $links) {
|
||||
$videos = $links->map(function($link) {
|
||||
return [
|
||||
'name' => $link->label,
|
||||
'type' => $link->type,
|
||||
'url' => $link->url,
|
||||
'title_id' => $link->title_id,
|
||||
'season' => $link->season,
|
||||
'episode' => $link->episode,
|
||||
'reports' => $link->reports,
|
||||
'created_at' => $link->created_at,
|
||||
'updated_at' => $link->updated_at,
|
||||
'positive_votes' => $link->positive_votes,
|
||||
'negative_votes' => $link->negative_votes,
|
||||
'quality' => $link->quality,
|
||||
'approved' => $link->approved,
|
||||
'source' => 'local',
|
||||
];
|
||||
});
|
||||
|
||||
try {
|
||||
app(Video::class)->insert($videos->toArray());
|
||||
} catch (\Exception $e) {
|
||||
//
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
65
database/migrations/2018_12_29_145238_migrate_indexes_to_v2.php
Executable file
65
database/migrations/2018_12_29_145238_migrate_indexes_to_v2.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class MigrateIndexesToV2 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('titles', function (Blueprint $table) {
|
||||
$sm = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $sm->listTableIndexes('titles');
|
||||
|
||||
$table->unique(['tmdb_id', 'is_series']);
|
||||
|
||||
if (array_key_exists('titles_imdb_id_unique', $indexesFound)) {
|
||||
$table->dropUnique('titles_imdb_id_unique');
|
||||
}
|
||||
|
||||
if (array_key_exists('title', $indexesFound)) {
|
||||
$table->dropIndex('title');
|
||||
}
|
||||
|
||||
if (array_key_exists('titles_title_index', $indexesFound)) {
|
||||
$table->dropIndex('titles_title_index');
|
||||
}
|
||||
|
||||
if (array_key_exists('created_at', $indexesFound)) {
|
||||
$table->dropIndex('created_at');
|
||||
}
|
||||
|
||||
if (array_key_exists('type', $indexesFound)) {
|
||||
$table->dropUnique('type');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('people', function (Blueprint $table) {
|
||||
$sm = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $sm->listTableIndexes('people');
|
||||
|
||||
if (DB::table('people')->count() === 0) {
|
||||
$table->unique(['tmdb_id']);
|
||||
}
|
||||
|
||||
if (array_key_exists('actors_name_unique', $indexesFound)) {
|
||||
$table->dropUnique('actors_name_unique');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddShowVideoColumnToTitlesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('titles', function (Blueprint $table) {
|
||||
$table->boolean('show_videos')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('titles', function (Blueprint $table) {
|
||||
$table->dropColumn('show_videos');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddAdultColumnToTitlesAndPeople extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('titles', function(Blueprint $table)
|
||||
{
|
||||
$table->boolean('adult')->default(0);
|
||||
$table->index(['is_series', 'adult']);
|
||||
});
|
||||
|
||||
Schema::table('people', function(Blueprint $table)
|
||||
{
|
||||
$table->boolean('adult')->default(0);
|
||||
$table->index(['adult', 'popularity']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('people', function($table)
|
||||
{
|
||||
$table->dropColumn('adult');
|
||||
});
|
||||
|
||||
Schema::table('titles', function($table)
|
||||
{
|
||||
$table->dropColumn('adult');
|
||||
});
|
||||
}
|
||||
}
|
||||
32
database/migrations/2019_08_26_180056_add_order_column_to_images_table.php
Executable file
32
database/migrations/2019_08_26_180056_add_order_column_to_images_table.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddOrderColumnToImagesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('images', function (Blueprint $table) {
|
||||
$table->integer('order')->unsigned()->default(0)->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('images', function (Blueprint $table) {
|
||||
$table->dropColumn('order');
|
||||
});
|
||||
}
|
||||
}
|
||||
34
database/migrations/2019_08_28_162643_index_vote_columns_in_videos_table.php
Executable file
34
database/migrations/2019_08_28_162643_index_vote_columns_in_videos_table.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class IndexVoteColumnsInVideosTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->index('positive_votes');
|
||||
$table->index('negative_votes');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->dropIndex('positive_votes');
|
||||
$table->dropIndex('negative_votes');
|
||||
});
|
||||
}
|
||||
}
|
||||
32
database/migrations/2019_08_28_165028_add_user_id_to_videos_table.php
Executable file
32
database/migrations/2019_08_28_165028_add_user_id_to_videos_table.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddUserIdToVideosTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->integer('user_id')->nullable()->unsigned()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->dropColumn('user_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddLanguageColumnToVideosTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->string('language', 5)->default('en')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->dropColumn('language');
|
||||
});
|
||||
}
|
||||
}
|
||||
41
database/migrations/2019_08_29_180920_create_video_reports_table.php
Executable file
41
database/migrations/2019_08_29_180920_create_video_reports_table.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVideoReportsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('video_reports', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned()->nullable()->index();
|
||||
$table->integer('video_id')->unsigned()->index();
|
||||
$table->string('user_ip', 20)->index();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'video_id']);
|
||||
$table->unique(['user_ip', 'video_id']);
|
||||
|
||||
$table->collation = config('database.connections.mysql.collation');
|
||||
$table->charset = config('database.connections.mysql.charset');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('reports');
|
||||
}
|
||||
}
|
||||
40
database/migrations/2019_09_04_203002_create_video_captions_table.php
Executable file
40
database/migrations/2019_09_04_203002_create_video_captions_table.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVideoCaptionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('video_captions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name', 50);
|
||||
$table->string('language', 5)->index()->default('en');
|
||||
$table->uuid('hash')->unique();
|
||||
$table->string('url')->nullable();
|
||||
$table->integer('video_id')->unsigned()->index();
|
||||
$table->integer('user_id')->unsigned()->nullable()->index();
|
||||
$table->integer('order')->unsigned()->index()->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'video_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('video_captions');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddCategoryColumnToVideosTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->string('category', 20)->index()->default('trailer');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->dropColumn('category');
|
||||
});
|
||||
}
|
||||
}
|
||||
38
database/migrations/2020_05_10_174904_create_video_plays_table.php
Executable file
38
database/migrations/2020_05_10_174904_create_video_plays_table.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVideoPlaysTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('video_plays', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->index()->nullable();
|
||||
$table->integer('video_id')->index();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
|
||||
$table->string('platform', 30)->nullable()->index();
|
||||
$table->string('device', 30)->nullable()->index();
|
||||
$table->string('browser', 30)->nullable()->index();
|
||||
$table->string('location', 5)->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('video_plays');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddLocalVoteCountColumnToTitlesAndEpisodesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('titles', function (Blueprint $table) {
|
||||
$table->integer('local_vote_count')->default(0)->unsigned()->index();
|
||||
});
|
||||
|
||||
Schema::table('episodes', function (Blueprint $table) {
|
||||
$table->integer('local_vote_count')->default(0)->unsigned()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('titles', function (Blueprint $table) {
|
||||
$table->dropColumn('local_vote_count');
|
||||
});
|
||||
|
||||
Schema::table('episodes', function (Blueprint $table) {
|
||||
$table->dropColumn('local_vote_count');
|
||||
});
|
||||
}
|
||||
}
|
||||
46
database/migrations/2020_05_13_163817_hydrate_local_vote_count_column.php
Executable file
46
database/migrations/2020_05_13_163817_hydrate_local_vote_count_column.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Episode;
|
||||
use App\Models\Review;
|
||||
use App\Models\Title;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class HydrateLocalVoteCountColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Review::where('reviewable_type', Title::class)
|
||||
->select('reviewable_id', 'reviewable_type', DB::raw('count(*) as review_count'))
|
||||
->groupBy('reviewable_id')
|
||||
->chunk(500, function(Collection $counts) {
|
||||
$counts->each(function($count) {
|
||||
Title::where('id', $count['reviewable_id'])->update(['local_vote_count' => $count['review_count']]);
|
||||
});
|
||||
});
|
||||
|
||||
Review::where('reviewable_type', Episode::class)
|
||||
->select('reviewable_id', 'reviewable_type', DB::raw('count(*) as review_count'))
|
||||
->groupBy('reviewable_id')
|
||||
->chunk(500, function(Collection $counts) {
|
||||
$counts->each(function($count) {
|
||||
Episode::where('id', $count['reviewable_id'])->update(['local_vote_count' => $count['review_count']]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
39
database/migrations/2020_05_16_163120_add_billing_columns_to_users_table.php
Executable file
39
database/migrations/2020_05_16_163120_add_billing_columns_to_users_table.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddBillingColumnsToUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if ( ! Schema::hasColumn('users', 'card_brand')) {
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('card_brand', 30)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
if ( ! Schema::hasColumn('users', 'card_last_four')) {
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('card_last_four', 4)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
32
database/migrations/2020_07_19_163023_add_style_column_to_lists_table.php
Executable file
32
database/migrations/2020_07_19_163023_add_style_column_to_lists_table.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddStyleColumnToListsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('lists', function (Blueprint $table) {
|
||||
$table->string('style', 50)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('lists', function (Blueprint $table) {
|
||||
$table->dropColumn('style');
|
||||
});
|
||||
}
|
||||
}
|
||||
31
database/migrations/2021_08_18_150359_migrate_video_plays_table_to_v2.php
Executable file
31
database/migrations/2021_08_18_150359_migrate_video_plays_table_to_v2.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class MigrateVideoPlaysTableToV2 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('video_plays', function (Blueprint $table) {
|
||||
$table->float('time_watched')->unsigned()->nullable()->index();
|
||||
$table->string('ip', 30)->index()->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
30
database/migrations/2021_08_21_165826_add_imge_column_to_lists_table.php
Executable file
30
database/migrations/2021_08_21_165826_add_imge_column_to_lists_table.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddImgeColumnToListsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('lists', function (Blueprint $table) {
|
||||
$table->string('image')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
40
database/migrations/2021_08_23_141541_add_episode_id_col_to_videos_table.php
Executable file
40
database/migrations/2021_08_23_141541_add_episode_id_col_to_videos_table.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddEpisodeIdColToVideosTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('videos', 'episode_id')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table
|
||||
->integer('episode_id')
|
||||
->unsigned()
|
||||
->nullable()
|
||||
->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class RenameEpisodeAndSeasonColumnsInVideosTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('videos', 'episode_num')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->renameColumn('season', 'season_num');
|
||||
$table->renameColumn('episode', 'episode_num');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Episode;
|
||||
use App\Models\Video;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class HydrateEpisodeIdColumnInVideosTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$videos = Video::whereNotNull('season_num')
|
||||
->whereNotNull('episode_num')
|
||||
->whereNull('episode_id')
|
||||
->lazyById(100)
|
||||
->each(function (Video $video) {
|
||||
$episode = Episode::where('episode_number', $video->episode_num)
|
||||
->where('season_number', $video->season_num)
|
||||
->where('title_id', $video->title_id)
|
||||
->first();
|
||||
|
||||
if ($episode) {
|
||||
$video->episode_id = $episode->id;
|
||||
$video->save();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Common\Settings\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class LowercaseCustomSeoInSettingsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$settings = Setting::where('name', 'like', 'seo.%')->get();
|
||||
|
||||
$settings->each(function (Setting $setting) {
|
||||
$newValue = preg_replace_callback(
|
||||
'/({{[\w\.\-\?\:]+?}})/',
|
||||
function ($matches) {
|
||||
return strtolower($matches[1]);
|
||||
},
|
||||
$setting->value,
|
||||
);
|
||||
$setting->value = $newValue;
|
||||
$setting->save();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
24
database/migrations/2023_05_01_141721_add_prefix_to_tmdb_season_posters.php
Executable file
24
database/migrations/2023_05_01_141721_add_prefix_to_tmdb_season_posters.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Season;
|
||||
use App\Services\Data\Tmdb\TransformData;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
$prefix = TransformData::TMDB_IMAGE_BASE;
|
||||
Season::whereNotNull('poster')
|
||||
->where('poster', 'like', '/%')
|
||||
->update([
|
||||
'poster' => DB::raw(
|
||||
"CONCAT('$prefix', poster)",
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
28
database/migrations/2023_05_04_133744_create_channels_table.php
Executable file
28
database/migrations/2023_05_04_133744_create_channels_table.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('channels', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('slug', 50)->unique()->nullable();
|
||||
$table->string('name');
|
||||
$table->boolean('internal')->default(false)->index();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('type', 10)->default('channel')->index();
|
||||
$table->boolean('public')->default(true)->index();
|
||||
$table->bigInteger('user_id')->unsigned()->nullable()->index();
|
||||
$table->longText('config');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('channels');
|
||||
}
|
||||
};
|
||||
26
database/migrations/2023_05_05_124232_create_channelables_table.php
Executable file
26
database/migrations/2023_05_05_124232_create_channelables_table.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('channelables', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('channel_id')->unsgined()->index();
|
||||
$table->string('channelable_type', 20)->index();
|
||||
$table->integer('channelable_id')->unsgined()->index();
|
||||
$table->integer('order')->unsgined()->default(0)->index();
|
||||
|
||||
$table->unique(['channelable_type', 'channelable_id', 'channel_id'], 'channelables_unique');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('channelables');
|
||||
}
|
||||
};
|
||||
22
database/migrations/2023_05_21_120124_create_news_article_models_table.php
Executable file
22
database/migrations/2023_05_21_120124_create_news_article_models_table.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('news_article_models', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('model');
|
||||
$table->bigInteger('article_id')->unsigned()->index();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('news_article_models');
|
||||
}
|
||||
};
|
||||
32
database/migrations/2023_05_21_123600_add_imdb_id_indexes.php
Executable file
32
database/migrations/2023_05_21_123600_add_imdb_id_indexes.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('titles', function (Blueprint $table) {
|
||||
$table->index('imdb_id');
|
||||
});
|
||||
Schema::table('people', function (Blueprint $table) {
|
||||
$table->index('imdb_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
23
database/migrations/2023_05_30_114832_create_genres_tables.php
Executable file
23
database/migrations/2023_05_30_114832_create_genres_tables.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('genres', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->index();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('genres');
|
||||
}
|
||||
};
|
||||
24
database/migrations/2023_05_30_115019_genreables_table.php
Executable file
24
database/migrations/2023_05_30_115019_genreables_table.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('genre_title', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('genre_id')->index();
|
||||
$table->bigInteger('title_id')->index();
|
||||
|
||||
$table->unique(['genre_id', 'title_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
32
database/migrations/2023_05_30_131122_add_id_to_taggables_table.php
Executable file
32
database/migrations/2023_05_30_131122_add_id_to_taggables_table.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('taggables', function (Blueprint $table) {
|
||||
if ( ! Schema::hasColumn('taggables', 'id')) {
|
||||
$table->id();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
24
database/migrations/2023_05_30_131522_create_keywords_table.php
Executable file
24
database/migrations/2023_05_30_131522_create_keywords_table.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('keywords', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->index();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('keywords');
|
||||
}
|
||||
};
|
||||
22
database/migrations/2023_05_30_131557_create_production_countries_table.php
Executable file
22
database/migrations/2023_05_30_131557_create_production_countries_table.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
Schema::create('production_countries', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->index();
|
||||
$table->string('display_name')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('production_countries');
|
||||
}
|
||||
};
|
||||
23
database/migrations/2023_05_30_131630_create_keywordeables_table.php
Executable file
23
database/migrations/2023_05_30_131630_create_keywordeables_table.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
Schema::create('keyword_title', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('keyword_id')->index();
|
||||
$table->bigInteger('title_id')->index();
|
||||
|
||||
$table->unique(['keyword_id', 'title_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('keyword_title');
|
||||
}
|
||||
};
|
||||
23
database/migrations/2023_05_30_131718_create_countryeables_table.php
Executable file
23
database/migrations/2023_05_30_131718_create_countryeables_table.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
Schema::create('country_title', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('production_country_id')->index();
|
||||
$table->bigInteger('title_id')->index();
|
||||
|
||||
$table->unique(['production_country_id', 'title_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('countryables');
|
||||
}
|
||||
};
|
||||
101
database/migrations/2023_05_31_115407_move_genre_tags_into_seprate_table.php
Executable file
101
database/migrations/2023_05_31_115407_move_genre_tags_into_seprate_table.php
Executable file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
use Common\Tags\Tag;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
ini_set('memory_limit', '-1');
|
||||
set_time_limit(0);
|
||||
|
||||
$this->handle('genre', 'genre_title', 'genre_id');
|
||||
$this->handle('keyword', 'keyword_title', 'keyword_id');
|
||||
$this->handle(
|
||||
'production_country',
|
||||
'country_title',
|
||||
'production_country_id',
|
||||
);
|
||||
|
||||
DB::table('taggables')->truncate();
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
protected function handle(string $tagType, string $table, string $column)
|
||||
{
|
||||
Tag::where('type', $tagType)->chunkById(100, function ($_oldTags) use (
|
||||
$tagType,
|
||||
$table,
|
||||
$column,
|
||||
) {
|
||||
$newModel = app(modelTypeToNamespace($tagType));
|
||||
|
||||
$oldTags = [];
|
||||
$newTags = [];
|
||||
|
||||
$_oldTags
|
||||
->filter(fn($tag) => !!$tag->name)
|
||||
->each(function ($tag) use ($newModel, &$oldTags, &$newTags) {
|
||||
$newTag = $newModel
|
||||
->firstOrCreate(
|
||||
['name' => $tag->name],
|
||||
[
|
||||
'name' => $tag->name,
|
||||
'display_name' => $tag->display_name,
|
||||
],
|
||||
);
|
||||
$oldTags[$tag->id] = $tag->toArray();
|
||||
$newTags[$newTag->name] = $newTag->toArray();
|
||||
});
|
||||
|
||||
DB::table('taggables')
|
||||
->whereIn('tag_id', array_keys($oldTags))
|
||||
->chunkById(100, function ($taggables) use (
|
||||
$newTags,
|
||||
$oldTags,
|
||||
$table,
|
||||
$column,
|
||||
) {
|
||||
$oldTaggableIds = [];
|
||||
$newRecords = $taggables
|
||||
->map(function ($taggable) use (
|
||||
$oldTags,
|
||||
$newTags,
|
||||
$column,
|
||||
&$oldTaggableIds,
|
||||
) {
|
||||
$tagName = $oldTags[$taggable->tag_id]['name'];
|
||||
if (!isset($newTags[$tagName])) {
|
||||
dd('x', $tagName, array_keys($newTags));
|
||||
}
|
||||
$newTagId = $newTags[$tagName]['id'];
|
||||
$oldTaggableIds[] = $taggable->id;
|
||||
return [
|
||||
$column => $newTagId,
|
||||
'title_id' => $taggable->taggable_id,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
DB::table($table)->upsert(
|
||||
$newRecords,
|
||||
$newRecords,
|
||||
array_keys($newRecords[0]),
|
||||
);
|
||||
|
||||
// delete from old taggables table
|
||||
DB::table('taggables')
|
||||
->whereIn('id', $oldTaggableIds)
|
||||
->delete();
|
||||
});
|
||||
|
||||
DB::table('tags')
|
||||
->whereIn('id', $_oldTags->pluck('id'))
|
||||
->delete();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('channelables', function (Blueprint $table) {
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
};
|
||||
30
database/migrations/2023_06_06_141127_add_sort_indexes_to_titles_table.php
Executable file
30
database/migrations/2023_06_06_141127_add_sort_indexes_to_titles_table.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Common\Database\Traits\AddsIndexToExistingTable;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
use AddsIndexToExistingTable;
|
||||
|
||||
public function up()
|
||||
{
|
||||
Schema::table('titles', function (Blueprint $table) {
|
||||
$this->addIndexIfDoesNotExist($table, 'created_at');
|
||||
$this->addIndexIfDoesNotExist($table, 'updated_at');
|
||||
$this->addIndexIfDoesNotExist($table, 'budget');
|
||||
$this->addIndexIfDoesNotExist($table, 'revenue');
|
||||
$this->addIndexIfDoesNotExist($table, 'language');
|
||||
$this->addIndexIfDoesNotExist($table, 'adult');
|
||||
$this->addIndexIfDoesNotExist($table, 'year');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
17
database/migrations/2023_06_10_141731_rename_video_ratings_table.php
Executable file
17
database/migrations/2023_06_10_141731_rename_video_ratings_table.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::rename('video_ratings', 'video_votes');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
Schema::table('video_votes', function (Blueprint $table) {
|
||||
$table->renameColumn('rating', 'vote_type');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->renameColumn('positive_votes', 'upvotes');
|
||||
$table->renameColumn('negative_votes', 'downvotes');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::table('video_votes')
|
||||
->where('vote_type', 'positive')
|
||||
->update(['vote_type' => 'upvote']);
|
||||
|
||||
DB::table('video_votes')
|
||||
->where('vote_type', 'negative')
|
||||
->update(['vote_type' => 'downvote']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
34
database/migrations/2023_06_12_131113_add_has_text_col_to_reviews_table.php
Executable file
34
database/migrations/2023_06_12_131113_add_has_text_col_to_reviews_table.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('reviews', function (Blueprint $table) {
|
||||
$table
|
||||
->boolean('has_text')
|
||||
->after('score')
|
||||
->default(false)
|
||||
->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Review;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Review::whereNotNull('body')->update(['has_text' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
32
database/migrations/2023_06_12_142709_add_title_column_to_reviews_table.php
Executable file
32
database/migrations/2023_06_12_142709_add_title_column_to_reviews_table.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('reviews', function (Blueprint $table) {
|
||||
$table->string('title')->nullable()->after('id');
|
||||
$table->integer('helpful_count')->default(0)->after('has_text');
|
||||
$table->integer('not_helpful_count')->default(0)->after('helpful_count');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
34
database/migrations/2023_06_12_145530_create_review_feedback_table.php
Executable file
34
database/migrations/2023_06_12_145530_create_review_feedback_table.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('review_feedback', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('user_id')->index();
|
||||
$table->unsignedBigInteger('review_id')->index();
|
||||
$table->boolean('is_helpful')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('review_feedback');
|
||||
}
|
||||
};
|
||||
25
database/migrations/2023_06_13_140612_create_review_reports_table.php
Executable file
25
database/migrations/2023_06_13_140612_create_review_reports_table.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('review_reports', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('reason')->nullable();
|
||||
$table->unsignedBigInteger('user_id')->index()->nullable();
|
||||
$table->unsignedBigInteger('review_id')->index();
|
||||
$table->string('user_ip')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('review_reports');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->renameColumn('url', 'src');
|
||||
$table->renameColumn('source', 'origin');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('videos', function (Blueprint $table) {
|
||||
$table->dropColumn('reports');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('episodes', function (Blueprint $table) {
|
||||
$table
|
||||
->integer('runtime')
|
||||
->after('episode_number')
|
||||
->index()
|
||||
->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('episodes', function (Blueprint $table) {
|
||||
$table->dropColumn('runtime');
|
||||
});
|
||||
}
|
||||
};
|
||||
22
database/migrations/2023_06_24_114735_change_cast_department_to_actors.php
Executable file
22
database/migrations/2023_06_24_114735_change_cast_department_to_actors.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
DB::table('creditables')
|
||||
->where('department', 'cast')
|
||||
->update(['department' => 'actors', 'job' => 'actor']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('seasons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('seasons', 'episode_count')) {
|
||||
$table->dropColumn('episode_count');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Common\Database\Traits\AddsIndexToExistingTable;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
use AddsIndexToExistingTable;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('episodes', function (Blueprint $table) {
|
||||
$this->addIndexIfDoesNotExist($table, 'title_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
38
database/migrations/2023_06_26_132305_add_sort_indexes_to_people_table.php
Executable file
38
database/migrations/2023_06_26_132305_add_sort_indexes_to_people_table.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Common\Database\Traits\AddsIndexToExistingTable;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
use AddsIndexToExistingTable;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('people', function (Blueprint $table) {
|
||||
$this->addIndexIfDoesNotExist($table, 'birth_date');
|
||||
$this->addIndexIfDoesNotExist($table, 'death_date');
|
||||
$this->addIndexIfDoesNotExist($table, 'views');
|
||||
$this->addIndexIfDoesNotExist($table, 'known_for');
|
||||
$this->addIndexIfDoesNotExist($table, 'gender');
|
||||
$this->addIndexIfDoesNotExist($table, 'adult');
|
||||
$this->addIndexIfDoesNotExist($table, 'popularity');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
39
database/migrations/2023_06_27_124810_create_news_articles_table.php
Executable file
39
database/migrations/2023_06_27_124810_create_news_articles_table.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('news_articles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->string('slug', 100)->unique()->index();
|
||||
$table->longText('body');
|
||||
$table->string('image')->nullable();
|
||||
$table->string('source')->nullable();
|
||||
$table->string('source_url')->nullable();
|
||||
$table->string('byline')->nullable();
|
||||
$table->timestamp('created_at', 0)->nullable()->index();
|
||||
$table->timestamp('updated_at', 0)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('news_articles');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use App\Models\NewsArticle;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::table('custom_pages')
|
||||
->where('type', 'news_article')
|
||||
->lazyById(100)
|
||||
->each(function ($article) {
|
||||
$meta = json_decode($article->meta, true);
|
||||
try {
|
||||
NewsArticle::create([
|
||||
'title' => $article->title,
|
||||
'body' => $article->body,
|
||||
'slug' => $article->slug,
|
||||
'image' => $meta['image'] ?? null,
|
||||
'source' => $meta['source'] ?? null,
|
||||
'source_url' => $meta['source_url'] ?? null,
|
||||
'byline' => $meta['byline'] ?? null,
|
||||
]);
|
||||
DB::table('custom_pages')->delete($article->id);
|
||||
} catch (Exception $e) {
|
||||
//
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
108
database/migrations/2023_06_28_154354_move_user_lists_to_channels_table.php
Executable file
108
database/migrations/2023_06_28_154354_move_user_lists_to_channels_table.php
Executable file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Channel;
|
||||
use App\Models\Person;
|
||||
use App\Models\Title;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::table('lists')
|
||||
->whereNull('auto_update')
|
||||
->where('name', '!=', 'watchlist')
|
||||
->lazyById(100)
|
||||
->each(function ($list) {
|
||||
$channel =
|
||||
Channel::where('name', $list->name)->first() ??
|
||||
Channel::create([
|
||||
'name' => $list->name,
|
||||
'description' => $list->description,
|
||||
'user_id' => $list->user_id,
|
||||
'type' => 'list',
|
||||
'public' => $list->public,
|
||||
'internal' => $list->system,
|
||||
'created_at' => $list->created_at,
|
||||
'updated_at' => $list->updated_at,
|
||||
'config' => json_encode([
|
||||
'contentType' => 'manual',
|
||||
'contentOrder' => 'channelables.order:asc',
|
||||
'contentModel' => 'title',
|
||||
'layout' => 'grid',
|
||||
'preventDeletion' => $list?->system ?? false,
|
||||
]),
|
||||
]);
|
||||
|
||||
$listables = DB::table('listables')
|
||||
->where('list_id', $list->id)
|
||||
->where(
|
||||
// skip episodes
|
||||
fn($q) => $q
|
||||
->where(function ($q) {
|
||||
$q->where(
|
||||
'listable_type',
|
||||
Title::class,
|
||||
)->orWhere('listable_type', Title::MODEL_TYPE);
|
||||
})
|
||||
->orWhere(function ($q) {
|
||||
$q->where(
|
||||
'listable_type',
|
||||
Person::class,
|
||||
)->orWhere('listable_type', Person::MODEL_TYPE);
|
||||
}),
|
||||
)
|
||||
->get();
|
||||
|
||||
$newChannelables = $listables->map(function ($listable) use (
|
||||
$channel,
|
||||
) {
|
||||
$modelType = str_contains($listable->listable_type, '\\')
|
||||
? Str::of($listable->listable_type)
|
||||
->lower()
|
||||
->explode('\\')
|
||||
->last()
|
||||
->toString()
|
||||
: $listable->listable_type;
|
||||
return [
|
||||
'channel_id' => $channel->id,
|
||||
'channelable_id' => $listable->listable_id,
|
||||
'channelable_type' => $listable->listable_type,
|
||||
'order' => $listable->order,
|
||||
'created_at' => $listable->created_at,
|
||||
];
|
||||
});
|
||||
|
||||
$currentChannelables = DB::table('channelables')
|
||||
->where('channel_id', $channel->id)
|
||||
->get();
|
||||
|
||||
$filteredChannelables = $newChannelables->filter(function (
|
||||
$newChannelable,
|
||||
) use ($currentChannelables) {
|
||||
return !$currentChannelables->contains(
|
||||
'channelable_id',
|
||||
$newChannelable['channelable_id'],
|
||||
);
|
||||
});
|
||||
|
||||
DB::table('channelables')->insert(
|
||||
$filteredChannelables->toArray(),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
};
|
||||
33
database/migrations/2023_07_01_150222_add_creditables_table_indexes.php
Executable file
33
database/migrations/2023_07_01_150222_add_creditables_table_indexes.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Common\Database\Traits\AddsIndexToExistingTable;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
use AddsIndexToExistingTable;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('creditables', function (Blueprint $table) {
|
||||
$this->addIndexIfDoesNotExist($table, 'creditable_type');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
35
database/migrations/2023_07_03_140608_create_user_profiles_table.php
Executable file
35
database/migrations/2023_07_03_140608_create_user_profiles_table.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUserProfilesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('user_profiles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('description')->nullable();
|
||||
$table->string('city')->nullable();
|
||||
$table->string('country')->nullable();
|
||||
$table->integer('user_id')->index()->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('user_profiles');
|
||||
}
|
||||
}
|
||||
35
database/migrations/2023_07_03_140907_create_profile_links_table.php
Executable file
35
database/migrations/2023_07_03_140907_create_profile_links_table.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateProfileLinksTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('profile_links', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('url');
|
||||
$table->string('title');
|
||||
$table->integer('linkeable_id')->index();
|
||||
$table->string('linkeable_type')->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('user_links');
|
||||
}
|
||||
}
|
||||
34
database/migrations/2023_07_06_142126_add_duration_to_video_plays_table.php
Executable file
34
database/migrations/2023_07_06_142126_add_duration_to_video_plays_table.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('video_plays', function (Blueprint $table) {
|
||||
$table
|
||||
->integer('duration')
|
||||
->after('time_watched')
|
||||
->unsigned()
|
||||
->nullable()
|
||||
->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::table('settings')
|
||||
->where('name', 'content.people_provider')
|
||||
->where('value', 'local')
|
||||
->delete();
|
||||
|
||||
DB::table('settings')
|
||||
->where('name', 'content.title_provider')
|
||||
->where('value', 'local')
|
||||
->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('video_captions', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('video_captions', 'hash')) {
|
||||
$table->dropColumn('hash');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('titles', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('titles', 'year')) {
|
||||
$table->dropColumn('year');
|
||||
}
|
||||
if (Schema::hasColumn('titles', 'episode_count')) {
|
||||
$table->dropColumn('episode_count');
|
||||
}
|
||||
if (Schema::hasColumn('titles', 'season_count')) {
|
||||
$table->dropColumn('season_count');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('episodes', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('episodes', 'year')) {
|
||||
$table->dropColumn('year');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user