Skip to content
Snippets Groups Projects
2021-05-30-101500_add_podcasts.php 6.58 KiB
Newer Older
  • Learn to ignore specific revisions
  •  * Class AddPodcasts Creates podcasts table in database
    
     * @copyright  2020 Ad Aures
    
     * @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 AddPodcasts extends Migration
    {
    
        {
            $this->forge->addField([
                'id' => [
    
                    'unsigned' => true,
                    'auto_increment' => true,
                ],
    
                'guid' => [
                    'type' => 'CHAR',
                    'constraint' => 36,
                ],
    
                'actor_id' => [
                    'type' => 'INT',
                    'unsigned' => true,
    
                    'type' => 'VARCHAR',
    
                ],
                'title' => [
                    'type' => 'VARCHAR',
                    'constraint' => 128,
    
                'description_markdown' => [
                    'type' => 'TEXT',
                ],
                'description_html' => [
    
                    'type' => 'TEXT',
                ],
    
                'cover_id' => [
                    'type' => 'INT',
                    'unsigned' => true,
    
                'banner_id' => [
                    'type' => 'INT',
                    'unsigned' => true,
    
                    'type' => 'VARCHAR',
                    'constraint' => 2,
                ],
    
                'category_id' => [
                    'type' => 'INT',
                    'unsigned' => true,
                    'default' => 0,
    
                'parental_advisory' => [
                    'type' => 'ENUM',
                    'constraint' => ['clean', 'explicit'],
                    'null' => true,
    
                    'type' => 'VARCHAR',
    
                    'type' => 'VARCHAR',
    
                    'type' => 'VARCHAR',
    
                    'null' => true,
                ],
                'type' => [
                    'type' => 'ENUM',
                    'constraint' => ['episodic', 'serial'],
                    'default' => 'episodic',
                ],
                'copyright' => [
                    'type' => 'VARCHAR',
    
                    'constraint' => 128,
                    'null' => true,
                ],
                'episode_description_footer_markdown' => [
                    'type' => 'TEXT',
    
                'episode_description_footer_html' => [
    
                    'type' => 'TINYINT',
                    'constraint' => 1,
                    'default' => 0,
                ],
    
                    'type' => 'TINYINT',
                    'constraint' => 1,
                    'default' => 0,
                ],
    
                    'type' => 'TINYINT',
                    'constraint' => 1,
                    'default' => 1,
    
                'imported_feed_url' => [
                    'type' => 'VARCHAR',
    
                    'comment' =>
                        'The RSS feed URL if this podcast was imported, NULL otherwise.',
                    'null' => true,
                ],
    
                'new_feed_url' => [
                    'type' => 'VARCHAR',
    
                    'comment' =>
                        'The RSS new feed URL if this podcast is moving out, NULL otherwise.',
                    'null' => true,
    
                ],
                'payment_pointer' => [
                    'type' => 'VARCHAR',
                    'constraint' => 128,
                    'comment' => 'Wallet address for Web Monetization payments',
                    'null' => true,
    
                ],
                'location_name' => [
                    'type' => 'VARCHAR',
                    'constraint' => 128,
                    'null' => true,
                ],
                'location_geo' => [
                    'type' => 'VARCHAR',
                    'constraint' => 32,
                    'null' => true,
                ],
    
                    'type' => 'VARCHAR',
                    'constraint' => 12,
                    'null' => true,
    
                ],
                'partner_id' => [
                    'type' => 'VARCHAR',
                    'constraint' => 32,
                    'null' => true,
                ],
                'partner_link_url' => [
                    'type' => 'VARCHAR',
                    'constraint' => 512,
                    'null' => true,
                ],
                'partner_image_url' => [
                    'type' => 'VARCHAR',
                    'constraint' => 512,
    
                'is_premium_by_default' => [
                    'type' => 'TINYINT',
                    'constraint' => 1,
                    'default' => 0,
                ],
    
                'created_by' => [
                    'type' => 'INT',
                    'unsigned' => true,
                ],
                'updated_by' => [
                    'type' => 'INT',
                    'unsigned' => true,
                ],
    
                'published_at' => [
                    'type' => 'DATETIME',
                    'null' => true,
                ],
    
                'created_at' => [
    
                ],
                'updated_at' => [
    
            // TODO: remove name in favor of username from actor
    
            $this->forge->addUniqueKey('handle');
    
            $this->forge->addUniqueKey('guid');
    
            $this->forge->addUniqueKey('actor_id');
    
            $this->forge->addForeignKey('actor_id', config('Fediverse')->tablesPrefix . 'actors', 'id', '', 'CASCADE');
    
            $this->forge->addForeignKey('cover_id', 'media', 'id');
    
            $this->forge->addForeignKey('banner_id', 'media', 'id', '', 'SET NULL');
    
            $this->forge->addForeignKey('category_id', 'categories', 'id');
    
            $this->forge->addForeignKey('language_code', 'languages', 'code');
    
            $this->forge->addForeignKey('created_by', 'users', 'id');
            $this->forge->addForeignKey('updated_by', 'users', 'id');
    
            $this->forge->createTable('podcasts');
        }
    
    
        {
            $this->forge->dropTable('podcasts');
        }
    }