Skip to content
Snippets Groups Projects
2020-05-29-152000_add_categories.php 1.25 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * Class AddCategories
     * Creates categories table in database
     *
     * @copyright  2020 Podlibre
     * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
     * @link       https://castopod.org/
     */
    
    use CodeIgniter\Database\Migration;
    
    
    class AddCategories extends Migration
    {
        public function up()
        {
            $this->forge->addField([
    
                'id' => [
                    'type' => 'INT',
                    'unsigned' => true,
    
                'parent_id' => [
                    'type' => 'INT',
                    'unsigned' => true,
    
                'code' => [
                    'type' => 'VARCHAR',
    
                ],
                'apple_category' => [
                    'type' => 'VARCHAR',
    
                    'type' => 'VARCHAR',
    
            $this->forge->addUniqueKey('code');
    
            $this->forge->addForeignKey('parent_id', 'categories', 'id');
            $this->forge->createTable('categories');
        }
    
        public function down()
        {
            $this->forge->dropTable('categories');
        }
    }