db->tableExists('teacher_class')) { $this->forge->addColumn('teacher_class', [ 'semester' => [ 'type' => 'VARCHAR', 'constraint' => 25, 'null' => false, 'default' => '', ], ]); } if ($this->db->tableExists('student_class')) { $this->forge->addColumn('student_class', [ 'semester' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => false, 'default' => '', ], ]); } } private function indexExists(string $table, string $index): bool { $result = $this->db->query( 'SHOW INDEX FROM `' . str_replace('`', '``', $table) . '` WHERE Key_name = ' . $this->db->escape($index) ); return $result->getNumRows() > 0; } }