2020-06-08 20:32:42 +00:00
|
|
|
<?php
|
2020-08-04 11:25:22 +00:00
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
* Class AddEpisodes Creates episodes 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-10 15:00:12 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
2020-06-08 20:32:42 +00:00
|
|
|
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
|
|
|
|
class AddEpisodes extends Migration
|
|
|
|
{
|
2021-05-06 14:00:48 +00:00
|
|
|
public function up(): void
|
2020-06-08 20:32:42 +00:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'id' => [
|
2020-10-29 15:45:19 +00:00
|
|
|
'type' => 'INT',
|
2020-06-08 20:32:42 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
'auto_increment' => true,
|
|
|
|
],
|
|
|
|
'podcast_id' => [
|
2020-10-29 15:45:19 +00:00
|
|
|
'type' => 'INT',
|
2020-06-08 20:32:42 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-08-21 08:41:09 +00:00
|
|
|
'guid' => [
|
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 15:45:19 +00:00
|
|
|
'constraint' => 255,
|
2020-08-21 08:41:09 +00:00
|
|
|
],
|
2020-06-08 20:32:42 +00:00
|
|
|
'title' => [
|
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 15:45:19 +00:00
|
|
|
'constraint' => 128,
|
2020-06-08 20:32:42 +00:00
|
|
|
],
|
|
|
|
'slug' => [
|
|
|
|
'type' => 'VARCHAR',
|
2021-08-13 11:07:29 +00:00
|
|
|
'constraint' => 128,
|
2020-06-08 20:32:42 +00:00
|
|
|
],
|
2021-12-14 16:41:10 +00:00
|
|
|
'audio_id' => [
|
2020-10-06 15:39:27 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-10-29 15:45:19 +00:00
|
|
|
'description_markdown' => [
|
|
|
|
'type' => 'TEXT',
|
|
|
|
],
|
|
|
|
'description_html' => [
|
2020-06-08 20:32:42 +00:00
|
|
|
'type' => 'TEXT',
|
|
|
|
],
|
2021-12-14 16:41:10 +00:00
|
|
|
'cover_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2021-04-02 17:20:02 +00:00
|
|
|
'null' => true,
|
|
|
|
],
|
2021-12-14 16:41:10 +00:00
|
|
|
'transcript_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2020-11-24 20:18:08 +00:00
|
|
|
'null' => true,
|
|
|
|
],
|
2021-12-14 16:41:10 +00:00
|
|
|
'transcript_remote_url' => [
|
2021-05-03 17:39:58 +00:00
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 512,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2021-12-14 16:41:10 +00:00
|
|
|
'chapters_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2020-11-24 20:18:08 +00:00
|
|
|
'null' => true,
|
|
|
|
],
|
2021-12-14 16:41:10 +00:00
|
|
|
'chapters_remote_url' => [
|
2021-05-03 17:39:58 +00:00
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 512,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2020-10-02 15:38:16 +00:00
|
|
|
'parental_advisory' => [
|
|
|
|
'type' => 'ENUM',
|
|
|
|
'constraint' => ['clean', 'explicit'],
|
|
|
|
'null' => true,
|
2020-06-08 20:32:42 +00:00
|
|
|
],
|
2020-06-12 19:31:10 +00:00
|
|
|
'number' => [
|
2020-06-08 20:32:42 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2020-08-21 08:41:09 +00:00
|
|
|
'null' => true,
|
2020-06-08 20:32:42 +00:00
|
|
|
],
|
|
|
|
'season_number' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2020-08-21 08:41:09 +00:00
|
|
|
'null' => true,
|
2020-06-26 14:34:52 +00:00
|
|
|
],
|
2020-06-08 20:32:42 +00:00
|
|
|
'type' => [
|
|
|
|
'type' => 'ENUM',
|
2020-08-21 08:41:09 +00:00
|
|
|
'constraint' => ['trailer', 'full', 'bonus'],
|
2020-06-08 20:32:42 +00:00
|
|
|
'default' => 'full',
|
|
|
|
],
|
2020-10-29 15:45:19 +00:00
|
|
|
'is_blocked' => [
|
2020-06-08 20:32:42 +00:00
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => 1,
|
|
|
|
'default' => 0,
|
2020-08-14 18:27:57 +00:00
|
|
|
],
|
2020-12-23 14:11:38 +00:00
|
|
|
'location_name' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 128,
|
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'location_geo' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 32,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2021-05-17 17:11:23 +00:00
|
|
|
'location_osm' => [
|
2020-12-23 14:11:38 +00:00
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 12,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2021-03-19 16:12:36 +00:00
|
|
|
'custom_rss' => [
|
|
|
|
'type' => 'JSON',
|
|
|
|
'null' => true,
|
|
|
|
],
|
2021-08-13 11:07:29 +00:00
|
|
|
'posts_count' => [
|
2021-04-02 17:20:02 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
'default' => 0,
|
|
|
|
],
|
2021-08-13 11:07:29 +00:00
|
|
|
'comments_count' => [
|
2021-04-02 17:20:02 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
'default' => 0,
|
|
|
|
],
|
2022-09-28 15:02:09 +00:00
|
|
|
'is_premium' => [
|
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => 1,
|
|
|
|
'default' => 0,
|
|
|
|
],
|
2020-08-14 18:27:57 +00:00
|
|
|
'created_by' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'updated_by' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'published_at' => [
|
|
|
|
'type' => 'DATETIME',
|
|
|
|
'null' => true,
|
2020-06-08 20:32:42 +00:00
|
|
|
],
|
|
|
|
'created_at' => [
|
2020-10-29 15:45:19 +00:00
|
|
|
'type' => 'DATETIME',
|
2020-06-08 20:32:42 +00:00
|
|
|
],
|
|
|
|
'updated_at' => [
|
2020-10-29 15:45:19 +00:00
|
|
|
'type' => 'DATETIME',
|
2020-06-08 20:32:42 +00:00
|
|
|
],
|
|
|
|
]);
|
2021-04-02 17:20:02 +00:00
|
|
|
$this->forge->addPrimaryKey('id');
|
2020-06-08 20:32:42 +00:00
|
|
|
$this->forge->addUniqueKey(['podcast_id', 'slug']);
|
2021-06-08 09:52:11 +00:00
|
|
|
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
|
2021-12-14 16:41:10 +00:00
|
|
|
$this->forge->addForeignKey('audio_id', 'media', 'id');
|
2021-12-17 17:14:37 +00:00
|
|
|
$this->forge->addForeignKey('cover_id', 'media', 'id', '', 'SET NULL');
|
|
|
|
$this->forge->addForeignKey('transcript_id', 'media', 'id', '', 'SET NULL');
|
|
|
|
$this->forge->addForeignKey('chapters_id', 'media', 'id', '', 'SET NULL');
|
2020-08-14 18:27:57 +00:00
|
|
|
$this->forge->addForeignKey('created_by', 'users', 'id');
|
|
|
|
$this->forge->addForeignKey('updated_by', 'users', 'id');
|
2020-06-08 20:32:42 +00:00
|
|
|
$this->forge->createTable('episodes');
|
2022-06-17 10:44:05 +00:00
|
|
|
|
|
|
|
// Add Full-Text Search index on title and description_markdown
|
|
|
|
$prefix = $this->db->getPrefix();
|
|
|
|
$createQuery = <<<CODE_SAMPLE
|
|
|
|
ALTER TABLE {$prefix}episodes
|
|
|
|
ADD FULLTEXT(title, description_markdown);
|
|
|
|
CODE_SAMPLE;
|
|
|
|
$this->db->query($createQuery);
|
2020-06-08 20:32:42 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
public function down(): void
|
2020-06-08 20:32:42 +00:00
|
|
|
{
|
|
|
|
$this->forge->dropTable('episodes');
|
|
|
|
}
|
|
|
|
}
|