mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-14 21:26:37 +00:00
Migrate length to decimal (#3113)
* Changed station_media duration from int to decimal to allow more precise song durations * Update Version20200825183243.php
This commit is contained in:
parent
a0bd2ad5c3
commit
5dbf4ff0f4
31
src/Entity/Migration/Version20200825183243.php
Normal file
31
src/Entity/Migration/Version20200825183243.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity\Migration;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20200825183243 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return 'Change the length of station media to double for more precise values.';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE station_media MODIFY `length` NUMERIC(7, 1)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE station_media MODIFY `length` int(11)');
|
||||
}
|
||||
}
|
|
@ -118,13 +118,13 @@ class StationMedia
|
|||
protected $isrc;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="length", type="integer")
|
||||
* @ORM\Column(name="length", type="decimal", precision=7, scale=2)
|
||||
*
|
||||
* @OA\Property(example=240)
|
||||
* @OA\Property(example=240.00)
|
||||
*
|
||||
* @var int The song duration in seconds.
|
||||
* @var float The song duration in seconds.
|
||||
*/
|
||||
protected $length = 0;
|
||||
protected $length = 0.00;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="length_text", type="string", length=10, nullable=true)
|
||||
|
@ -345,7 +345,7 @@ class StationMedia
|
|||
$length_min = floor($length / 60);
|
||||
$length_sec = $length % 60;
|
||||
|
||||
$this->length = (int)round($length);
|
||||
$this->length = (float)$length;
|
||||
$this->length_text = $length_min . ':' . str_pad($length_sec, 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user