@@ -132,6 +132,44 @@ public function testGetCreateCommand(
132132 self ::assertSame ($ expectedPKs , $ tableReflection ->getPrimaryKeysNames ());
133133 }
134134
135+ public function testAddAndDropColumn (): void
136+ {
137+ $ dbName = $ this ->getDatabaseName ();
138+ $ columns = [TeradataColumn::createGenericColumn ('col1 ' ),
139+ TeradataColumn::createGenericColumn ('col2 ' )];
140+ $ sql = $ this ->qb ->getCreateTableCommand (
141+ $ this ->getDatabaseName (),
142+ self ::TABLE_GENERIC ,
143+ new ColumnCollection ($ columns ),
144+
145+ );
146+ $ this ->connection ->executeQuery ($ sql );
147+
148+ // add column
149+ $ sql = $ this ->qb ->getAddColumnCommand ($ dbName , self ::TABLE_GENERIC , TeradataColumn::createGenericColumn ('col3 ' ));
150+ $ this ->assertEquals (sprintf ('ALTER TABLE "%s"."%s" ADD "col3" VARCHAR (32000) NOT NULL DEFAULT \'\' CHARACTER SET UNICODE ' , $ dbName , self ::TABLE_GENERIC ), $ sql );
151+ $ this ->connection ->executeQuery ($ sql );
152+
153+ $ tableReflection = new TeradataTableReflection (
154+ $ this ->connection ,
155+ $ this ->getDatabaseName (),
156+ self ::TABLE_GENERIC
157+ );
158+ self ::assertSame (['col1 ' , 'col2 ' , 'col3 ' ], $ tableReflection ->getColumnsNames ());
159+
160+ // drop column
161+ $ sql = $ this ->qb ->getDropColumnCommand ($ dbName , self ::TABLE_GENERIC , 'col2 ' );
162+ $ this ->assertEquals (sprintf ('ALTER TABLE "%s"."%s" DROP "col2" ' , $ dbName , self ::TABLE_GENERIC ), $ sql );
163+ $ this ->connection ->executeQuery ($ sql );
164+
165+ $ tableReflection = new TeradataTableReflection (
166+ $ this ->connection ,
167+ $ this ->getDatabaseName (),
168+ self ::TABLE_GENERIC
169+ );
170+ self ::assertSame (['col1 ' , 'col3 ' ], $ tableReflection ->getColumnsNames ());
171+ }
172+
135173 /**
136174 * @return \Generator<string, mixed, mixed, mixed>
137175 */
0 commit comments