2021-02-10 16:20:01 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class AddEpisodesPersons
|
|
|
|
* Creates episodes_persons table in database
|
|
|
|
*
|
|
|
|
* @copyright 2020 Podlibre
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
|
|
|
|
class AddEpisodesPersons extends Migration
|
|
|
|
{
|
2021-05-06 14:00:48 +00:00
|
|
|
public function up(): void
|
2021-02-10 16:20:01 +00:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
'auto_increment' => true,
|
|
|
|
],
|
|
|
|
'podcast_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'episode_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'person_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'person_group' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 32,
|
|
|
|
],
|
|
|
|
'person_role' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 32,
|
|
|
|
],
|
|
|
|
]);
|
2021-05-17 17:11:23 +00:00
|
|
|
$this->forge->addPrimaryKey('id', true);
|
2021-02-10 16:20:01 +00:00
|
|
|
$this->forge->addUniqueKey([
|
|
|
|
'podcast_id',
|
|
|
|
'episode_id',
|
|
|
|
'person_id',
|
|
|
|
'person_group',
|
|
|
|
'person_role',
|
|
|
|
]);
|
2021-04-02 17:20:02 +00:00
|
|
|
$this->forge->addForeignKey(
|
|
|
|
'podcast_id',
|
|
|
|
'podcasts',
|
|
|
|
'id',
|
2021-05-12 14:00:25 +00:00
|
|
|
'',
|
2021-04-02 17:20:02 +00:00
|
|
|
'CASCADE',
|
|
|
|
);
|
|
|
|
$this->forge->addForeignKey(
|
|
|
|
'episode_id',
|
|
|
|
'episodes',
|
|
|
|
'id',
|
2021-05-12 14:00:25 +00:00
|
|
|
'',
|
2021-04-02 17:20:02 +00:00
|
|
|
'CASCADE',
|
|
|
|
);
|
|
|
|
$this->forge->addForeignKey(
|
|
|
|
'person_id',
|
|
|
|
'persons',
|
|
|
|
'id',
|
2021-05-12 14:00:25 +00:00
|
|
|
'',
|
2021-04-02 17:20:02 +00:00
|
|
|
'CASCADE',
|
|
|
|
);
|
2021-02-10 16:20:01 +00:00
|
|
|
$this->forge->createTable('episodes_persons');
|
|
|
|
}
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
public function down(): void
|
2021-02-10 16:20:01 +00:00
|
|
|
{
|
|
|
|
$this->forge->dropTable('episodes_persons');
|
|
|
|
}
|
|
|
|
}
|