2020-10-02 17:38:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class AddPodcastsCategories
|
|
|
|
* Creates podcasts_categories 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 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-04-02 19:20:02 +02:00
|
|
|
$this->forge->addForeignKey(
|
|
|
|
'podcast_id',
|
|
|
|
'podcasts',
|
|
|
|
'id',
|
2021-05-12 16:00:25 +02:00
|
|
|
'',
|
2021-04-02 19:20:02 +02:00
|
|
|
'CASCADE',
|
|
|
|
);
|
|
|
|
$this->forge->addForeignKey(
|
|
|
|
'category_id',
|
|
|
|
'categories',
|
|
|
|
'id',
|
2021-05-12 16:00:25 +02:00
|
|
|
'',
|
2021-04-02 19:20:02 +02:00
|
|
|
'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');
|
|
|
|
}
|
|
|
|
}
|