Newer
Older

Yassine Doghri
committed
<?php

Yassine Doghri
committed

Yassine Doghri
committed
/**
* Class AddPodcastUsers
* Creates podcast_users table in database

Yassine Doghri
committed
*
* @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 AddPodcastsUsers extends Migration

Yassine Doghri
committed
{
public function up()
{
$this->forge->addField([
'podcast_id' => [

Yassine Doghri
committed
'type' => 'INT',
'unsigned' => true,
],
'user_id' => [
'type' => 'INT',

Yassine Doghri
committed
'unsigned' => true,
],

Yassine Doghri
committed
'group_id' => [
'type' => 'INT',
'unsigned' => true,
],

Yassine Doghri
committed
]);
$this->forge->addPrimaryKey(['user_id', 'podcast_id']);
$this->forge->addForeignKey('user_id', 'users', 'id', false, 'CASCADE');
$this->forge->addForeignKey(
'podcast_id',
'podcasts',
'id',
false,
'CASCADE',
);
$this->forge->addForeignKey(
'group_id',
'auth_groups',
'id',
false,
'CASCADE',
);
$this->forge->createTable('podcasts_users');

Yassine Doghri
committed
}
public function down()
{
$this->forge->dropTable('podcasts_users');