Skip to content
Snippets Groups Projects
2021-06-05-170000_add_episodes.php 5.55 KiB
Newer Older
  • Learn to ignore specific revisions
  •  * Class AddEpisodes Creates episodes table in database
    
     * @copyright  2020 Ad Aures
    
     * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
     * @link       https://castopod.org/
     */
    
    class AddEpisodes extends BaseMigration
    
                    'type'           => 'INT',
                    'unsigned'       => true,
    
                    'auto_increment' => true,
                ],
                'podcast_id' => [
    
                'description_markdown' => [
                    'type' => 'TEXT',
                ],
                'description_html' => [
    
                    'constraint' => ['clean', 'explicit'],
    
                    'constraint' => ['trailer', 'full', 'bonus'],
    
                'location_name' => [
    
                    'constraint' => 128,
    
                ],
                'location_geo' => [
    
                    'constraint' => 32,
    
                    'constraint' => 12,
    
                    'unsigned' => true,
                ],
                'updated_by' => [
    
                    'unsigned' => true,
                ],
                'published_at' => [
                    'type' => 'DATETIME',
                    'null' => true,
    
            $this->forge->addUniqueKey(['podcast_id', 'slug']);
    
            $this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
    
            $this->forge->addForeignKey('audio_id', 'media', 'id');
    
            $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');
    
            $this->forge->addForeignKey('created_by', 'users', 'id');
            $this->forge->addForeignKey('updated_by', 'users', 'id');
    
            $this->forge->createTable('episodes');
    
    
            // Add Full-Text Search index on title and description_markdown
            $prefix = $this->db->getPrefix();
    
                ALTER TABLE {$prefix}episodes
    
                ADD FULLTEXT title (title, description_markdown);
            SQL;
    
            $this->db->query($createQuery);