Fixed tests
This commit is contained in:
parent
35effbafd2
commit
a1b3d954c0
@ -5,8 +5,11 @@ namespace App\Listeners\Update\V21;
|
||||
use App\Abstracts\Listeners\Update as Listener;
|
||||
use App\Events\Install\UpdateFinished as Event;
|
||||
use App\Models\Common\Media;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Scopes\Company;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class Version2114 extends Listener
|
||||
{
|
||||
@ -36,7 +39,7 @@ class Version2114 extends Listener
|
||||
{
|
||||
$company_ids = [];
|
||||
|
||||
foreach (Media::withTrashed()->cursor() as $media) {
|
||||
foreach (Media::withTrashed()->withoutGlobalScope(Company::class)->cursor() as $media) {
|
||||
$company_id = null;
|
||||
|
||||
if (preg_match('/\d{4}(\/\d{2}){2}\/(\d+)\//', $media->directory, $matches) && isset($matches[2])) { // 2021/04/09/34235/invoices
|
||||
@ -56,5 +59,13 @@ class Version2114 extends Listener
|
||||
DB::table('media')->whereIn('id', $media_ids)->update(['company_id' => $company_id]);
|
||||
DB::table('mediables')->whereIn('media_id', $media_ids)->update(['company_id' => $company_id]);
|
||||
}
|
||||
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->default(null)->change();
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->default(null)->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ class CoreV2114 extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->after('id');
|
||||
$table->unsignedInteger('company_id')->default(0)->after('id');
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->after('media_id');
|
||||
$table->unsignedInteger('company_id')->default(0)->after('media_id');
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user