change_column() public method

Change a column
public change_column ( string $table_name, string $column_name, string $type, array $options = [] ) : boolean
$table_name string the table name
$column_name string the column name
$type string the column type
$options array column options
return boolean
 /**
  * test changing column
  */
 public function test_change_column()
 {
     //create it
     $table = $this->adapter->create_table('users');
     $table->column('name', 'string', array('limit' => 20));
     $table->column('age', 'integer');
     $table->finish();
     //verify its type
     $col = $this->adapter->column_info("users", "name");
     $this->assertEquals('character varying(20)', $col['type']);
     $this->assertEquals('', $col['default']);
     //change it, add a default too!
     $this->adapter->change_column("users", "name", "string", array('default' => 'abc', 'limit' => 128));
     $col = $this->adapter->column_info("users", "name");
     $this->assertEquals('character varying(128)', $col['type']);
     $this->assertEquals("'abc'::character varying", $col['default']);
     $this->drop_table('users');
 }
Beispiel #2
0
 /**
  * Change a column
  *
  * @param string $table_name the name of the table
  * @param string $column_name the column name
  * @param string $type the column type
  * @param array|string $options
  *
  * @return boolean
  */
 public function change_column($table_name, $column_name, $type, $options = array())
 {
     return $this->_adapter->change_column($table_name, $column_name, $type, $options);
 }