Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix quote issue in enum in PgSQL 2
  • Loading branch information
SOHELAHMED7 committed Jan 2, 2023
commit e8f1df1d8ad60dd5f2eff8379157ada441defc50
4 changes: 2 additions & 2 deletions src/lib/migrations/BaseMigrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public function tmpSaveNewCol(\cebe\yii2openapi\db\ColumnSchema $columnSchema):
{
$tableName = 'tmp_table_';
$tmpEnumName = function (string $columnName): string {
return 'tmp_enum_'.$columnName.'_';
return '"tmp_enum_'.$columnName.'_"';
};

Yii::$app->db->createCommand('DROP TABLE IF EXISTS '.$tableName)->execute();
Expand Down Expand Up @@ -455,7 +455,7 @@ public function tmpSaveNewCol(\cebe\yii2openapi\db\ColumnSchema $columnSchema):

if (ApiGenerator::isPostgres() && static::isEnum($columnSchema)) {// drop enum
Yii::$app->db->createCommand('DROP TYPE '.$tmpEnumName($columnSchema->name))->execute();
if ($table->columns[$columnSchema->name]->dbType !== $tmpEnumName($columnSchema->name)) {
if ('"'.$table->columns[$columnSchema->name]->dbType.'"' !== $tmpEnumName($columnSchema->name)) {
throw new \Exception('Unknown error related to PgSQL enum '.$table->columns[$columnSchema->name]->dbType);
}
// reset back column enum name to original as we are comparing with current
Expand Down