Beispiel #1
0
 /**
  * @depends testCanAddColumnComment
  */
 public function testCanRemoveColumnComment()
 {
     $table = new \Phinx\Db\Table('table1', array(), $this->adapter);
     $table->addColumn('field1', 'string', array('comment' => 'Comments from column "field1"'))->save();
     $table->changeColumn('field1', 'string', array('comment' => 'null'))->save();
     $row = $this->adapter->fetchRow('SELECT
             (select pg_catalog.col_description(oid,cols.ordinal_position::int)
         from pg_catalog.pg_class c 
         where c.relname=cols.table_name ) as column_comment
         FROM information_schema.columns cols 
         WHERE cols.table_catalog=\'' . TESTS_PHINX_DB_ADAPTER_POSTGRES_DATABASE . '\'
         AND cols.table_name=\'table1\'
         AND cols.column_name = \'field1\'');
     $this->assertEmpty($row['column_comment'], 'Dont remove column comment correctly');
 }
 /**
  * @depends testCanAddColumnComment
  */
 public function testColumnsAreResetBetweenTables()
 {
     $table = new \Phinx\Db\Table('widgets', array(), $this->adapter);
     $table->addColumn('transport', 'string', array('comment' => $comment = 'One of: car, boat, truck, plane, train'))->save();
     $table = new \Phinx\Db\Table('things', array(), $this->adapter);
     $table->addColumn('speed', 'integer')->save();
     $row = $this->adapter->fetchRow('SELECT
             (select pg_catalog.col_description(oid,cols.ordinal_position::int)
         from pg_catalog.pg_class c
         where c.relname=cols.table_name ) as column_comment
         FROM information_schema.columns cols
         WHERE cols.table_catalog=\'' . TESTS_PHINX_DB_ADAPTER_POSTGRES_DATABASE . '\'
         AND cols.table_name=\'widgets\'
         AND cols.column_name = \'transport\'');
     $this->assertEquals($comment, $row['column_comment'], 'Could not create column comment');
 }