mirror of
https://code.castopod.org/adaures/castopod
synced 2025-05-13 01:35:47 +00:00
49 lines
1.3 KiB
PHP
49 lines
1.3 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([
|
||
|
'id' => [
|
||
|
'type' => 'BIGINT',
|
||
|
'constraint' => 20,
|
||
|
'unsigned' => true,
|
||
|
'auto_increment' => true,
|
||
|
],
|
||
|
'user_id' => [
|
||
|
'type' => 'INT',
|
||
|
'constraint' => 11,
|
||
|
'unsigned' => true,
|
||
|
],
|
||
|
'podcast_id' => [
|
||
|
'type' => 'BIGINT',
|
||
|
'constraint' => 20,
|
||
|
'unsigned' => true,
|
||
|
],
|
||
|
]);
|
||
|
$this->forge->addPrimaryKey('id');
|
||
|
$this->forge->addUniqueKey(['user_id', 'podcast_id']);
|
||
|
$this->forge->addForeignKey('user_id', 'users', 'id');
|
||
|
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id');
|
||
|
$this->forge->createTable('users_podcasts');
|
||
|
}
|
||
|
|
||
|
public function down()
|
||
|
{
|
||
|
$this->forge->dropTable('users_podcasts');
|
||
|
}
|
||
|
}
|