2020-06-08 16:25:23 +02:00
|
|
|
<?php
|
2020-08-04 11:25:22 +00:00
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-06-08 16:25:23 +02:00
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
* Class AddAddPodcastsPlatforms Creates podcasts_platforms table in database
|
2020-06-10 15:00:12 +00:00
|
|
|
*
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2020 Ad Aures
|
2020-06-08 16:25:23 +02:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
2020-06-10 15:00:12 +00:00
|
|
|
|
2021-08-23 11:05:16 +00:00
|
|
|
namespace App\Database\Migrations;
|
2020-06-08 16:25:23 +02:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
use CodeIgniter\Database\Migration;
|
2020-06-08 16:25:23 +02:00
|
|
|
|
2020-10-29 15:45:19 +00:00
|
|
|
class AddPodcastsPlatforms extends Migration
|
2020-06-08 16:25:23 +02:00
|
|
|
{
|
2021-05-06 14:00:48 +00:00
|
|
|
public function up(): void
|
2020-06-08 16:25:23 +02:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'podcast_id' => [
|
2020-10-29 15:45:19 +00:00
|
|
|
'type' => 'INT',
|
2020-06-08 16:25:23 +02:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-11-18 17:17:56 +00:00
|
|
|
'platform_slug' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 32,
|
2020-06-08 16:25:23 +02:00
|
|
|
],
|
|
|
|
'link_url' => [
|
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 15:45:19 +00:00
|
|
|
'constraint' => 512,
|
2020-06-08 16:25:23 +02:00
|
|
|
],
|
2022-01-04 16:37:59 +00:00
|
|
|
'account_id' => [
|
2020-11-18 17:17:56 +00:00
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 128,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2020-10-29 15:45:19 +00:00
|
|
|
'is_visible' => [
|
2020-06-08 16:25:23 +02:00
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => 1,
|
|
|
|
'default' => 0,
|
|
|
|
],
|
2021-10-20 14:22:58 +00:00
|
|
|
'is_on_embed' => [
|
2021-02-27 21:21:26 +00:00
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => 1,
|
|
|
|
'default' => 0,
|
|
|
|
],
|
2020-06-08 16:25:23 +02:00
|
|
|
]);
|
2020-10-29 15:45:19 +00:00
|
|
|
|
2020-11-18 17:17:56 +00:00
|
|
|
$this->forge->addPrimaryKey(['podcast_id', 'platform_slug']);
|
2022-01-04 16:37:59 +00:00
|
|
|
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->addForeignKey('platform_slug', 'platforms', 'slug', 'CASCADE');
|
2020-11-18 17:17:56 +00:00
|
|
|
$this->forge->createTable('podcasts_platforms');
|
2020-06-08 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
public function down(): void
|
2020-06-08 16:25:23 +02:00
|
|
|
{
|
2020-11-18 17:17:56 +00:00
|
|
|
$this->forge->dropTable('podcasts_platforms');
|
2020-06-08 16:25:23 +02:00
|
|
|
}
|
|
|
|
}
|