示例#1
0
 public function testDropColumn()
 {
     $table = new \Phinx\Db\Table('t', array(), $this->adapter);
     $table->addColumn('column1', 'string')->save();
     $this->assertTrue($this->adapter->hasColumn('t', 'column1'));
     $this->adapter->dropColumn('t', 'column1');
     $this->assertFalse($this->adapter->hasColumn('t', 'column1'));
 }
 public function testTimestampWithTimezone()
 {
     $table = new \Phinx\Db\Table('tztable', array('id' => false), $this->adapter);
     $table->addColumn('timestamp_tz', 'timestamp', array('timezone' => true))->addColumn('time_tz', 'time', array('timezone' => true))->addColumn('date_notz', 'date', array('timezone' => true))->addColumn('time_notz', 'timestamp')->save();
     $this->assertTrue($this->adapter->hasColumn('tztable', 'timestamp_tz'));
     $this->assertTrue($this->adapter->hasColumn('tztable', 'time_tz'));
     $this->assertTrue($this->adapter->hasColumn('tztable', 'date_notz'));
     $this->assertTrue($this->adapter->hasColumn('tztable', 'time_notz'));
     $columns = $this->adapter->getColumns('tztable');
     foreach ($columns as $column) {
         if (substr($column->getName(), -4) === 'notz') {
             $this->assertFalse($column->isTimezone(), 'column: ' . $column->getName());
         } else {
             $this->assertTrue($column->isTimezone(), 'column: ' . $column->getName());
         }
     }
 }