feat: add migration for title ids

This commit is contained in:
Repflez 2023-10-30 21:32:05 -07:00
commit 0e8452d32e
2 changed files with 101 additions and 0 deletions

View file

@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Miiverse\DB;
class SeparateTitleIdsByRegionAndConsole extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$schema = DB::getSchemaBuilder();
$schema->table('community_title_ids', function (Blueprint $table) {
$table->enum('console', [
'3ds',
'wiiu',
])->nullable();
// Regions set and ordered by the account services
// https://github.com/PretendoNetwork/nintendo-wiki/blob/master/docs/wiiu/account.md#headers
$table->set('region', [
'japan',
'usa',
'europe',
'australia',
'china',
'korea',
'taiwan'
]);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$schema = DB::getSchemaBuilder();
$schema->table('community_title_ids', function (Blueprint $table) {
$table->dropColumn('console');
$table->dropColumn('region');
});
}
}

View file

@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Miiverse\DB;
class DefaultRegionForTitles extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$schema = DB::getSchemaBuilder();
$schema->table('communities', function (Blueprint $table) {
// Regions set and ordered by the account services
// https://github.com/PretendoNetwork/nintendo-wiki/blob/master/docs/wiiu/account.md#headers
$regionList = [
'japan',
'usa',
'europe',
'australia',
'china',
'korea',
'taiwan'
];
// The default for titles is region free now
$table->set('default_region', $regionList)->default(implode(',', $regionList));
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$schema = DB::getSchemaBuilder();
$schema->table('communities', function (Blueprint $table) {
$table->dropColumn('default_region');
});
}
}