/** * init sql * * @param string $name The table name * @param array $options The options definition of the table * * @return void */ protected function _initSql($name, $options = array()) { if (!is_array($options)) { $options = array(); } //are we forcing table creation? If so, drop it first if (array_key_exists('force', $options) && $options['force'] == true) { $this->_adapter->dropTable($name); } $temp = ''; if (array_key_exists('temporary', $options)) { $temp = ' TEMPORARY'; } $create_sql = sprintf('CREATE%s TABLE ', $temp); $create_sql .= sprintf("%s (\n", $this->_adapter->identifier($name)); $this->_sql .= $create_sql; $this->_initialized = true; }
/** */ public function testRenameTable() { try { $this->object->renameTable('', ''); $this->fail('renameTable does not accept empty string for original table name!'); } catch (Phigrate_Exception_Argument $ex) { $msg = 'Missing original table name parameter'; $this->assertEquals($msg, $ex->getMessage()); } try { $this->object->renameTable('users', ''); $this->fail('renameTable does not accept empty string for new table name!'); } catch (Phigrate_Exception_Argument $ex) { $msg = 'Missing new table name parameter'; $this->assertEquals($msg, $ex->getMessage()); } $sql = 'CREATE TABLE `users` (name varchar(20));'; $this->object->executeDdl($sql); $actual = $this->object->renameTable('users', 'contacts'); $this->assertTrue($actual); $this->assertFalse($this->object->tableExists('users', true)); $this->assertTrue($this->object->tableExists('contacts')); $this->object->dropTable('contacts'); }