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
|
|
|
*
|
|
|
|
* @copyright 2020 Podlibre
|
|
|
|
* @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-05-03 17:39:58 +00:00
|
|
|
'audio_file_path' => [
|
2020-06-08 20:32:42 +00:00
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 15:45:19 +00:00
|
|
|
'constraint' => 255,
|
2020-06-08 20:32:42 +00:00
|
|
|
],
|
2021-05-03 17:39:58 +00:00
|
|
|
'audio_file_duration' => [
|
2021-05-12 14:00:25 +00:00
|
|
|
// exact value for duration with max 99999,999 ~ 27.7 hours
|
|
|
|
'type' => 'DECIMAL(8,3)',
|
2020-09-04 09:09:26 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
'comment' => 'Playtime in seconds',
|
|
|
|
],
|
2021-05-03 17:39:58 +00:00
|
|
|
'audio_file_mimetype' => [
|
2020-09-04 09:09:26 +00:00
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 255,
|
|
|
|
],
|
2021-05-03 17:39:58 +00:00
|
|
|
'audio_file_size' => [
|
2020-09-04 09:09:26 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
'comment' => 'File size in bytes',
|
|
|
|
],
|
2021-05-03 17:39:58 +00:00
|
|
|
'audio_file_header_size' => [
|
2020-10-06 15:39:27 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
'comment' => 'Header size in bytes',
|
|
|
|
],
|
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-05-03 17:39:58 +00:00
|
|
|
'image_path' => [
|
2020-06-08 20:32:42 +00:00
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 15:45:19 +00:00
|
|
|
'constraint' => 255,
|
2020-06-30 18:17:41 +02:00
|
|
|
'null' => true,
|
2020-06-08 20:32:42 +00:00
|
|
|
],
|
2021-04-02 17:20:02 +00:00
|
|
|
// constraint is 13 because the longest safe mimetype for images is image/svg+xml,
|
|
|
|
// see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#image_types
|
|
|
|
'image_mimetype' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 13,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2021-05-03 17:39:58 +00:00
|
|
|
'transcript_file_path' => [
|
2020-11-24 20:18:08 +00:00
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 255,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2021-05-03 17:39:58 +00:00
|
|
|
'transcript_file_remote_url' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 512,
|
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'chapters_file_path' => [
|
2020-11-24 20:18:08 +00:00
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 255,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2021-05-03 17:39:58 +00:00
|
|
|
'chapters_file_remote_url' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 512,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2020-10-02 15:38:16 +00:00
|
|
|
'parental_advisory' => [
|
|
|
|
'type' => 'ENUM',
|
|
|
|
'constraint' => ['clean', 'explicit'],
|
|
|
|
'null' => true,
|
|
|
|
'default' => null,
|
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,
|
|
|
|
],
|
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
|
|
|
],
|
2020-06-30 18:17:41 +02:00
|
|
|
'deleted_at' => [
|
|
|
|
'type' => 'DATETIME',
|
|
|
|
'null' => true,
|
|
|
|
],
|
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');
|
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');
|
|
|
|
}
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
public function down(): void
|
2020-06-08 20:32:42 +00:00
|
|
|
{
|
|
|
|
$this->forge->dropTable('episodes');
|
|
|
|
}
|
|
|
|
}
|