Пример #1
0
 public function testDiff()
 {
     $table1 = DBTable::fromSQL('CREATE TABLE test (id int,name varchar(255))');
     $table2 = DBTable::fromSQL('CREATE TABLE test (id int,name varchar(255))');
     $table3 = DBTable::fromSQL('CREATE TABLE test2 (id int,name varchar(255))');
     $table4 = DBTable::fromSQL('CREATE TABLE test3 (id int,name varchar(255))');
     $table5 = DBTable::fromSQL('CREATE TABLE test (id char(4),name varchar(255))');
     $table6 = DBTable::fromSQL('CREATE TABLE test (no int,name varchar(255))');
     $this->assertEquals('', $table1->diff($table2));
     $this->assertEquals('ALTER TABLE test RENAME test2', $table1->diff($table3));
     $this->assertEquals('ALTER TABLE test RENAME test3', $table1->diff($table4));
     $this->assertEquals('ALTER TABLE test CHANGE id id char(4)', $table1->diff($table5));
     $this->assertEquals('ALTER TABLE test ADD no int,DROP id', $table1->diff($table6));
 }