public function __construct(Schema $schema) { $this->schema = $schema; $path = $schema->path() . 'sequences'; $this->sequences = array(); $this->file = new LockableFile(new File($path . '.cgi')); $this->lockFile = new MicrotimeLockFile(new File($path . '.lock.cgi')); }
protected function getRelation(Schema $schema, $relationName) { $relation = $schema->getRelation($relationName); if ($relation !== false) { if (!$this->ifNotExists) { return $this->environment->set_error("Relation {$relation->fullName()} already exists"); } else { return true; } } // Return anything not a boolean to continue on return 42; }
public function renameTable($old_table_name, $new_table_name, Schema $new_schema) { $oldTable = $this->getTable($old_table_name); if ($oldTable->exists()) { if (!$oldTable->temporary()) { $newTable = $new_schema->createTable($new_table_name, $oldTable->getColumns()); copy($oldTable->dataFile->getPath(), $newTable->dataFile->getPath()); copy($oldTable->dataLockFile->getPath(), $newTable->dataLockFile->getPath()); $this->dropTable($old_table_name); } else { $new_schema->loadedTables[$new_table_name] = $this->loadedTables[$old_table_name]; unset($this->loadedTables[$old_table_name]); } return true; } else { return false; } }
public function testDropTableTemp() { $name = 'blah'; $schema = new Schema($this->db, 'myschema'); $schema->create(); $schema->createTable($name, self::$columns, true); $passed = $schema->dropTable($name); $this->assertTrue($passed); $table = $schema->getTable($name); $this->assertFalse($table->exists()); }