2020-10-02 17:38:16 +02:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 11:52:11 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-10-02 17:38:16 +02:00
|
|
|
/**
|
2021-05-19 18:35:13 +02:00
|
|
|
* Class AddPodcastsCategories Creates podcasts_categories table in database
|
2020-10-02 17:38:16 +02:00
|
|
|
*
|
2022-02-19 17:06:11 +01:00
|
|
|
* @copyright 2020 Ad Aures
|
2020-10-02 17:38:16 +02:00
|
|
|
* @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 AddPodcastsCategories extends Migration
|
|
|
|
{
|
2021-05-06 16:00:48 +02:00
|
|
|
public function up(): void
|
2020-10-02 17:38:16 +02:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'podcast_id' => [
|
2020-10-29 16:45:19 +01:00
|
|
|
'type' => 'INT',
|
2020-10-02 17:38:16 +02:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'category_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
$this->forge->addPrimaryKey(['podcast_id', 'category_id']);
|
2021-06-08 11:52:11 +02:00
|
|
|
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->addForeignKey('category_id', 'categories', 'id', '', 'CASCADE');
|
2020-10-02 17:38:16 +02:00
|
|
|
$this->forge->createTable('podcasts_categories');
|
|
|
|
}
|
|
|
|
|
2021-05-06 16:00:48 +02:00
|
|
|
public function down(): void
|
2020-10-02 17:38:16 +02:00
|
|
|
{
|
|
|
|
$this->forge->dropTable('podcasts_categories');
|
|
|
|
}
|
|
|
|
}
|