private function getRevisionId() { if ($this->revisionId === null) { $date = date_create("now")->format($this->platform->getDateTimeFormatString()); if ($this->config->getCurrentUser() != null) { $userId = $this->config->getCurrentUser()->getId(); } else { $userId = null; } $this->conn->insert($this->config->getRevisionTableName(), array('timestamp' => $date, 'user_id' => $userId, 'note' => $this->config->getNote(), 'ipaddress' => $this->config->getIpAddress())); $sequenceName = $this->platform->supportsSequences() ? 'REVISIONS_ID_SEQ' : null; $this->revisionId = $this->conn->lastInsertId($sequenceName); } return $this->revisionId; }
/** * Get the SQL Statements to drop the given schema from underlying db. * * @param Schema $dropSchema * @return array */ public function getDropSchema(Schema $dropSchema) { $visitor = new DropSchemaSqlCollector($this->platform); $sm = $this->conn->getSchemaManager(); $fullSchema = $sm->createSchema(); foreach ($fullSchema->getTables() as $table) { if ($dropSchema->hasTable($table->getName())) { $visitor->acceptTable($table); } foreach ($table->getForeignKeys() as $foreignKey) { if (!$dropSchema->hasTable($table->getName())) { continue; } if (!$dropSchema->hasTable($foreignKey->getForeignTableName())) { continue; } $visitor->acceptForeignKey($table, $foreignKey); } } if (!$this->platform->supportsSequences()) { return $visitor->getQueries(); } foreach ($dropSchema->getSequences() as $sequence) { $visitor->acceptSequence($sequence); } foreach ($dropSchema->getTables() as $table) { /* @var $sequence Table */ if (!$table->hasPrimaryKey()) { continue; } $columns = $table->getPrimaryKey()->getColumns(); if (count($columns) > 1) { continue; } $checkSequence = $table->getName() . "_" . $columns[0] . "_seq"; if ($fullSchema->hasSequence($checkSequence)) { $visitor->acceptSequence($fullSchema->getSequence($checkSequence)); } } return $visitor->getQueries(); }