/** * Drop Table * * Generates a platform-specific DROP TABLE string * * @param string $table Table name * @param bool $if_exists Whether to add an IF EXISTS condition * * @return string */ protected function _dropTable($table, $if_exists) { $sql = 'DROP TABLE'; if ($if_exists) { if ($this->dropTableIfStr === false) { if (!$this->db->tableExists($table)) { return true; } } else { $sql = sprintf($this->dropTableIfStr, $this->db->escapeIdentifiers($table)); } } return $sql . ' ' . $this->db->escapeIdentifiers($table); }
/** * Ensures that we have created our migrations table * in the database. */ protected function ensureTable() { if ($this->db->tableExists($this->table)) { return; } $forge = \Config\Database::forge(); $forge->addField(['version' => ['type' => 'BIGINT', 'constraint' => 20, 'null' => false], 'group' => ['type' => 'varchar', 'constraint' => 255, 'null' => false], 'time' => ['type' => 'timestamp', 'null' => false]]); $forge->createTable($this->table, true); }