2020-07-10 12:20:25 +00:00
|
|
|
<?php
|
2020-08-04 11:25:22 +00:00
|
|
|
|
2020-07-10 12:20:25 +00:00
|
|
|
/**
|
2021-04-02 17:20:02 +00:00
|
|
|
* Class AddPodcastUsers
|
|
|
|
* Creates podcast_users table in database
|
2020-07-10 12:20:25 +00:00
|
|
|
*
|
|
|
|
* @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;
|
|
|
|
|
2020-10-29 15:45:19 +00:00
|
|
|
class AddPodcastsUsers extends Migration
|
2020-07-10 12:20:25 +00:00
|
|
|
{
|
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
$this->forge->addField([
|
2020-10-29 15:45:19 +00:00
|
|
|
'podcast_id' => [
|
2020-07-10 12:20:25 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-10-29 15:45:19 +00:00
|
|
|
'user_id' => [
|
|
|
|
'type' => 'INT',
|
2020-07-10 12:20:25 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-07-31 16:05:10 +00:00
|
|
|
'group_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-07-10 12:20:25 +00:00
|
|
|
]);
|
2020-07-16 10:08:23 +00:00
|
|
|
$this->forge->addPrimaryKey(['user_id', 'podcast_id']);
|
2021-04-02 17:20:02 +00:00
|
|
|
$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',
|
|
|
|
);
|
2020-10-29 15:45:19 +00:00
|
|
|
$this->forge->createTable('podcasts_users');
|
2020-07-10 12:20:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function down()
|
|
|
|
{
|
2020-10-29 15:45:19 +00:00
|
|
|
$this->forge->dropTable('podcasts_users');
|
2020-07-10 12:20:25 +00:00
|
|
|
}
|
|
|
|
}
|