Properly initially-shuffle shuffled playlists being migrated up; add descs to some older migrations.
This commit is contained in:
parent
6131e027cb
commit
4610ca4422
|
@ -6,7 +6,7 @@ use Doctrine\Migrations\AbstractMigration;
|
|||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Based to Version20180506022642
|
||||
* Add a custom "listen" URL for each mount point.
|
||||
*/
|
||||
final class Version20180608130900 extends AbstractMigration
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
* Make media length an INT instead of SMALLINT for songs longer than 9 hours (!)
|
||||
*/
|
||||
final class Version20180716185805 extends AbstractMigration
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
* Add per-station-configurable number of history items to be shown in the NowPlaying API.
|
||||
*/
|
||||
final class Version20180818223558 extends AbstractMigration
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
* Update the index on song_history.
|
||||
*/
|
||||
final class Version20180826011103 extends AbstractMigration
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
* Switch the collation of fields from "utf8mb4_unicode_ci" to "utf8mb4_general_ci" for case-insensitive searching.
|
||||
*/
|
||||
final class Version20180826043500 extends AbstractMigration
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
* Move all playlists that were previously "random" into the new "shuffled" type.
|
||||
*/
|
||||
final class Version20180830003036 extends AbstractMigration
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
* Create new dedicated table for remote relays.
|
||||
*/
|
||||
final class Version20180909035413 extends AbstractMigration
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
* Remove remote_ fields from station_mounts as they're now in their own table.
|
||||
*/
|
||||
final class Version20180909060758 extends AbstractMigration
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
* Add source_port, source_mount to station_remotes table
|
||||
*/
|
||||
final class Version20180909174026 extends AbstractMigration
|
||||
{
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Entity\Migration;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Manually re-shuffle any "shuffled" playlists via their weights in the DB.
|
||||
*/
|
||||
final class Version20181016144143 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('SELECT 1');
|
||||
}
|
||||
|
||||
public function postUp(Schema $schema)
|
||||
{
|
||||
$shuffled_playlists = $this->connection->fetchAll('SELECT sp.* FROM station_playlists AS sp WHERE sp.playback_order = :order', [
|
||||
'order' => 'shuffle'
|
||||
]);
|
||||
|
||||
foreach($shuffled_playlists as $playlist) {
|
||||
$all_media = $this->connection->fetchAll('SELECT spm.* FROM station_playlist_media AS spm WHERE spm.playlist_id = :playlist_id ORDER BY RAND()', [
|
||||
'playlist_id' => $playlist['id'],
|
||||
]);
|
||||
|
||||
$weight = 1;
|
||||
foreach($all_media as $row) {
|
||||
$this->connection->update('station_playlist_media', [
|
||||
'weight' => $weight,
|
||||
], [
|
||||
'id' => $row['id'],
|
||||
]);
|
||||
|
||||
$weight++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('SELECT 1');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue