blue-twilight/database/data_migrations/DataMigrationV2_0_0_alpha_1.php

32 lines
615 B
PHP
Raw Permalink Normal View History

<?php
use App\Album;
use App\DataMigration;
class DataMigrationV2_0_0_alpha_1 extends DataMigration
{
public function getVersion()
{
return '2.0.0-alpha.1';
}
public function run($currentVersion)
{
$this->storeAlbumUrlPaths();
}
/**
* Ensures all albums have a full URL path stored.
* @return void
*/
private function storeAlbumUrlPaths()
{
$albumsWithNoPath = Album::where('url_path', null)->get();
/** @var Album $album */
foreach ($albumsWithNoPath as $album)
{
$album->touch();
}
}
}