2021-02-10 16:20:01 +00:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-02-10 16:20:01 +00:00
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
* Class AddPodcastsPersons Creates podcasts_persons table in database
|
2021-02-10 16:20:01 +00:00
|
|
|
*
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2020 Ad Aures
|
2021-02-10 16:20:01 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
|
2023-06-13 16:05:02 +00:00
|
|
|
class AddPodcastsPersons extends BaseMigration
|
2021-02-10 16:20:01 +00:00
|
|
|
{
|
2021-05-06 14:00:48 +00:00
|
|
|
public function up(): void
|
2021-02-10 16:20:01 +00:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2021-02-10 16:20:01 +00:00
|
|
|
'auto_increment' => true,
|
|
|
|
],
|
|
|
|
'podcast_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2021-02-10 16:20:01 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'person_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2021-02-10 16:20:01 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'person_group' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'VARCHAR',
|
2021-02-10 16:20:01 +00:00
|
|
|
'constraint' => 32,
|
|
|
|
],
|
|
|
|
'person_role' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'VARCHAR',
|
2021-02-10 16:20:01 +00:00
|
|
|
'constraint' => 32,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
$this->forge->addKey('id', true);
|
2021-05-19 16:35:13 +00:00
|
|
|
$this->forge->addUniqueKey(['podcast_id', 'person_id', 'person_group', 'person_role']);
|
2021-06-08 09:52:11 +00:00
|
|
|
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->addForeignKey('person_id', 'persons', 'id', '', 'CASCADE');
|
2021-02-10 16:20:01 +00:00
|
|
|
$this->forge->createTable('podcasts_persons');
|
|
|
|
}
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
public function down(): void
|
2021-02-10 16:20:01 +00:00
|
|
|
{
|
|
|
|
$this->forge->dropTable('podcasts_persons');
|
|
|
|
}
|
|
|
|
}
|