castopod/app/Database/Migrations/2020-07-03-191500_add_users...

49 lines
1.2 KiB
PHP

<?php
/**
* Class AddLanguages
* Creates languages 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 AddUsersPodcasts extends Migration
{
public function up()
{
$this->forge->addField([
'user_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'podcast_id' => [
'type' => 'BIGINT',
'constraint' => 20,
'unsigned' => true,
],
'group_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
]);
$this->forge->addPrimaryKey(['user_id', 'podcast_id']);
$this->forge->addForeignKey('user_id', 'users', 'id');
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id');
$this->forge->addForeignKey('group_id', 'auth_groups', 'id');
$this->forge->createTable('users_podcasts');
}
public function down()
{
$this->forge->dropTable('users_podcasts');
}
}