first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

1
database/.gitignore vendored Executable file
View File

@@ -0,0 +1 @@
*.sqlite

View 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),
];
});

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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');
});
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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');
}
}

View 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()
{
//
}
}

View 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');
}
}

View 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()
{
//
}
}

View 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()
{
//
}
}

View 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()
{
//
}
}

View 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');
}
}

View 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');
});
}
}

View 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) {
//
});
}
}

View 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');
}
}

View 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) {
//
});
}
}

View 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) {
//
});
}
}

View 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');
});
}
}

View 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');
}
}

View 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');
}
}

View 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()
{
//
}
}

View 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) {
//
});
}
}

View File

@@ -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()
{
//
}
}

View 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) {
//
});
}
}

View 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');
}
}

View 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()
{
//
}
}

View 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()
{
//
}
}

View 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()
{
//
}
}

View File

@@ -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');
});
}
}

View File

@@ -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');
});
}
}

View 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');
});
}
}

View 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');
});
}
}

View 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');
});
}
}

View File

@@ -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');
});
}
}

View 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');
}
}

View 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');
}
}

View File

@@ -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');
});
}
}

View 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');
}
}

View File

@@ -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');
});
}
}

View 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()
{
//
}
}

View 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()
{
//
}
}

View 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');
});
}
}

View 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()
{
}
}

View 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()
{
//
}
}

View 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) {
//
});
}
}

View File

@@ -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()
{
//
}
}

View File

@@ -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()
{
//
}
}

View File

@@ -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()
{
}
}

View 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()
{
//
}
};

View 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');
}
};

View 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');
}
};

View 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');
}
};

View 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()
{
//
}
};

View 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');
}
};

View 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()
{
//
}
};

View 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()
{
//
}
};

View 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');
}
};

View 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');
}
};

View 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');
}
};

View 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');
}
};

View 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();
});
}
};

View File

@@ -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()
{
}
};

View 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()
{
//
}
};

View 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()
{
//
}
};

View File

@@ -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()
{
//
}
};

View File

@@ -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()
{
//
}
};

View File

@@ -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()
{
//
}
};

View 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()
{
//
}
};

View File

@@ -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()
{
//
}
};

View 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()
{
//
}
};

View 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');
}
};

View 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');
}
};

View File

@@ -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()
{
}
};

View File

@@ -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()
{
//
}
};

View File

@@ -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');
});
}
};

View 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()
{
//
}
};

View 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('seasons', function (Blueprint $table) {
if (Schema::hasColumn('seasons', 'episode_count')) {
$table->dropColumn('episode_count');
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};

View 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('episodes', function (Blueprint $table) {
$this->addIndexIfDoesNotExist($table, 'title_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};

View 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()
{
//
}
};

View 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');
}
};

View File

@@ -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()
{
//
}
};

View 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()
{
}
};

View 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()
{
//
}
};

View 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');
}
}

View 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');
}
}

View 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()
{
//
}
};

View File

@@ -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()
{
//
}
};

View File

@@ -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