text stringlengths 9 39.2M | dir stringlengths 26 295 | lang stringclasses 185
values | created_date timestamp[us] | updated_date timestamp[us] | repo_name stringlengths 1 97 | repo_full_name stringlengths 7 106 | star int64 1k 183k | len_tokens int64 1 13.8M |
|---|---|---|---|---|---|---|---|---|
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20220414214828 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add SFTP details to storage_location table.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE storage_location ADD sftp_host VARCHAR(255) DEFAULT NULL, ADD sftp_username VARCHAR(255) DEFAULT NULL, ADD sftp_password VARCHAR(255) DEFAULT NULL, ADD sftp_port INT DEFAULT NULL, ADD sftp_private_key LONGTEXT DEFAULT NULL, ADD sftp_private_key_pass_phrase VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE storage_location DROP sftp_host, DROP sftp_username, DROP sftp_password, DROP sftp_port, DROP sftp_private_key, DROP sftp_private_key_pass_phrase');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20220414214828.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 210 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use App\Entity\Attributes\StableMigration;
use Doctrine\DBAL\Schema\Schema;
#[
StableMigration('0.19.2'),
StableMigration('0.19.3')
]
final class Version20230829124744 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add S3 "Use path style" boolean.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE storage_location ADD s3_use_path_style TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE storage_location DROP s3_use_path_style');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230829124744.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 167 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use App\Entity\Attributes\StableMigration;
use Doctrine\DBAL\Schema\Schema;
#[StableMigration('0.17.3')]
final class Version20220724223136 extends AbstractMigration
{
public function getDescription(): string
{
return 'Prevent request/streamer/playlist deletion from cascading to song history.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD16164427EB8A5');
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD1616425F432AD');
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD161646BBD148');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD16164427EB8A5 FOREIGN KEY (request_id) REFERENCES station_requests (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD1616425F432AD FOREIGN KEY (streamer_id) REFERENCES station_streamers (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD161646BBD148 FOREIGN KEY (playlist_id) REFERENCES station_playlists (id) ON DELETE SET NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD161646BBD148');
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD1616425F432AD');
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD16164427EB8A5');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD161646BBD148 FOREIGN KEY (playlist_id) REFERENCES station_playlists (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD1616425F432AD FOREIGN KEY (streamer_id) REFERENCES station_streamers (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD16164427EB8A5 FOREIGN KEY (request_id) REFERENCES station_requests (id) ON DELETE CASCADE');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20220724223136.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 509 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200216121137 extends AbstractMigration
{
public function getDescription(): string
{
return 'Migrate to a shared schedules table.';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE station_schedules (id INT AUTO_INCREMENT NOT NULL, playlist_id INT DEFAULT NULL, streamer_id INT DEFAULT NULL, start_time SMALLINT NOT NULL, end_time SMALLINT NOT NULL, start_date VARCHAR(10) DEFAULT NULL, end_date VARCHAR(10) DEFAULT NULL, days VARCHAR(50) DEFAULT NULL, INDEX IDX_B3BFB2956BBD148 (playlist_id), INDEX IDX_B3BFB29525F432AD (streamer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_general_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE station_schedules ADD CONSTRAINT FK_B3BFB2956BBD148 FOREIGN KEY (playlist_id) REFERENCES station_playlists (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE station_schedules ADD CONSTRAINT FK_B3BFB29525F432AD FOREIGN KEY (streamer_id) REFERENCES station_streamers (id) ON DELETE CASCADE');
$this->addSql('INSERT INTO station_schedules (playlist_id, start_time, end_time, start_date, end_date, days) SELECT playlist_id, start_time, end_time, start_date, end_date, days FROM station_playlist_schedules');
$this->addSql('DROP TABLE station_playlist_schedules');
}
public function down(Schema $schema): void
{
$this->addSql('CREATE TABLE station_playlist_schedules (id INT AUTO_INCREMENT NOT NULL, playlist_id INT DEFAULT NULL, start_time SMALLINT NOT NULL, end_time SMALLINT NOT NULL, start_date VARCHAR(10) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, end_date VARCHAR(10) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, days VARCHAR(50) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, INDEX IDX_C61009BA6BBD148 (playlist_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE station_playlist_schedules ADD CONSTRAINT FK_C61009BA6BBD148 FOREIGN KEY (playlist_id) REFERENCES station_playlists (id) ON DELETE CASCADE');
$this->addSql('DROP TABLE station_schedules');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20200216121137.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 587 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20230525024711 extends AbstractMigration
{
public function getDescription(): string
{
return 'Fix frontend/backend type on stations being nullable.';
}
public function up(Schema $schema): void
{
$this->addSql(
<<<'SQL'
UPDATE `station`
SET frontend_type='icecast'
WHERE frontend_type IS NULL
SQL
);
$this->addSql(
<<<'SQL'
UPDATE `station`
SET backend_type='liquidsoap'
WHERE backend_type IS NULL
SQL
);
$this->addSql(
<<<'SQL'
ALTER TABLE `station`
CHANGE frontend_type frontend_type VARCHAR(100) NOT NULL,
CHANGE backend_type backend_type VARCHAR(100) NOT NULL
SQL
);
}
public function down(Schema $schema): void
{
$this->addSql(
<<<'SQL'
ALTER TABLE station
CHANGE frontend_type frontend_type VARCHAR(100) DEFAULT NULL,
CHANGE backend_type backend_type VARCHAR(100) DEFAULT NULL
SQL
);
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230525024711.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 263 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200105190343 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create "sftp_user" table.';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE sftp_user (id INT AUTO_INCREMENT NOT NULL, station_id INT DEFAULT NULL, username VARCHAR(8) NOT NULL, password VARCHAR(255) NOT NULL, public_keys LONGTEXT DEFAULT NULL, INDEX IDX_3C32EA3421BDB235 (station_id), UNIQUE INDEX username_idx (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_general_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE sftp_user ADD CONSTRAINT FK_3C32EA3421BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE sftp_user');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20200105190343.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 252 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170516073708 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE listener (id INT AUTO_INCREMENT NOT NULL, station_id INT NOT NULL, listener_uid INT NOT NULL, listener_ip VARCHAR(45) NOT NULL, listener_user_agent VARCHAR(255) NOT NULL, timestamp_start INT NOT NULL, timestamp_end INT NOT NULL, INDEX IDX_959C342221BDB235 (station_id), INDEX update_idx (listener_uid, listener_ip), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE listener ADD CONSTRAINT FK_959C342221BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE song_history ADD unique_listeners SMALLINT DEFAULT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE listener');
$this->addSql('ALTER TABLE song_history DROP unique_listeners');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170516073708.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 291 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20201003023117 extends AbstractMigration
{
public function getDescription(): string
{
return 'Songs denormalization, part 2';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD16164A0BDB2F3');
$this->addSql('DROP INDEX IDX_2AD16164A0BDB2F3 ON song_history');
$this->addSql('ALTER TABLE station_media DROP FOREIGN KEY FK_32AADE3AA0BDB2F3');
$this->addSql('DROP INDEX IDX_32AADE3AA0BDB2F3 ON station_media');
$this->addSql('ALTER TABLE station_queue DROP FOREIGN KEY FK_277B0055A0BDB2F3');
$this->addSql('DROP INDEX IDX_277B0055A0BDB2F3 ON station_queue');
$this->addSql('DROP TABLE IF EXISTS songs');
$this->addSql('DELETE FROM station_media WHERE song_id IS NULL');
$this->addSql('ALTER TABLE station_media CHANGE song_id song_id VARCHAR(50) NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media CHANGE song_id song_id VARCHAR(50) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`');
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE songs (id VARCHAR(50) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_general_ci`, text VARCHAR(150) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, artist VARCHAR(150) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, title VARCHAR(150) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, created INT NOT NULL, play_count INT NOT NULL, last_played INT NOT NULL, INDEX search_idx (text, artist, title), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD16164A0BDB2F3 FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_2AD16164A0BDB2F3 ON song_history (song_id)');
$this->addSql('ALTER TABLE station_media ADD CONSTRAINT FK_32AADE3AA0BDB2F3 FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_32AADE3AA0BDB2F3 ON station_media (song_id)');
$this->addSql('ALTER TABLE station_queue ADD CONSTRAINT FK_277B0055A0BDB2F3 FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_277B0055A0BDB2F3 ON station_queue (song_id)');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20201003023117.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 760 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20230102192033 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create Station branding config column, part 1.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station ADD branding_config LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\'');
}
public function postUp(Schema $schema): void
{
$allStations = $this->connection->fetchAllAssociative(
<<<'SQL'
SELECT id, default_album_art_url
FROM station
WHERE default_album_art_url IS NOT NULL
SQL
);
foreach ($allStations as $station) {
$this->connection->update(
'station',
[
'branding_config' => json_encode([
'default_album_art_url' => $station['default_album_art_url'],
], JSON_THROW_ON_ERROR),
],
[
'id' => $station['id'],
]
);
}
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP branding_config');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230102192033.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 274 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20201125023226 extends AbstractMigration
{
public function getDescription(): string
{
return 'Fix the "text" attribute of station media.';
}
public function up(Schema $schema): void
{
// Delete all non-processed media entries
$this->addSql('
DELETE FROM station_media
WHERE artist IS NULL OR title IS NULL
');
$this->addSql('
UPDATE station_media
SET text=SUBSTRING(CONCAT(artist, \' - \', title), 1, 150),
song_id=MD5(LOWER(REPLACE(REPLACE(CONCAT(artist,\' - \',title),\'-\',\'\'),\' \',\'\')))
');
}
public function down(Schema $schema): void
{
// No-op
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20201125023226.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 202 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200604073027 extends AbstractMigration
{
public function getDescription(): string
{
return 'Extend size of the "weight" parameter.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_playlist_media CHANGE weight weight INT NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_playlist_media CHANGE weight weight SMALLINT NOT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20200604073027.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 141 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200514061004 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add "on-demand" options for stations and playlists.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station ADD enable_on_demand TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE station_playlists ADD include_in_on_demand TINYINT(1) NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP enable_on_demand');
$this->addSql('ALTER TABLE station_playlists DROP include_in_on_demand');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20200514061004.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 186 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use App\Entity\Attributes\StableMigration;
use Doctrine\DBAL\Schema\Schema;
use Exception;
#[
StableMigration('0.18.5'),
StableMigration('0.18.3'),
StableMigration('0.18.2')
]
final class Version20230602095822 extends AbstractMigration
{
public function getDescription(): string
{
return 'Update Audit Log changes from serialized PHP to JSON.';
}
public function preUp(Schema $schema): void
{
parent::preUp($schema);
// Clear records older than 6 months.
$this->connection->executeQuery(
<<<SQL
DELETE FROM audit_log WHERE timestamp < (UNIX_TIMESTAMP() - (86400 * 180))
SQL
);
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE audit_log CHANGE changes changes LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\'');
}
public function postUp(Schema $schema): void
{
parent::postUp($schema);
// Convert audit log changes to JSON.
$allChanges = $this->connection->fetchAllAssociative(
'SELECT id, changes FROM audit_log'
);
foreach ($allChanges as $row) {
try {
$newChanges = json_encode(
@unserialize($row['changes']),
JSON_THROW_ON_ERROR | JSON_PRESERVE_ZERO_FRACTION
);
} catch (Exception) {
$newChanges = null;
}
$this->connection->update(
'audit_log',
[
'changes' => $newChanges,
],
[
'id' => $row['id'],
]
);
}
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE audit_log CHANGE changes changes LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\'');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230602095822.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 432 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20201008014439 extends AbstractMigration
{
public function getDescription(): string
{
return 'Clean up station_media table from songs migration.';
}
public function up(Schema $schema): void
{
$this->addSql('DELETE FROM station_media WHERE song_id IS NULL');
$this->addSql('UPDATE station_media SET text=SUBSTRING(CONCAT(artist, \' - \', title), 1, 150) WHERE text IS NULL OR text = \'\'');
}
public function down(Schema $schema): void
{
// No-op
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20201008014439.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 152 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20171128121012 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS station_media_art');
$this->addSql('CREATE TABLE station_media_art (id INT AUTO_INCREMENT NOT NULL, media_id INT NOT NULL, art LONGBLOB DEFAULT NULL, UNIQUE INDEX UNIQ_35E0CAB2EA9FDD75 (media_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE station_media_art');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20171128121012.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 185 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use App\Entity\Attributes\StableMigration;
use Doctrine\DBAL\Schema\Schema;
#[
StableMigration('0.19.1'),
StableMigration('0.19.0')
]
final class Version20230803181406 extends AbstractMigration
{
public function getDescription(): string
{
return 'Expand length of Station "genre" field.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station CHANGE genre genre VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station CHANGE genre genre VARCHAR(150) DEFAULT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230803181406.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 162 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20181211220707 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE song_history ADD autodj_custom_uri VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE song_history DROP autodj_custom_uri');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20181211220707.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 121 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20220610125828 extends AbstractMigration
{
public function getDescription(): string
{
return 'Re-align genre field.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media CHANGE genre genre VARCHAR(30) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql(
'ALTER TABLE station_media CHANGE genre genre VARCHAR(30) CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_unicode_ci`'
);
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20220610125828.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 147 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20171214104226 extends AbstractMigration
{
public function preup(Schema $schema): void
{
// Deleting duplicate user accounts to avoid constraint errors in subsequent update
$users = $this->connection->fetchAllAssociative('SELECT * FROM users ORDER BY uid ASC');
$emails = [];
foreach ($users as $row) {
$email = $row['email'];
if (isset($emails[$email])) {
$this->connection->delete('users', ['uid' => $row['uid']]);
} else {
$emails[$email] = $email;
}
}
}
public function up(Schema $schema): void
{
$this->addSql('CREATE UNIQUE INDEX email_idx ON users (email)');
}
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX email_idx ON users');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20171214104226.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 232 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Create new dedicated table for remote relays.
*/
final class Version20180909035413 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE station_remotes (id INT AUTO_INCREMENT NOT NULL, station_id INT NOT NULL, type VARCHAR(50) NOT NULL, enable_autodj TINYINT(1) NOT NULL, autodj_format VARCHAR(10) DEFAULT NULL, autodj_bitrate SMALLINT DEFAULT NULL, custom_listen_url VARCHAR(255) DEFAULT NULL, url VARCHAR(255) DEFAULT NULL, mount VARCHAR(150) DEFAULT NULL, source_username VARCHAR(100) DEFAULT NULL, source_password VARCHAR(100) DEFAULT NULL, INDEX IDX_779D0E8A21BDB235 (station_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE station_remotes ADD CONSTRAINT FK_779D0E8A21BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE');
}
public function postup(Schema $schema): void
{
$stations = $this->connection->fetchAllAssociative(
"SELECT id, frontend_config FROM station WHERE frontend_type = 'remote'"
);
foreach ($stations as $station) {
$mounts = $this->connection->fetchAllAssociative(
'SELECT * FROM station_mounts WHERE station_id = ' . $station['id']
);
if (count($mounts) === 0) {
$settings = json_decode($station['frontend_config'], true, 512, JSON_THROW_ON_ERROR);
if (isset($settings['remote_type'])) {
$this->connection->insert('station_remotes', [
'station_id' => $station['id'],
'type' => $settings['remote_type'],
'url' => $settings['remote_url'],
'mount' => $settings['remote_mount'],
'enable_autodj' => 0,
]);
}
} else {
foreach ($mounts as $mount) {
$this->connection->insert('station_remotes', [
'station_id' => $station['id'],
'type' => $mount['remote_type'],
'url' => $mount['remote_url'],
'mount' => $mount['remote_mount'],
'custom_listen_url' => $mount['custom_listen_url'],
'enable_autodj' => (int)$mount['enable_autodj'],
'autodj_format' => $mount['autodj_format'],
'autodj_bitrate' => $mount['autodj_bitrate'],
'source_username' => $mount['remote_source_username'],
'source_password' => $mount['remote_source_password'],
]);
}
}
}
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE station_remotes');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180909035413.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 664 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20211227232320 extends AbstractMigration
{
public function getDescription(): string
{
return 'Change on-delete behavior of media on song_history table.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD16164EA9FDD75');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD16164EA9FDD75 FOREIGN KEY (media_id) REFERENCES station_media (id) ON DELETE SET NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD16164EA9FDD75');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD16164EA9FDD75 FOREIGN KEY (media_id) REFERENCES station_media (id) ON DELETE CASCADE');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20211227232320.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 224 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170512023527 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE song_history ADD playlist_id INT DEFAULT NULL, ADD timestamp_cued INT DEFAULT NULL');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD161646BBD148 FOREIGN KEY (playlist_id) REFERENCES station_playlists (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_2AD161646BBD148 ON song_history (playlist_id)');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD161646BBD148');
$this->addSql('DROP INDEX IDX_2AD161646BBD148 ON song_history');
$this->addSql('ALTER TABLE song_history DROP playlist_id, DROP timestamp_cued');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170512023527.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 259 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20161007195027 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE role_permissions (id INT AUTO_INCREMENT NOT NULL, role_id INT NOT NULL, station_id INT DEFAULT NULL, action_name VARCHAR(50) NOT NULL, INDEX IDX_1FBA94E6D60322AC (role_id), INDEX IDX_1FBA94E621BDB235 (station_id), UNIQUE INDEX role_permission_unique_idx (role_id, action_name, station_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE role_permissions ADD CONSTRAINT FK_1FBA94E6D60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE role_permissions ADD CONSTRAINT FK_1FBA94E621BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE');
$this->addSql('INSERT INTO role_permissions (role_id, action_name, station_id) SELECT rha.role_id, a.name, rha.station_id FROM role_has_actions AS rha INNER JOIN action AS a ON rha.action_id = a.id');
$this->addSql('ALTER TABLE role_has_actions DROP FOREIGN KEY FK_50EEC1BD9D32F035');
$this->addSql('DROP TABLE action');
$this->addSql('DROP TABLE role_has_actions');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('CREATE TABLE action (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100) DEFAULT NULL COLLATE utf8_unicode_ci, is_global TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE role_has_actions (id INT AUTO_INCREMENT NOT NULL, station_id INT DEFAULT NULL, action_id INT NOT NULL, role_id INT NOT NULL, UNIQUE INDEX role_action_unique_idx (role_id, action_id, station_id), INDEX IDX_50EEC1BDD60322AC (role_id), INDEX IDX_50EEC1BD21BDB235 (station_id), INDEX IDX_50EEC1BD9D32F035 (action_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE role_has_actions ADD CONSTRAINT FK_50EEC1BD21BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE role_has_actions ADD CONSTRAINT FK_50EEC1BD9D32F035 FOREIGN KEY (action_id) REFERENCES action (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE role_has_actions ADD CONSTRAINT FK_50EEC1BDD60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE');
$this->addSql('DROP TABLE role_permissions');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20161007195027.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 717 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20220228013328 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add custom fallback path to Stations.';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE station ADD fallback_path VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE station DROP fallback_path');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20220228013328.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 155 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180203201032 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station ADD current_streamer_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE station ADD CONSTRAINT FK_9F39F8B19B209974 FOREIGN KEY (current_streamer_id) REFERENCES station_streamers (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_9F39F8B19B209974 ON station (current_streamer_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP FOREIGN KEY FK_9F39F8B19B209974');
$this->addSql('DROP INDEX IDX_9F39F8B19B209974 ON station');
$this->addSql('ALTER TABLE station DROP current_streamer_id');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180203201032.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 236 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200123004338 extends AbstractMigration
{
public function getDescription(): string
{
return 'Expand size of SFTP username field to 32 characters.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE sftp_user CHANGE username username VARCHAR(32) NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE sftp_user CHANGE username username VARCHAR(8) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_general_ci`');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20200123004338.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 165 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20240619132840 extends AbstractMigration
{
public function getDescription(): string
{
return 'Migrate media metadata to an expandable field, pt. 2';
}
public function preUp(Schema $schema): void
{
$allMedia = $this->connection->fetchAllAssociative(
<<<SQL
SELECT id, amplify, fade_start_next, fade_in, fade_out, cue_in, cue_out
FROM station_media
WHERE
(amplify IS NOT NULL AND amplify != '')
OR (fade_start_next IS NOT NULL AND fade_start_next != '')
OR (fade_in IS NOT NULL AND fade_in != '')
OR (fade_out IS NOT NULL AND fade_out != '')
OR (cue_in IS NOT NULL AND cue_in != '')
OR (cue_out IS NOT NULL AND cue_out != '')
SQL
);
$fieldLookup = [
'amplify' => 'liq_amplify',
'fade_start_next' => 'liq_cross_start_next',
'fade_in' => 'liq_fade_in',
'fade_out' => 'liq_fade_out',
'cue_in' => 'liq_cue_in',
'cue_out' => 'liq_cue_out',
];
foreach ($allMedia as $row) {
$extraMeta = [];
foreach ($fieldLookup as $original => $new) {
$originalVal = $row[$original] ?? null;
if (null !== $originalVal && '' !== $originalVal) {
$extraMeta[$new] = $originalVal;
}
}
$this->connection->update(
'station_media',
[
'extra_metadata' => json_encode($extraMeta, JSON_THROW_ON_ERROR),
],
[
'id' => $row['id'],
]
);
}
}
public function up(Schema $schema): void
{
$this->addSql(<<<'SQL'
ALTER TABLE station_media
DROP amplify,
DROP fade_start_next,
DROP fade_in,
DROP fade_out,
DROP cue_in,
DROP cue_out
SQL);
}
public function down(Schema $schema): void
{
$this->addSql(<<<'SQL'
ALTER TABLE station_media
ADD amplify NUMERIC(6, 1) DEFAULT NULL,
ADD fade_start_next NUMERIC(6, 1) DEFAULT NULL,
ADD fade_in NUMERIC(6, 1) DEFAULT NULL,
ADD fade_out NUMERIC(6, 1) DEFAULT NULL,
ADD cue_in NUMERIC(6, 1) DEFAULT NULL,
ADD cue_out NUMERIC(6, 1) DEFAULT NULL
SQL);
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20240619132840.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 626 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170516205418 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE listener ADD listener_hash VARCHAR(32) NOT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE listener DROP listener_hash');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170516205418.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 137 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180203203751 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_streamers ADD display_name VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_streamers DROP display_name');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180203203751.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 117 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180425025237 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media CHANGE path path VARCHAR(500) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media CHANGE path path VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180425025237.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 129 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180204210633 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('DROP TABLE api_keys');
}
public function down(Schema $schema): void
{
$this->addSql('CREATE TABLE api_keys (id VARCHAR(50) NOT NULL COLLATE utf8mb4_unicode_ci, owner VARCHAR(150) DEFAULT \'NULL\' COLLATE utf8mb4_unicode_ci, calls_made INT NOT NULL, created INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180204210633.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 173 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190810234058 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts ADD listeners_unique INT NOT NULL, ADD listeners_total INT NOT NULL');
$this->addSql('ALTER TABLE station_remotes ADD listeners_unique INT NOT NULL, ADD listeners_total INT NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts DROP listeners_unique, DROP listeners_total');
$this->addSql('ALTER TABLE station_remotes DROP listeners_unique, DROP listeners_total');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190810234058.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 171 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20201210013351 extends AbstractMigration
{
public function getDescription(): string
{
return 'Re-add Symfony Message Queue table.';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(
'CREATE TABLE messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL, available_at DATETIME NOT NULL, delivered_at DATETIME DEFAULT NULL, INDEX IDX_75EA56E0FB7336F0 (queue_name), INDEX IDX_75EA56E0E3BD61CE (available_at), INDEX IDX_75EA56E016BA31DB (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_general_ci` ENGINE = InnoDB'
);
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE messenger_messages');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20201210013351.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 288 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180320171318 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media_art DROP FOREIGN KEY FK_35E0CAB2EA9FDD75');
$this->addSql('ALTER TABLE station_media_art ADD CONSTRAINT FK_35E0CAB2EA9FDD75 FOREIGN KEY (media_id) REFERENCES station_media (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media_art DROP FOREIGN KEY FK_35E0CAB2EA9FDD75');
$this->addSql('ALTER TABLE station_media_art ADD CONSTRAINT FK_35E0CAB2EA9FDD75 FOREIGN KEY (media_id) REFERENCES station_media (id)');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180320171318.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 219 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20211114071609 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add "is_played" boolean to station queue.';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE station_queue ADD is_played TINYINT(1) NOT NULL');
}
public function postUp(Schema $schema): void
{
$this->connection->update(
'station_queue',
[
'is_played' => 1,
],
[
'sent_to_autodj' => 1,
]
);
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE station_queue DROP is_played');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20211114071609.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 239 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170518100549 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media ADD cue_in NUMERIC(3, 1) DEFAULT NULL, ADD cue_out NUMERIC(3, 1) DEFAULT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media DROP cue_in, DROP cue_out');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170518100549.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 161 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190314203550 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_webhooks ADD metadata LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json_array)\'');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_webhooks DROP metadata');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190314203550.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 124 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20221027134810 extends AbstractMigration
{
public function getDescription(): string
{
return 'Remove unnecessary Dropbox fields.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE storage_location DROP dropbox_app_key, DROP dropbox_app_secret');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE storage_location ADD dropbox_app_key VARCHAR(255) DEFAULT NULL, ADD dropbox_app_secret VARCHAR(255) DEFAULT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20221027134810.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 143 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Add a custom "listen" URL for each mount point.
*/
final class Version20180608130900 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts ADD custom_listen_url VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts DROP custom_listen_url');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180608130900.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 121 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190314074747 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE users ADD two_factor_secret VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE users DROP two_factor_secret');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190314074747.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 115 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use App\Entity\Attributes\StableMigration;
use Doctrine\DBAL\Schema\Schema;
#[
StableMigration('0.20.1')
]
final class Version20240529175534 extends AbstractMigration
{
public function getDescription(): string
{
return 'Convert "fade_overlap" back to "fade_start_next".';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media ADD fade_start_next NUMERIC(6, 1) DEFAULT NULL AFTER amplify');
$this->addSql(
<<<'SQL'
UPDATE station_media
SET fade_start_next=IF(cue_out IS NOT NULL, cue_out, length) - fade_overlap
WHERE fade_overlap IS NOT NULL
SQL
);
$this->addSql('ALTER TABLE station_media DROP fade_overlap');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media ADD fade_overlap NUMERIC(6, 1) DEFAULT NULL');
$this->addSql('ALTER TABLE station_media DROP fade_start_next');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20240529175534.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 253 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20230729133644 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add DB-level PSR-6 cache table.';
}
public function up(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS cache_items');
$this->addSql('CREATE TABLE cache_items (item_id VARBINARY(255) NOT NULL, item_data MEDIUMBLOB NOT NULL, item_lifetime INT UNSIGNED DEFAULT NULL, item_time INT UNSIGNED NOT NULL, PRIMARY KEY(item_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_general_ci` ENGINE = InnoDB');
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS cache_items');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230729133644.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 191 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20240813181909 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add playlist_media_id to station_queue';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_queue ADD playlist_media_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE station_queue ADD CONSTRAINT FK_277B005517421B18 FOREIGN KEY (playlist_media_id) REFERENCES station_playlist_media (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_277B005517421B18 ON station_queue (playlist_media_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_queue DROP FOREIGN KEY FK_277B005517421B18');
$this->addSql('DROP INDEX IDX_277B005517421B18 ON station_queue');
$this->addSql('ALTER TABLE station_queue DROP playlist_media_id');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20240813181909.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 235 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use App\Entity\Attributes\StableMigration;
use Doctrine\DBAL\Schema\Schema;
#[StableMigration('0.17.7')]
final class Version20230102192652 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create Station branding config column, part 2.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP default_album_art_url');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station ADD default_album_art_url VARCHAR(255) DEFAULT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230102192652.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 149 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20161006030903 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS user_manages_station');
$this->addSql('DELETE FROM role_has_actions WHERE role_id NOT IN (SELECT id FROM role)');
$this->addSql('DELETE FROM role_has_actions WHERE action_id NOT IN (SELECT id FROM action)');
$this->addSql('ALTER TABLE role_has_actions ADD CONSTRAINT FK_50EEC1BDD60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE role_has_actions ADD CONSTRAINT FK_50EEC1BD9D32F035 FOREIGN KEY (action_id) REFERENCES action (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_50EEC1BD9D32F035 ON role_has_actions (action_id)');
$this->addSql('ALTER TABLE users ADD timezone VARCHAR(100) DEFAULT NULL, ADD locale VARCHAR(25) DEFAULT NULL, ADD created_at INT NOT NULL, ADD updated_at INT NOT NULL, DROP auth_last_login_time, DROP auth_recovery_code, DROP gender, DROP customization');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('CREATE TABLE user_manages_station (user_id INT NOT NULL, station_id INT NOT NULL, INDEX IDX_2453B56BA76ED395 (user_id), INDEX IDX_2453B56B21BDB235 (station_id), PRIMARY KEY(user_id, station_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE user_manages_station ADD CONSTRAINT FK_2453B56B21BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE user_manages_station ADD CONSTRAINT FK_2453B56BA76ED395 FOREIGN KEY (user_id) REFERENCES users (uid) ON DELETE CASCADE');
$this->addSql('ALTER TABLE role_has_actions DROP FOREIGN KEY FK_50EEC1BDD60322AC');
$this->addSql('ALTER TABLE role_has_actions DROP FOREIGN KEY FK_50EEC1BD9D32F035');
$this->addSql('DROP INDEX IDX_50EEC1BD9D32F035 ON role_has_actions');
$this->addSql('ALTER TABLE users ADD auth_last_login_time INT DEFAULT NULL, ADD auth_recovery_code VARCHAR(50) DEFAULT NULL COLLATE utf8_unicode_ci, ADD gender VARCHAR(1) DEFAULT NULL COLLATE utf8_unicode_ci, ADD customization LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci COMMENT \'(DC2Type:json)\', DROP timezone, DROP locale, DROP created_at, DROP updated_at');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20161006030903.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 666 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20201006044905 extends AbstractMigration
{
public function getDescription(): string
{
return 'Analytics database improvements.';
}
public function up(Schema $schema): void
{
$this->addSql('DROP INDEX search_idx ON analytics');
$this->addSql('ALTER TABLE analytics ADD moment DATETIME(0) NOT NULL COMMENT \'(DC2Type:carbon_immutable)\', CHANGE number_avg number_avg NUMERIC(10, 2) NOT NULL, ADD number_unique INT');
$this->addSql('UPDATE analytics SET moment=FROM_UNIXTIME(timestamp)');
$this->addSql('ALTER TABLE analytics DROP timestamp');
$this->addSql('CREATE INDEX search_idx ON analytics (type, moment)');
}
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX search_idx ON analytics');
$this->addSql('ALTER TABLE analytics ADD timestamp INT NOT NULL');
$this->addSql('UPDATE analytics SET new_timestamp=UNIX_TIMESTAMP(moment)');
$this->addSql('ALTER TABLE analytics DROP moment, DROP number_unique, CHANGE number_avg number_avg INT NOT NULL');
$this->addSql('CREATE INDEX search_idx ON analytics (type, timestamp)');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20201006044905.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 304 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200816092130 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create new "station_queue" table.';
}
public function preUp(Schema $schema): void
{
$this->connection->executeStatement('DELETE FROM song_history WHERE timestamp_start = 0');
$this->connection->executeStatement('UPDATE station SET nowplaying=null, nowplaying_timestamp=0');
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE IF NOT EXISTS station_queue (id INT AUTO_INCREMENT NOT NULL, song_id VARCHAR(50) NOT NULL, station_id INT DEFAULT NULL, playlist_id INT DEFAULT NULL, media_id INT DEFAULT NULL, request_id INT DEFAULT NULL, sent_to_autodj TINYINT(1) NOT NULL, autodj_custom_uri VARCHAR(255) DEFAULT NULL, timestamp_cued INT NOT NULL, duration INT DEFAULT NULL, INDEX IDX_277B0055A0BDB2F3 (song_id), INDEX IDX_277B005521BDB235 (station_id), INDEX IDX_277B00556BBD148 (playlist_id), INDEX IDX_277B0055EA9FDD75 (media_id), INDEX IDX_277B0055427EB8A5 (request_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_general_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE station_queue ADD CONSTRAINT FK_277B0055A0BDB2F3 FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE station_queue ADD CONSTRAINT FK_277B005521BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE station_queue ADD CONSTRAINT FK_277B00556BBD148 FOREIGN KEY (playlist_id) REFERENCES station_playlists (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE station_queue ADD CONSTRAINT FK_277B0055EA9FDD75 FOREIGN KEY (media_id) REFERENCES station_media (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE station_queue ADD CONSTRAINT FK_277B0055427EB8A5 FOREIGN KEY (request_id) REFERENCES station_requests (id) ON DELETE CASCADE');
$this->addSql('DROP INDEX idx_timestamp_cued ON song_history');
$this->addSql('ALTER TABLE song_history DROP timestamp_cued, DROP sent_to_autodj, DROP autodj_custom_uri');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE station_queue');
$this->addSql('ALTER TABLE song_history ADD timestamp_cued INT DEFAULT NULL, ADD sent_to_autodj TINYINT(1) NOT NULL, ADD autodj_custom_uri VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`');
$this->addSql('CREATE INDEX idx_timestamp_cued ON song_history (timestamp_cued)');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20200816092130.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 730 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200818010817 extends AbstractMigration
{
public function getDescription(): string
{
return 'Switch to Doctrine 2 JSON type; add log column to StationQueue.';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE settings CHANGE setting_value setting_value LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\'');
$this->addSql('ALTER TABLE song_history CHANGE delta_points delta_points LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\'');
$this->addSql('ALTER TABLE station CHANGE frontend_config frontend_config LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', CHANGE backend_config backend_config LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', CHANGE automation_settings automation_settings LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\'');
$this->addSql('ALTER TABLE station_queue ADD log LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', CHANGE station_id station_id INT NOT NULL');
$this->addSql('ALTER TABLE station_webhooks CHANGE triggers triggers LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', CHANGE config config LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', CHANGE metadata metadata LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\'');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE settings CHANGE setting_value setting_value LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci` COMMENT \'(DC2Type:json_array)\'');
$this->addSql('ALTER TABLE song_history CHANGE delta_points delta_points LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci` COMMENT \'(DC2Type:json_array)\'');
$this->addSql('ALTER TABLE station CHANGE frontend_config frontend_config LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci` COMMENT \'(DC2Type:json_array)\', CHANGE backend_config backend_config LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci` COMMENT \'(DC2Type:json_array)\', CHANGE automation_settings automation_settings LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci` COMMENT \'(DC2Type:json_array)\'');
$this->addSql('ALTER TABLE station_queue DROP log, CHANGE station_id station_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE station_webhooks CHANGE triggers triggers LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci` COMMENT \'(DC2Type:json_array)\', CHANGE config config LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci` COMMENT \'(DC2Type:json_array)\', CHANGE metadata metadata LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci` COMMENT \'(DC2Type:json_array)\'');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20200818010817.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 723 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Switch the collation of fields from "utf8mb4_unicode_ci" to "utf8mb4_general_ci" for case-insensitive searching.
*/
final class Version20180826043500 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->changeCharset('utf8mb4_general_ci');
}
private function changeCharset(string $collate): void
{
$dbName = $this->connection->getDatabase() ?? 'azuracast';
$tables = [
'analytics',
'api_keys',
'app_migrations',
'custom_field',
'listener',
'role',
'role_permissions',
'settings',
'song_history',
'songs',
'station',
'station_media',
'station_media_art',
'station_media_custom_field',
'station_mounts',
'station_playlist_media',
'station_playlists',
'station_requests',
'station_requests',
'station_streamers',
'station_webhooks',
'user_has_role',
'users',
];
$sqlLines = [
'ALTER DATABASE ' . $this->connection->quoteIdentifier(
$dbName
) . ' CHARACTER SET = utf8mb4 COLLATE = ' . $collate,
'ALTER TABLE `song_history` DROP FOREIGN KEY FK_2AD16164A0BDB2F3',
'ALTER TABLE `station_media` DROP FOREIGN KEY FK_32AADE3AA0BDB2F3',
];
foreach ($sqlLines as $sql) {
$this->addSql($sql);
}
foreach ($tables as $tableName) {
$this->addSql(
'ALTER TABLE ' . $this->connection->quoteIdentifier(
$tableName
) . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE ' . $collate
);
}
$sqlLines = [
'ALTER TABLE `song_history` ADD CONSTRAINT FK_2AD16164A0BDB2F3 FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE CASCADE',
'ALTER TABLE `station_media` ADD CONSTRAINT FK_32AADE3AA0BDB2F3 FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE SET NULL',
];
foreach ($sqlLines as $sql) {
$this->addSql($sql);
}
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->changeCharset('utf8mb4_unicode_ci');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180826043500.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 592 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20210805004608 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add author and e-mail to podcast table.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE podcast ADD author VARCHAR(255) NOT NULL, ADD email VARCHAR(255) NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE podcast DROP author, DROP email');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20210805004608.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 133 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180417041534 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE custom_field ADD short_name VARCHAR(100) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE custom_field DROP short_name');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180417041534.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 115 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20171022005913 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts ADD remote_type VARCHAR(50) DEFAULT NULL, ADD remote_url VARCHAR(255) DEFAULT NULL, ADD remote_mount VARCHAR(150) DEFAULT NULL, ADD remote_source_username VARCHAR(100) DEFAULT NULL, ADD remote_source_password VARCHAR(100) DEFAULT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts DROP remote_type, DROP remote_url, DROP remote_mount, DROP remote_source_username, DROP remote_source_password');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20171022005913.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 201 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20210207015534 extends AbstractMigration
{
public function getDescription(): string
{
return 'Expand smallint fields in "song_history" to full integers.';
}
public function up(Schema $schema): void
{
$this->addSql(
'ALTER TABLE song_history CHANGE listeners_end listeners_end INT DEFAULT NULL, CHANGE delta_total delta_total INT NOT NULL, CHANGE delta_positive delta_positive INT NOT NULL, CHANGE delta_negative delta_negative INT NOT NULL, CHANGE unique_listeners unique_listeners INT DEFAULT NULL'
);
}
public function down(Schema $schema): void
{
$this->addSql(
'ALTER TABLE song_history CHANGE listeners_end listeners_end SMALLINT DEFAULT NULL, CHANGE unique_listeners unique_listeners SMALLINT DEFAULT NULL, CHANGE delta_total delta_total SMALLINT NOT NULL, CHANGE delta_positive delta_positive SMALLINT NOT NULL, CHANGE delta_negative delta_negative SMALLINT NOT NULL'
);
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20210207015534.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 222 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170522052114 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts ADD is_public TINYINT(1) NOT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts DROP is_public');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170522052114.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 143 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20230525022221 extends AbstractMigration
{
public function getDescription(): string
{
return 'Enforce enum fields.';
}
public function up(Schema $schema): void
{
$this->addSql(
<<<'SQL'
UPDATE `users` SET theme=NULL
WHERE theme = ''
SQL
);
$this->addSql(
<<<'SQL'
UPDATE `station_remotes` SET autodj_format=NULL
WHERE autodj_format = ''
SQL
);
$this->addSql(
<<<'SQL'
UPDATE `station_playlists` SET remote_type=NULL
WHERE remote_type = ''
SQL
);
$this->addSql(
<<<'SQL'
UPDATE `station_mounts` SET autodj_format=NULL
WHERE autodj_format = ''
SQL
);
$this->addSql(
<<<'SQL'
UPDATE `station_hls_streams` SET format=NULL
WHERE format = ''
SQL
);
$this->addSql(
<<<'SQL'
UPDATE `settings` SET ip_source=NULL
WHERE ip_source = ''
SQL
);
$this->addSql(
<<<'SQL'
UPDATE `settings` SET public_theme=NULL
WHERE public_theme = ''
SQL
);
$this->addSql(
<<<'SQL'
UPDATE `settings` SET analytics=NULL
WHERE analytics = ''
SQL
);
}
public function down(Schema $schema): void
{
// Noop
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230525022221.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 365 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20210528211201 extends AbstractMigration
{
public function getDescription(): string
{
return 'Rename "users" table identifier to "id".';
}
public function up(Schema $schema): void
{
// Automatically renames all foreign key constraints too. Handy!
$this->addSql('ALTER TABLE users RENAME COLUMN uid TO id');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE users RENAME COLUMN id TO uid');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20210528211201.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 138 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200826084718 extends AbstractMigration
{
public function getDescription(): string
{
return 'Fix an oopsie with incorrect decimals.';
}
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, 2)');
}
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` NUMERIC(7, 2)');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20200826084718.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 182 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20210828034409 extends AbstractMigration
{
public function getDescription(): string
{
return 'Remove redundant backup results column.';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE settings DROP backup_last_result');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE settings ADD backup_last_result LONGTEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20210828034409.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 170 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190715231530 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE relays (id INT AUTO_INCREMENT NOT NULL, base_url VARCHAR(255) NOT NULL, name VARCHAR(100) DEFAULT NULL, is_visible_on_public_pages TINYINT(1) NOT NULL, nowplaying LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\', created_at INT NOT NULL, updated_at INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE station_remotes ADD relay_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE station_remotes ADD CONSTRAINT FK_779D0E8A68A482E FOREIGN KEY (relay_id) REFERENCES relays (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_779D0E8A68A482E ON station_remotes (relay_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_remotes DROP FOREIGN KEY FK_779D0E8A68A482E');
$this->addSql('DROP TABLE relays');
$this->addSql('DROP INDEX IDX_779D0E8A68A482E ON station_remotes');
$this->addSql('ALTER TABLE station_remotes DROP relay_id');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190715231530.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 353 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20220608113502 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add ACME settings to Settings table.';
}
public function up(Schema $schema): void
{
$this->addSql(
'ALTER TABLE settings ADD acme_email VARCHAR(255) DEFAULT NULL, ADD acme_domains VARCHAR(255) DEFAULT NULL'
);
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE settings DROP acme_email, DROP acme_domains');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20220608113502.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 144 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Remove remote_ fields from station_mounts as they're now in their own table.
*/
final class Version20180909060758 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts DROP remote_type, DROP remote_url, DROP remote_mount, DROP remote_source_username, DROP remote_source_password');
}
public function postup(Schema $schema): void
{
$stations = $this->connection->fetchAllAssociative("SELECT id FROM station WHERE frontend_type = 'remote'");
foreach ($stations as $station) {
$this->connection->delete('station_mounts', [
'station_id' => $station['id'],
]);
}
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts ADD remote_type VARCHAR(50) DEFAULT NULL COLLATE utf8mb4_general_ci, ADD remote_url VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_general_ci, ADD remote_mount VARCHAR(150) DEFAULT NULL COLLATE utf8mb4_general_ci, ADD remote_source_username VARCHAR(100) DEFAULT NULL COLLATE utf8mb4_general_ci, ADD remote_source_password VARCHAR(100) DEFAULT NULL COLLATE utf8mb4_general_ci');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180909060758.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 301 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190128035353 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station ADD storage_quota BIGINT DEFAULT NULL, ADD storage_used BIGINT DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP storage_quota, DROP storage_used');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190128035353.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 123 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210126191431 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add mount/remote to listeners.';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE listener ADD mount_id INT DEFAULT NULL, ADD remote_id INT DEFAULT NULL');
$this->addSql(
'ALTER TABLE listener ADD CONSTRAINT FK_959C3422538228B8 FOREIGN KEY (mount_id) REFERENCES station_mounts (id) ON DELETE SET NULL'
);
$this->addSql(
'ALTER TABLE listener ADD CONSTRAINT FK_959C34222A3E9C94 FOREIGN KEY (remote_id) REFERENCES station_remotes (id) ON DELETE SET NULL'
);
$this->addSql('CREATE INDEX IDX_959C3422538228B8 ON listener (mount_id)');
$this->addSql('CREATE INDEX IDX_959C34222A3E9C94 ON listener (remote_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE listener DROP FOREIGN KEY FK_959C3422538228B8');
$this->addSql('ALTER TABLE listener DROP FOREIGN KEY FK_959C34222A3E9C94');
$this->addSql('DROP INDEX IDX_959C3422538228B8 ON listener');
$this->addSql('DROP INDEX IDX_959C34222A3E9C94 ON listener');
$this->addSql('ALTER TABLE listener DROP mount_id, DROP remote_id');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20210126191431.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 414 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170423202805 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station ADD url VARCHAR(255) DEFAULT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP url');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170423202805.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 135 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170803050109 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
// Empty migration accidentally committed.
$this->addSql('-- "Ignore Migration"');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
// Empty migration accidentally committed.
$this->addSql('-- "Ignore Migration"');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170803050109.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 141 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use App\Entity\Migration\Traits\UpdateAllRecords;
use DateTime;
use DateTimeZone;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190513163051 extends AbstractMigration
{
use UpdateAllRecords;
public function up(Schema $schema): void
{
// Move "play once per day" playlists to be standard scheduled ones with the same start/end time.
$this->addSql('UPDATE station_playlists SET type="scheduled", schedule_start_time=play_once_time, schedule_end_time=play_once_time, schedule_days=play_once_days WHERE type = "once_per_day"');
$this->addSql('ALTER TABLE station ADD timezone VARCHAR(100) DEFAULT NULL');
$this->addSql('ALTER TABLE station_playlists DROP play_once_time, DROP play_once_days');
$this->addSql('ALTER TABLE users DROP timezone');
}
public function postup(Schema $schema): void
{
// Use the system setting for "global timezone" to set the station timezones.
$globalTz = $this->connection->fetchOne('SELECT setting_value FROM settings WHERE setting_key="timezone"');
if (!empty($globalTz)) {
$globalTz = json_decode($globalTz, true, 512, JSON_THROW_ON_ERROR);
} else {
$globalTz = 'UTC';
}
// Set all stations' timezones to this value.
$this->updateAllRecords('station', [
'timezone' => $globalTz,
]);
// Calculate the offset of any currently scheduled playlists.
if ('UTC' !== $globalTz) {
$systemTz = new DateTimeZone('UTC');
$systemDt = new DateTime('now', $systemTz);
$systemOffset = $systemTz->getOffset($systemDt);
$appTz = new DateTimeZone($globalTz);
$appDt = new DateTime('now', $appTz);
$appOffset = $appTz->getOffset($appDt);
$offset = $systemOffset - $appOffset;
$offsetHours = (int)floor($offset / 3600);
if (0 !== $offsetHours) {
$playlists = $this->connection->fetchAllAssociative(
'SELECT sp.* FROM station_playlists AS sp WHERE sp.type = "scheduled"'
);
foreach ($playlists as $playlist) {
$this->connection->update('station_playlists', [
'schedule_start_time' => $this->applyOffset($playlist['schedule_start_time'], $offsetHours),
'schedule_end_time' => $this->applyOffset($playlist['schedule_end_time'], $offsetHours),
], [
'id' => $playlist['id'],
]);
}
}
}
}
/**
* @param mixed $timeCode
* @param int $offsetHours
*
* @return int
* @noinspection SummerTimeUnsafeTimeManipulationInspection
*/
private function applyOffset(mixed $timeCode, int $offsetHours): int
{
$hours = (int)floor($timeCode / 100);
$mins = $timeCode % 100;
$hours += $offsetHours;
$hours %= 24;
if ($hours < 0) {
$hours += 24;
}
return ($hours * 100) + $mins;
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP timezone');
$this->addSql('ALTER TABLE station_playlists ADD play_once_time SMALLINT NOT NULL, ADD play_once_days VARCHAR(50) DEFAULT NULL COLLATE utf8mb4_general_ci');
$this->addSql('ALTER TABLE users ADD timezone VARCHAR(100) DEFAULT NULL COLLATE utf8mb4_general_ci');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190513163051.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 856 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20220405031647 extends AbstractMigration
{
public function getDescription(): string
{
return 'Split indices up in station_queue.';
}
public function up(Schema $schema): void
{
$this->addSql('DROP INDEX idx_cued_status ON station_queue');
$this->addSql('DROP INDEX idx_played_status ON station_queue');
$this->addSql('CREATE INDEX idx_is_played ON station_queue (is_played)');
$this->addSql('CREATE INDEX idx_timestamp_played ON station_queue (timestamp_played)');
$this->addSql('CREATE INDEX idx_sent_to_autodj ON station_queue (sent_to_autodj)');
$this->addSql('CREATE INDEX idx_timestamp_cued ON station_queue (timestamp_cued)');
}
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX idx_is_played ON station_queue');
$this->addSql('DROP INDEX idx_timestamp_played ON station_queue');
$this->addSql('DROP INDEX idx_sent_to_autodj ON station_queue');
$this->addSql('DROP INDEX idx_timestamp_cued ON station_queue');
$this->addSql('CREATE INDEX idx_cued_status ON station_queue (sent_to_autodj, timestamp_cued)');
$this->addSql('CREATE INDEX idx_played_status ON station_queue (is_played, timestamp_played)');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20220405031647.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 331 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20171124184831 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media DROP art');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media ADD art LONGBLOB DEFAULT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20171124184831.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 113 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use App\Entity\Attributes\StableMigration;
use Doctrine\DBAL\Schema\Schema;
#[StableMigration('0.20.2')]
final class Version20240710235245 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add uploaded_at field to station media.';
}
public function preUp(Schema $schema): void
{
$this->connection->executeQuery(
<<<'SQL'
DELETE FROM unprocessable_media WHERE mtime IS NULL
SQL
);
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media ADD uploaded_at INT NOT NULL AFTER mtime');
$this->addSql('ALTER TABLE unprocessable_media CHANGE mtime mtime INT NOT NULL');
}
public function postUp(Schema $schema): void
{
$this->connection->executeQuery(
<<<'SQL'
UPDATE station_media SET uploaded_at=IF(mtime = 0, UNIX_TIMESTAMP(), mtime)
SQL
);
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media DROP uploaded_at');
$this->addSql('ALTER TABLE unprocessable_media CHANGE mtime mtime INT DEFAULT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20240710235245.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 290 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20161003041904 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
// Apply the original database schema.
$initialSql = [
'SET NAMES utf8mb4',
'SET FOREIGN_KEY_CHECKS=0',
'CREATE TABLE IF NOT EXISTS `action` (`id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `analytics` (`id` int(11) NOT NULL AUTO_INCREMENT, `station_id` int(11) DEFAULT NULL, `type` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `timestamp` int(11) NOT NULL, `number_min` int(11) NOT NULL, `number_max` int(11) NOT NULL, `number_avg` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `IDX_EAC2E68821BDB235` (`station_id`), KEY `search_idx` (`type`,`timestamp`), CONSTRAINT `FK_EAC2E68821BDB235` FOREIGN KEY (`station_id`) REFERENCES `station` (`id`) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `api_keys` (`id` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `owner` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, `calls_made` int(11) NOT NULL, `created` int(11) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `role` (`id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `role_has_action` (`role_id` int(11) NOT NULL, `action_id` int(11) NOT NULL, PRIMARY KEY (`role_id`,`action_id`), KEY `IDX_E4DAF125D60322AC` (`role_id`), KEY `IDX_E4DAF1259D32F035` (`action_id`), CONSTRAINT `FK_E4DAF1259D32F035` FOREIGN KEY (`action_id`) REFERENCES `action` (`id`) ON DELETE CASCADE, CONSTRAINT `FK_E4DAF125D60322AC` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `settings` (`setting_key` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `setting_value` longtext COLLATE utf8_unicode_ci COMMENT \'(DC2Type:json)\', PRIMARY KEY (`setting_key`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `songs` (`id` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `text` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, `artist` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, `title` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, `created` int(11) NOT NULL, `play_count` int(11) NOT NULL, `last_played` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `search_idx` (`text`,`artist`,`title`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `song_history` (`id` int(11) NOT NULL AUTO_INCREMENT, `song_id` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `station_id` int(11) NOT NULL, `timestamp_start` int(11) NOT NULL, `listeners_start` int(11) DEFAULT NULL, `timestamp_end` int(11) NOT NULL, `listeners_end` smallint(6) DEFAULT NULL, `delta_total` smallint(6) NOT NULL, `delta_positive` smallint(6) NOT NULL, `delta_negative` smallint(6) NOT NULL, `delta_points` longtext COLLATE utf8_unicode_ci COMMENT \'(DC2Type:json)\', PRIMARY KEY (`id`), KEY `IDX_2AD16164A0BDB2F3` (`song_id`), KEY `IDX_2AD1616421BDB235` (`station_id`), KEY `sort_idx` (`timestamp_start`), CONSTRAINT `FK_2AD1616421BDB235` FOREIGN KEY (`station_id`) REFERENCES `station` (`id`) ON DELETE CASCADE, CONSTRAINT `FK_2AD16164A0BDB2F3` FOREIGN KEY (`song_id`) REFERENCES `songs` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `station` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `frontend_type` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `frontend_config` longtext COLLATE utf8_unicode_ci COMMENT \'(DC2Type:json)\', `backend_type` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `backend_config` longtext COLLATE utf8_unicode_ci COMMENT \'(DC2Type:json)\', `description` longtext COLLATE utf8_unicode_ci, `radio_base_dir` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `nowplaying_data` longtext COLLATE utf8_unicode_ci COMMENT \'(DC2Type:json)\', `automation_settings` longtext COLLATE utf8_unicode_ci COMMENT \'(DC2Type:json)\', `automation_timestamp` int(11) DEFAULT NULL, `enable_requests` tinyint(1) NOT NULL, `request_delay` int(11) DEFAULT NULL, `enable_streamers` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `station_media` ( `id` int(11) NOT NULL AUTO_INCREMENT, `station_id` int(11) NOT NULL, `song_id` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `title` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, `artist` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, `album` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, `length` smallint(6) NOT NULL, `length_text` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `path` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `mtime` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `path_unique_idx` (`path`), KEY `IDX_32AADE3A21BDB235` (`station_id`), KEY `IDX_32AADE3AA0BDB2F3` (`song_id`), KEY `search_idx` (`title`,`artist`,`album`), CONSTRAINT `FK_32AADE3A21BDB235` FOREIGN KEY (`station_id`) REFERENCES `station` (`id`) ON DELETE CASCADE, CONSTRAINT `FK_32AADE3AA0BDB2F3` FOREIGN KEY (`song_id`) REFERENCES `songs` (`id`) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `station_playlists` ( `id` int(11) NOT NULL AUTO_INCREMENT, `station_id` int(11) NOT NULL, `name` varchar(200) COLLATE utf8_unicode_ci NOT NULL, `type` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `is_enabled` tinyint(1) NOT NULL, `play_per_songs` smallint(6) NOT NULL, `play_per_minutes` smallint(6) NOT NULL, `schedule_start_time` smallint(6) NOT NULL, `schedule_end_time` smallint(6) NOT NULL, `play_once_time` smallint(6) NOT NULL, `weight` smallint(6) NOT NULL, `include_in_automation` tinyint(1) NOT NULL, PRIMARY KEY (`id`), KEY `IDX_DC827F7421BDB235` (`station_id`), CONSTRAINT `FK_DC827F7421BDB235` FOREIGN KEY (`station_id`) REFERENCES `station` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `station_playlist_has_media` ( `media_id` int(11) NOT NULL, `playlists_id` int(11) NOT NULL, PRIMARY KEY (`media_id`,`playlists_id`), KEY `IDX_668E6486EA9FDD75` (`media_id`), KEY `IDX_668E64869F70CF56` (`playlists_id`), CONSTRAINT `FK_668E64869F70CF56` FOREIGN KEY (`playlists_id`) REFERENCES `station_playlists` (`id`) ON DELETE CASCADE, CONSTRAINT `FK_668E6486EA9FDD75` FOREIGN KEY (`media_id`) REFERENCES `station_media` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `station_requests` ( `id` int(11) NOT NULL AUTO_INCREMENT, `station_id` int(11) NOT NULL, `track_id` int(11) NOT NULL, `timestamp` int(11) NOT NULL, `played_at` int(11) NOT NULL, `ip` varchar(40) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `IDX_F71F0C0721BDB235` (`station_id`), KEY `IDX_F71F0C075ED23C43` (`track_id`), CONSTRAINT `FK_F71F0C0721BDB235` FOREIGN KEY (`station_id`) REFERENCES `station` (`id`) ON DELETE CASCADE, CONSTRAINT `FK_F71F0C075ED23C43` FOREIGN KEY (`track_id`) REFERENCES `station_media` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `station_streamers` ( `id` int(11) NOT NULL AUTO_INCREMENT, `station_id` int(11) NOT NULL, `streamer_username` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `streamer_password` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `comments` longtext COLLATE utf8_unicode_ci, `is_active` tinyint(1) NOT NULL, PRIMARY KEY (`id`), KEY `IDX_5170063E21BDB235` (`station_id`), CONSTRAINT `FK_5170063E21BDB235` FOREIGN KEY (`station_id`) REFERENCES `station` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `users` ( `uid` int(11) NOT NULL AUTO_INCREMENT, `email` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `auth_password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `auth_last_login_time` int(11) DEFAULT NULL, `auth_recovery_code` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `gender` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, `customization` longtext COLLATE utf8_unicode_ci COMMENT \'(DC2Type:json)\', PRIMARY KEY (`uid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `user_has_role` ( `user_id` int(11) NOT NULL, `role_id` int(11) NOT NULL, PRIMARY KEY (`user_id`,`role_id`), KEY `IDX_EAB8B535A76ED395` (`user_id`), KEY `IDX_EAB8B535D60322AC` (`role_id`), CONSTRAINT `FK_EAB8B535A76ED395` FOREIGN KEY (`user_id`) REFERENCES `users` (`uid`) ON DELETE CASCADE, CONSTRAINT `FK_EAB8B535D60322AC` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE IF NOT EXISTS `user_manages_station` ( `user_id` int(11) NOT NULL, `station_id` int(11) NOT NULL, PRIMARY KEY (`user_id`,`station_id`), KEY `IDX_2453B56BA76ED395` (`user_id`), KEY `IDX_2453B56B21BDB235` (`station_id`), CONSTRAINT `FK_2453B56B21BDB235` FOREIGN KEY (`station_id`) REFERENCES `station` (`id`) ON DELETE CASCADE, CONSTRAINT `FK_2453B56BA76ED395` FOREIGN KEY (`user_id`) REFERENCES `users` (`uid`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci',
'CREATE TABLE role_has_actions (id INT AUTO_INCREMENT NOT NULL, station_id INT DEFAULT NULL, role_id INT NOT NULL, action_id INT NOT NULL, INDEX IDX_50EEC1BDD60322AC (role_id), INDEX IDX_50EEC1BD21BDB235 (station_id), UNIQUE INDEX role_action_unique_idx (role_id, action_id, station_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
'ALTER TABLE role_has_actions ADD CONSTRAINT FK_50EEC1BD21BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE',
'INSERT INTO role_has_actions (role_id, action_id) SELECT role_id, action_id FROM role_has_action',
'DROP TABLE role_has_action',
'ALTER TABLE action ADD is_global TINYINT(1) NOT NULL',
'UPDATE action SET is_global=1',
'SET FOREIGN_KEY_CHECKS=1',
];
foreach ($initialSql as $sqlLine) {
$this->addSql($sqlLine);
}
$actions = [
['view administration', 1],
['administer settings', 1],
['administer api keys', 1],
['administer user accounts', 1],
['administer permissions', 1],
['administer stations', 1],
['view station management', 0],
['view station reports', 0],
['manage station profile', 0],
['manage station broadcasting', 0],
['manage station streamers', 0],
['manage station media', 0],
['manage station automation', 0],
];
foreach ($actions as $action) {
$this->addSql('DELETE FROM action WHERE name = :name', [
'name' => $action[0],
], [
'string' => 'string',
]);
$this->addSql('INSERT INTO action (name, is_global) VALUES (:name, :is_global)', [
'name' => $action[0],
'is_global' => $action[1],
], [
'string' => 'string',
'int' => 'int',
]);
}
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20161003041904.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 3,431 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170619044014 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts ADD authhash VARCHAR(255) DEFAULT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts DROP authhash');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170619044014.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 141 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20230428062001 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add "IP Source" setting.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE settings ADD ip_source VARCHAR(50) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE settings DROP ip_source');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230428062001.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 121 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* 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)');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20200825183243.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 182 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20220603065416 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add HLS fields.';
}
public function up(Schema $schema): void
{
$this->addSql(
'CREATE TABLE station_hls_streams (id INT AUTO_INCREMENT NOT NULL, station_id INT NOT NULL, name VARCHAR(100) NOT NULL, format VARCHAR(10) DEFAULT NULL, bitrate SMALLINT DEFAULT NULL, INDEX IDX_9ECC9CD021BDB235 (station_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_general_ci` ENGINE = InnoDB'
);
$this->addSql(
'ALTER TABLE station_hls_streams ADD CONSTRAINT FK_9ECC9CD021BDB235 FOREIGN KEY (station_id) REFERENCES station (id) ON DELETE CASCADE'
);
$this->addSql('ALTER TABLE station ADD enable_hls TINYINT(1) NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE station_hls_streams');
$this->addSql('ALTER TABLE station DROP enable_hls');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20220603065416.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 276 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170424042111 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts DROP enable_streamers');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_mounts ADD enable_streamers TINYINT(1) NOT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170424042111.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 145 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20230829093303 extends AbstractMigration
{
public function getDescription(): string
{
return 'Expand station media genre field.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media CHANGE genre genre VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media CHANGE genre genre VARCHAR(30) DEFAULT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230829093303.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 128 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20230601043650 extends AbstractMigration
{
public function getDescription(): string
{
return 'Remove serialized NowPlaying field for AzuraRelays.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE relays DROP nowplaying');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE relays ADD nowplaying LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\'');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230601043650.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 135 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200213052842 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add administrator password storage for remote relays.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_remotes ADD admin_password VARCHAR(100) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_remotes DROP admin_password');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20200213052842.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 140 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210717164419 extends AbstractMigration
{
public function getDescription(): string
{
return 'Make some fields that should never be nullable non-nullable.';
}
public function preUp(Schema $schema): void
{
$this->setEmptyWhereNull('api_keys', 'comment');
$this->setEmptyWhereNull('custom_field', 'short_name');
$this->setEmptyWhereNull('station', 'name');
$this->setEmptyWhereNull('station', 'short_name');
$this->setEmptyWhereNull('users', 'email');
$this->setEmptyWhereNull('users', 'auth_password');
$this->setEmptyWhereNull('storage_location', 'path');
$this->setEmptyWhereNull('station_remotes', 'url');
}
private function setEmptyWhereNull(string $table, string $field): void
{
$this->connection->update(
$table,
[$field => ''],
[$field => null]
);
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE api_keys CHANGE comment comment VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE custom_field CHANGE short_name short_name VARCHAR(100) NOT NULL');
$this->addSql(
'ALTER TABLE station CHANGE name name VARCHAR(100) NOT NULL, CHANGE short_name short_name VARCHAR(100) NOT NULL'
);
$this->addSql(
'ALTER TABLE users CHANGE email email VARCHAR(100) NOT NULL, CHANGE auth_password auth_password VARCHAR(255) NOT NULL'
);
$this->addSql('ALTER TABLE storage_location CHANGE path path VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE station_remotes CHANGE url url VARCHAR(255) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(
'ALTER TABLE api_keys CHANGE comment comment VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`'
);
$this->addSql(
'ALTER TABLE custom_field CHANGE short_name short_name VARCHAR(100) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`'
);
$this->addSql(
'ALTER TABLE station CHANGE name name VARCHAR(100) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, CHANGE short_name short_name VARCHAR(100) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`'
);
$this->addSql(
'ALTER TABLE users CHANGE email email VARCHAR(100) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, CHANGE auth_password auth_password VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`'
);
$this->addSql(
'ALTER TABLE storage_location CHANGE path path VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`'
);
$this->addSql(
'ALTER TABLE station_remotes CHANGE url url VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`'
);
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20210717164419.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 782 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180324053351 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station ADD is_enabled TINYINT(1) NOT NULL');
}
public function postup(Schema $schema): void
{
$this->connection->executeStatement('UPDATE station SET is_enabled=1');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP is_enabled');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180324053351.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 147 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190719220017 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_playlists ADD played_at INT NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_playlists DROP played_at');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190719220017.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 114 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use App\Entity\Attributes\StableMigration;
use Doctrine\DBAL\Schema\Schema;
#[StableMigration('0.17.4')]
final class Version20221008043751 extends AbstractMigration
{
public function getDescription(): string
{
return 'Remove stations that were mis-created.';
}
public function up(Schema $schema): void
{
$this->addSql(
<<<'SQL'
DELETE
FROM station
WHERE media_storage_location_id IS NULL
OR recordings_storage_location_id IS NULL
OR podcasts_storage_location_id IS NULL
SQL
);
}
public function down(Schema $schema): void
{
// Noop
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20221008043751.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 164 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20210203030115 extends AbstractMigration
{
public function getDescription(): string
{
return 'Migrate advanced features setting to database.';
}
public function up(Schema $schema): void
{
// No-op
$this->addSql('SELECT 1');
}
public function postUp(Schema $schema): void
{
$this->connection->delete(
'settings',
[
'setting_key' => 'enableAdvancedFeatures',
]
);
$this->connection->insert(
'settings',
[
'setting_key' => 'enableAdvancedFeatures',
'setting_value' => 'true',
]
);
}
public function down(Schema $schema): void
{
// No-op
$this->addSql('SELECT 1');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20210203030115.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 203 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190813210707 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE audit_log (id INT AUTO_INCREMENT NOT NULL, timestamp INT NOT NULL, operation SMALLINT NOT NULL, class VARCHAR(255) NOT NULL, identifier VARCHAR(255) NOT NULL, target_class VARCHAR(255) DEFAULT NULL, target VARCHAR(255) DEFAULT NULL, changes LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', user VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ENGINE = InnoDB');
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE audit_log');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190813210707.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 201 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170619171323 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media CHANGE cue_in cue_in NUMERIC(5, 1) DEFAULT NULL, CHANGE cue_out cue_out NUMERIC(5, 1) DEFAULT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media CHANGE cue_in cue_in NUMERIC(3, 1) DEFAULT NULL, CHANGE cue_out cue_out NUMERIC(3, 1) DEFAULT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170619171323.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 189 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180415235105 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE station_media_custom_field (id INT AUTO_INCREMENT NOT NULL, media_id INT NOT NULL, field_id INT NOT NULL, field_value VARCHAR(255) DEFAULT NULL, INDEX IDX_35DC02AAEA9FDD75 (media_id), INDEX IDX_35DC02AA443707B0 (field_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE custom_field (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE station_media_custom_field ADD CONSTRAINT FK_35DC02AAEA9FDD75 FOREIGN KEY (media_id) REFERENCES station_media (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE station_media_custom_field ADD CONSTRAINT FK_35DC02AA443707B0 FOREIGN KEY (field_id) REFERENCES custom_field (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_media_custom_field DROP FOREIGN KEY FK_35DC02AA443707B0');
$this->addSql('DROP TABLE station_media_custom_field');
$this->addSql('DROP TABLE custom_field');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180415235105.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 363 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Schema\Schema;
final class Version20201027130504 extends AbstractMigration
{
public function getDescription(): string
{
return 'Song storage consolidation, part 2.';
}
public function preUp(Schema $schema): void
{
// Create temp index
$this->addSql(
'CREATE INDEX IDX_TEMP_CONVERT ON station_media (path, storage_location_id, station_id)'
);
// Create initial backup directory.
$this->connection->insert(
'storage_location',
[
'type' => 'backup',
'adapter' => 'local',
'path' => '/var/azuracast/backups',
]
);
$storageLocationId = $this->connection->lastInsertId();
$this->connection->update(
'settings',
[
'setting_value' => $storageLocationId,
],
[
'setting_key' => 'backup_storage_location',
]
);
// Migrate existing directories to new StorageLocation paradigm.
$stations = $this->connection->fetchAllAssociative(
'SELECT id, radio_base_dir, radio_media_dir, storage_quota FROM station WHERE media_storage_location_id IS NULL ORDER BY id ASC'
);
$directories = [];
foreach ($stations as $row) {
$stationId = $row['id'];
$baseDir = $row['radio_base_dir'];
$mediaDir = $row['radio_media_dir'];
if (empty($mediaDir)) {
$mediaDir = $baseDir . '/media';
}
if (isset($directories[$mediaDir])) {
$directories[$mediaDir]['stations'][] = $stationId;
} else {
$directories[$mediaDir] = [
'stations' => [$stationId],
'storageQuota' => $row['storage_quota'],
'albumArtDir' => $baseDir . '/album_art',
'waveformsDir' => $baseDir . '/waveforms',
];
}
// Create recordings dir.
$this->connection->insert(
'storage_location',
[
'type' => 'station_recordings',
'adapter' => 'local',
'path' => $baseDir . '/recordings',
'storage_quota' => $row['storage_quota'],
]
);
$recordingsStorageLocationId = $this->connection->lastInsertId();
$this->connection->update(
'station',
[
'recordings_storage_location_id' => $recordingsStorageLocationId,
],
[
'id' => $stationId,
]
);
}
foreach ($directories as $path => $dirInfo) {
$newAlbumArtDir = $path . '/.albumart';
rename($dirInfo['albumArtDir'], $newAlbumArtDir);
$newWaveformsDir = $path . '/.waveforms';
rename($dirInfo['waveformsDir'], $newWaveformsDir);
$this->connection->insert(
'storage_location',
[
'type' => 'station_media',
'adapter' => 'local',
'path' => $path,
'storage_quota' => $dirInfo['storageQuota'],
]
);
$mediaStorageLocationId = $this->connection->lastInsertId();
foreach ($dirInfo['stations'] as $stationId) {
$this->connection->update(
'station',
[
'media_storage_location_id' => $mediaStorageLocationId,
],
[
'id' => $stationId,
]
);
}
$firstStationId = array_shift($dirInfo['stations']);
$this->connection->executeQuery(
'UPDATE station_media SET storage_location_id=? WHERE station_id = ?',
[
$mediaStorageLocationId,
$firstStationId,
],
[
ParameterType::INTEGER,
ParameterType::INTEGER,
]
);
foreach ($dirInfo['stations'] as $stationId) {
$media = $this->connection->fetchAllAssociative(
'SELECT sm.id, sm.path FROM station_media AS sm WHERE sm.station_id = ?',
[
$stationId,
],
[
ParameterType::INTEGER,
]
);
foreach ($media as [$oldMediaId, $mediaPath]) {
$newMediaId = $this->connection->fetchOne(
'SELECT sm.id FROM station_media AS sm WHERE sm.path = ? AND sm.storage_location_id = ?',
[
$mediaPath,
$mediaStorageLocationId,
],
[
ParameterType::STRING,
ParameterType::INTEGER,
]
);
if ($newMediaId) {
$tablesToUpdate = [
'song_history' => 'media_id',
'station_playlist_media' => 'media_id',
'station_queue' => 'media_id',
'station_requests' => 'track_id',
];
foreach ($tablesToUpdate as $table => $fieldName) {
$this->connection->update(
$table,
[
$fieldName => $newMediaId,
],
[
$fieldName => $oldMediaId,
]
);
}
}
}
$this->connection->executeQuery(
'DELETE FROM station_media WHERE station_id = ?',
[
$stationId,
],
[
ParameterType::INTEGER,
]
);
}
}
// Drop temp index
$this->addSql('DROP INDEX IDX_TEMP_CONVERT ON station_media');
}
public function up(Schema $schema): void
{
$this->addSql(
'ALTER TABLE station_media ADD CONSTRAINT FK_32AADE3ACDDD8AF FOREIGN KEY (storage_location_id) REFERENCES storage_location (id) ON DELETE CASCADE'
);
$this->addSql('CREATE INDEX IDX_32AADE3ACDDD8AF ON station_media (storage_location_id)');
$this->addSql('CREATE UNIQUE INDEX path_unique_idx ON station_media (path, storage_location_id)');
$this->addSql('ALTER TABLE station DROP radio_media_dir, DROP storage_quota, DROP storage_used');
$this->addSql('ALTER TABLE station_media DROP station_id');
}
public function down(Schema $schema): void
{
$this->addSql(
'ALTER TABLE station ADD radio_media_dir VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, ADD storage_quota BIGINT DEFAULT NULL, ADD storage_used BIGINT DEFAULT NULL'
);
$this->addSql('ALTER TABLE station_media ADD station_id INT NOT NULL');
$this->addSql('ALTER TABLE station_media DROP FOREIGN KEY FK_32AADE3ACDDD8AF');
$this->addSql('DROP INDEX IDX_32AADE3ACDDD8AF ON station_media');
$this->addSql('DROP INDEX path_unique_idx ON station_media');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20201027130504.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 1,511 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190930201744 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE custom_field ADD auto_assign VARCHAR(100) DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE custom_field DROP auto_assign');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190930201744.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 115 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170516215536 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('CREATE INDEX search_idx ON listener (listener_uid, timestamp_end)');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX search_idx ON listener');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170516215536.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 137 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190624135222 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_remotes CHANGE source_port source_port SMALLINT UNSIGNED DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_remotes CHANGE source_port source_port SMALLINT DEFAULT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190624135222.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 124 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170906080352 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station ADD adapter_api_key VARCHAR(150) DEFAULT NULL, ADD nowplaying_timestamp INT DEFAULT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP adapter_api_key, DROP nowplaying_timestamp');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170906080352.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 152 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20220610132810 extends AbstractMigration
{
public function getDescription(): string
{
return 'Remove automation settings.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP automation_settings, DROP automation_timestamp');
$this->addSql('ALTER TABLE station_playlists DROP include_in_automation');
}
public function down(Schema $schema): void
{
$this->addSql(
'ALTER TABLE station ADD automation_settings LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', ADD automation_timestamp INT DEFAULT NULL'
);
$this->addSql('ALTER TABLE station_playlists ADD include_in_automation TINYINT(1) NOT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20220610132810.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 184 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20170512082741 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE song_history ADD request_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE song_history ADD CONSTRAINT FK_2AD16164427EB8A5 FOREIGN KEY (request_id) REFERENCES station_requests (id) ON DELETE CASCADE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2AD16164427EB8A5 ON song_history (request_id)');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE song_history DROP FOREIGN KEY FK_2AD16164427EB8A5');
$this->addSql('DROP INDEX UNIQ_2AD16164427EB8A5 ON song_history');
$this->addSql('ALTER TABLE song_history DROP request_id');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20170512082741.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 256 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20240319113446 extends AbstractMigration
{
public function getDescription(): string
{
return 'Remove Doctrine type annotations from earlier DBAL versions.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE analytics CHANGE moment moment DATETIME NOT NULL');
$this->addSql('ALTER TABLE audit_log CHANGE changes changes JSON NOT NULL');
$this->addSql('ALTER TABLE podcast CHANGE id id CHAR(36) NOT NULL');
$this->addSql('ALTER TABLE podcast_category CHANGE podcast_id podcast_id CHAR(36) NOT NULL');
$this->addSql('ALTER TABLE podcast_episode DROP INDEX UNIQ_77EB2BD017421B18, ADD INDEX IDX_77EB2BD017421B18 (playlist_media_id)');
$this->addSql('ALTER TABLE podcast_episode CHANGE id id CHAR(36) NOT NULL, CHANGE podcast_id podcast_id CHAR(36) NOT NULL');
$this->addSql('ALTER TABLE podcast_media CHANGE id id CHAR(36) NOT NULL, CHANGE episode_id episode_id CHAR(36) DEFAULT NULL');
$this->addSql('ALTER TABLE settings CHANGE app_unique_identifier app_unique_identifier CHAR(36) NOT NULL, CHANGE update_results update_results JSON DEFAULT NULL');
$this->addSql('ALTER TABLE song_history CHANGE delta_points delta_points JSON DEFAULT NULL');
$this->addSql('ALTER TABLE station CHANGE frontend_config frontend_config JSON DEFAULT NULL, CHANGE backend_config backend_config JSON DEFAULT NULL, CHANGE branding_config branding_config JSON DEFAULT NULL');
$this->addSql('ALTER TABLE station_webhooks CHANGE triggers triggers JSON DEFAULT NULL, CHANGE config config JSON DEFAULT NULL, CHANGE metadata metadata JSON DEFAULT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE podcast CHANGE id id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\'');
$this->addSql('ALTER TABLE song_history CHANGE delta_points delta_points LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\'');
$this->addSql('ALTER TABLE podcast_media CHANGE id id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', CHANGE episode_id episode_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:guid)\'');
$this->addSql('ALTER TABLE audit_log CHANGE changes changes LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\'');
$this->addSql('ALTER TABLE station_webhooks CHANGE triggers triggers LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', CHANGE config config LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', CHANGE metadata metadata LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\'');
$this->addSql('ALTER TABLE settings CHANGE app_unique_identifier app_unique_identifier CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', CHANGE update_results update_results LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\'');
$this->addSql('ALTER TABLE analytics CHANGE moment moment DATETIME NOT NULL COMMENT \'(DC2Type:carbon_immutable)\'');
$this->addSql('ALTER TABLE podcast_category CHANGE podcast_id podcast_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\'');
$this->addSql('ALTER TABLE podcast_episode DROP INDEX IDX_77EB2BD017421B18, ADD UNIQUE INDEX UNIQ_77EB2BD017421B18 (playlist_media_id)');
$this->addSql('ALTER TABLE podcast_episode CHANGE id id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\', CHANGE podcast_id podcast_id CHAR(36) NOT NULL COMMENT \'(DC2Type:guid)\'');
$this->addSql('ALTER TABLE station CHANGE frontend_config frontend_config LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', CHANGE backend_config backend_config LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', CHANGE branding_config branding_config LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\'');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20240319113446.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 885 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use App\Entity\Migration\Traits\UpdateAllRecords;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180429013130 extends AbstractMigration
{
use UpdateAllRecords;
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_playlists ADD playback_order VARCHAR(50) NOT NULL, ADD remote_url VARCHAR(255) DEFAULT NULL');
}
public function postup(Schema $schema): void
{
$this->updateAllRecords('station_playlists', [
'source' => 'songs',
'playback_order' => 'random',
]);
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_playlists DROP playback_order, DROP remote_url');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20180429013130.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 195 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20230626102616 extends AbstractMigration
{
public function getDescription(): string
{
return 'Store theme at the browser level, not the user level.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE users DROP theme');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE users ADD theme VARCHAR(25) DEFAULT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230626102616.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 124 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20190517122806 extends AbstractMigration
{
public function up(Schema $schema): void
{
// Mitigate an issue affecting some playlists.
$this->addSql('UPDATE station_playlists SET remote_type="stream" WHERE remote_type IS NULL OR remote_type NOT IN ("playlist", "stream")');
}
public function down(Schema $schema): void
{
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20190517122806.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 110 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20230531054836 extends AbstractMigration
{
public function getDescription(): string
{
return 'Remove DB-level Now Playing cache for stations.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station DROP nowplaying, DROP nowplaying_timestamp');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station ADD nowplaying LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\', ADD nowplaying_timestamp INT DEFAULT NULL');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20230531054836.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 143 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20191101075303 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_playlists DROP schedule_start_time, DROP schedule_end_time, DROP schedule_days');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_playlists ADD schedule_start_time SMALLINT NOT NULL, ADD schedule_end_time SMALLINT NOT NULL, ADD schedule_days VARCHAR(50) DEFAULT NULL COLLATE utf8mb4_general_ci');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20191101075303.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 153 |
```php
<?php
declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
final class Version20210703185549 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add columns to facilitate "loop once" functionality.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE station_playlists ADD queue_reset_at INT NOT NULL');
$this->addSql('ALTER TABLE station_schedules ADD loop_once TINYINT(1) NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE station_playlists DROP queue_reset_at');
$this->addSql('ALTER TABLE station_schedules DROP loop_once');
}
}
``` | /content/code_sandbox/backend/src/Entity/Migration/Version20210703185549.php | php | 2016-04-30T21:41:23 | 2024-08-16T18:27:26 | AzuraCast | AzuraCast/AzuraCast | 2,978 | 167 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.