2020-05-31 21:15:52 +02:00
|
|
|
<?php
|
2020-08-04 13:25:22 +02:00
|
|
|
|
2021-06-08 11:52:11 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-06-10 17:00:12 +02:00
|
|
|
/**
|
2021-05-19 18:35:13 +02:00
|
|
|
* Class AddPodcasts Creates podcasts table in database
|
2020-06-10 17:00:12 +02:00
|
|
|
*
|
2022-02-19 17:06:11 +01:00
|
|
|
* @copyright 2020 Ad Aures
|
2020-06-10 17:00:12 +02:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
2020-05-31 21:15:52 +02:00
|
|
|
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
|
2020-06-10 17:00:12 +02:00
|
|
|
use CodeIgniter\Database\Migration;
|
2020-05-31 21:15:52 +02:00
|
|
|
|
|
|
|
class AddPodcasts extends Migration
|
|
|
|
{
|
2021-05-06 16:00:48 +02:00
|
|
|
public function up(): void
|
2020-05-31 21:15:52 +02:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'id' => [
|
2020-10-29 16:45:19 +01:00
|
|
|
'type' => 'INT',
|
2020-05-31 21:15:52 +02:00
|
|
|
'unsigned' => true,
|
|
|
|
'auto_increment' => true,
|
|
|
|
],
|
2021-06-21 13:58:43 +02:00
|
|
|
'guid' => [
|
|
|
|
'type' => 'CHAR',
|
|
|
|
'constraint' => 36,
|
|
|
|
],
|
2021-04-02 19:20:02 +02:00
|
|
|
'actor_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2020-05-31 21:15:52 +02:00
|
|
|
],
|
2021-07-26 15:10:46 +02:00
|
|
|
'handle' => [
|
2020-05-31 21:15:52 +02:00
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 16:45:19 +01:00
|
|
|
'constraint' => 32,
|
2021-04-02 19:20:02 +02:00
|
|
|
],
|
|
|
|
'title' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 128,
|
2020-05-31 21:15:52 +02:00
|
|
|
],
|
2020-10-29 16:45:19 +01:00
|
|
|
'description_markdown' => [
|
|
|
|
'type' => 'TEXT',
|
|
|
|
],
|
|
|
|
'description_html' => [
|
2020-05-31 21:15:52 +02:00
|
|
|
'type' => 'TEXT',
|
|
|
|
],
|
2021-12-14 17:41:10 +01:00
|
|
|
'cover_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2021-11-01 18:12:03 +01:00
|
|
|
],
|
2021-12-14 17:41:10 +01:00
|
|
|
'banner_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2021-11-01 18:12:03 +01:00
|
|
|
'null' => true,
|
|
|
|
],
|
2020-10-29 16:45:19 +01:00
|
|
|
'language_code' => [
|
2020-05-31 21:15:52 +02:00
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 2,
|
|
|
|
],
|
2020-08-21 10:41:09 +02:00
|
|
|
'category_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
'default' => 0,
|
2020-05-31 21:15:52 +02:00
|
|
|
],
|
2020-10-02 17:38:16 +02:00
|
|
|
'parental_advisory' => [
|
|
|
|
'type' => 'ENUM',
|
|
|
|
'constraint' => ['clean', 'explicit'],
|
|
|
|
'null' => true,
|
2020-05-31 21:15:52 +02:00
|
|
|
],
|
2020-08-18 18:31:28 +02:00
|
|
|
'owner_name' => [
|
2020-05-31 21:15:52 +02:00
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 16:45:19 +01:00
|
|
|
'constraint' => 128,
|
2020-06-26 16:34:52 +02:00
|
|
|
],
|
2020-08-18 18:31:28 +02:00
|
|
|
'owner_email' => [
|
2020-05-31 21:15:52 +02:00
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 16:45:19 +01:00
|
|
|
'constraint' => 255,
|
2020-05-31 21:15:52 +02:00
|
|
|
],
|
2020-10-02 17:38:16 +02:00
|
|
|
'publisher' => [
|
2020-05-31 21:15:52 +02:00
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 16:45:19 +01:00
|
|
|
'constraint' => 128,
|
2020-05-31 21:15:52 +02:00
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'type' => [
|
|
|
|
'type' => 'ENUM',
|
|
|
|
'constraint' => ['episodic', 'serial'],
|
|
|
|
'default' => 'episodic',
|
|
|
|
],
|
|
|
|
'copyright' => [
|
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 16:45:19 +01:00
|
|
|
'constraint' => 128,
|
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'episode_description_footer_markdown' => [
|
|
|
|
'type' => 'TEXT',
|
2020-05-31 21:15:52 +02:00
|
|
|
'null' => true,
|
|
|
|
],
|
2020-10-29 16:45:19 +01:00
|
|
|
'episode_description_footer_html' => [
|
2020-10-20 15:46:00 +02:00
|
|
|
'type' => 'TEXT',
|
|
|
|
'null' => true,
|
|
|
|
],
|
2020-10-29 16:45:19 +01:00
|
|
|
'is_blocked' => [
|
2020-05-31 21:15:52 +02:00
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => 1,
|
|
|
|
'default' => 0,
|
|
|
|
],
|
2020-10-29 16:45:19 +01:00
|
|
|
'is_completed' => [
|
2020-05-31 21:15:52 +02:00
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => 1,
|
|
|
|
'default' => 0,
|
|
|
|
],
|
2020-10-29 16:45:19 +01:00
|
|
|
'is_locked' => [
|
2020-10-20 15:46:00 +02:00
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => 1,
|
|
|
|
'default' => 1,
|
2020-08-14 20:27:57 +02:00
|
|
|
],
|
2020-08-21 10:41:09 +02:00
|
|
|
'imported_feed_url' => [
|
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 16:45:19 +01:00
|
|
|
'constraint' => 512,
|
2020-08-21 10:41:09 +02:00
|
|
|
'comment' =>
|
|
|
|
'The RSS feed URL if this podcast was imported, NULL otherwise.',
|
|
|
|
'null' => true,
|
|
|
|
],
|
2020-10-06 17:39:27 +02:00
|
|
|
'new_feed_url' => [
|
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 16:45:19 +01:00
|
|
|
'constraint' => 512,
|
2020-10-06 17:39:27 +02:00
|
|
|
'comment' =>
|
|
|
|
'The RSS new feed URL if this podcast is moving out, NULL otherwise.',
|
|
|
|
'null' => true,
|
2020-11-26 19:53:52 +01:00
|
|
|
],
|
|
|
|
'payment_pointer' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 128,
|
|
|
|
'comment' => 'Wallet address for Web Monetization payments',
|
|
|
|
'null' => true,
|
2020-12-23 15:11:38 +01:00
|
|
|
],
|
|
|
|
'location_name' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 128,
|
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'location_geo' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 32,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2021-05-17 19:11:23 +02:00
|
|
|
'location_osm' => [
|
2020-12-23 15:11:38 +01:00
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 12,
|
|
|
|
'null' => true,
|
2021-03-19 17:12:36 +01:00
|
|
|
],
|
|
|
|
'custom_rss' => [
|
|
|
|
'type' => 'JSON',
|
2021-04-02 19:20:02 +02:00
|
|
|
'null' => true,
|
2021-03-30 18:21:00 +02:00
|
|
|
],
|
|
|
|
'partner_id' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 32,
|
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'partner_link_url' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 512,
|
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'partner_image_url' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 512,
|
2021-03-19 17:12:36 +01:00
|
|
|
'null' => true,
|
2020-10-06 17:39:27 +02:00
|
|
|
],
|
2020-10-20 15:46:00 +02:00
|
|
|
'created_by' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'updated_by' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-05-31 21:15:52 +02:00
|
|
|
'created_at' => [
|
2020-10-29 16:45:19 +01:00
|
|
|
'type' => 'DATETIME',
|
2020-05-31 21:15:52 +02:00
|
|
|
],
|
|
|
|
'updated_at' => [
|
2020-10-29 16:45:19 +01:00
|
|
|
'type' => 'DATETIME',
|
2020-05-31 21:15:52 +02:00
|
|
|
],
|
2020-06-30 18:17:41 +02:00
|
|
|
'deleted_at' => [
|
|
|
|
'type' => 'DATETIME',
|
|
|
|
'null' => true,
|
|
|
|
],
|
2020-05-31 21:15:52 +02:00
|
|
|
]);
|
2020-10-29 16:45:19 +01:00
|
|
|
|
2021-04-02 19:20:02 +02:00
|
|
|
$this->forge->addPrimaryKey('id');
|
2021-04-22 19:20:28 +02:00
|
|
|
// TODO: remove name in favor of username from actor
|
2021-07-26 15:10:46 +02:00
|
|
|
$this->forge->addUniqueKey('handle');
|
2021-06-21 13:58:43 +02:00
|
|
|
$this->forge->addUniqueKey('guid');
|
2021-04-22 19:20:28 +02:00
|
|
|
$this->forge->addUniqueKey('actor_id');
|
2021-08-27 12:58:22 +02:00
|
|
|
$this->forge->addForeignKey('actor_id', config('Fediverse')->tablesPrefix . 'actors', 'id', '', 'CASCADE');
|
2021-12-14 17:41:10 +01:00
|
|
|
$this->forge->addForeignKey('cover_id', 'media', 'id');
|
2021-12-17 18:14:37 +01:00
|
|
|
$this->forge->addForeignKey('banner_id', 'media', 'id', '', 'SET NULL');
|
2020-08-21 10:41:09 +02:00
|
|
|
$this->forge->addForeignKey('category_id', 'categories', 'id');
|
2020-10-29 16:45:19 +01:00
|
|
|
$this->forge->addForeignKey('language_code', 'languages', 'code');
|
2020-08-14 20:27:57 +02:00
|
|
|
$this->forge->addForeignKey('created_by', 'users', 'id');
|
|
|
|
$this->forge->addForeignKey('updated_by', 'users', 'id');
|
2020-05-31 21:15:52 +02:00
|
|
|
$this->forge->createTable('podcasts');
|
|
|
|
}
|
|
|
|
|
2021-05-06 16:00:48 +02:00
|
|
|
public function down(): void
|
2020-05-31 21:15:52 +02:00
|
|
|
{
|
|
|
|
$this->forge->dropTable('podcasts');
|
|
|
|
}
|
|
|
|
}
|