Skip to content

Resolve: Remove unnecessary null or default related migrations in PgSQL #151 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
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
Next Next commit
Fix style
  • Loading branch information
SOHELAHMED7 committed Jul 5, 2024
commit be26ed5ca72e56a9ae2d518233305859ca092b32
2 changes: 1 addition & 1 deletion src/lib/ColumnToCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private function resolve():void
$rawSize = $this->column->size ? '(' . $this->column->size . ')' : '';
$this->rawParts['nullable'] = $this->column->allowNull ? 'NULL' : 'NOT NULL';
// if (!ApiGenerator::isPostgres()) {
$this->fluentParts['nullable'] = $this->column->allowNull === true ? 'null()' : 'notNull()';
$this->fluentParts['nullable'] = $this->column->allowNull === true ? 'null()' : 'notNull()';
// }
if (array_key_exists($dbType, self::INT_TYPE_MAP)) {
$this->fluentParts['type'] = self::INT_TYPE_MAP[$dbType] . $fluentSize;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/migrations/PostgresMigrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function buildColumnChanges(ColumnSchema $current, ColumnSchema $desir
$this->migration->addDownCode($this->recordBuilder->alterColumnTypeFromDb($tableName, $current, $addUsing));
}
if (in_array('allowNull', $changed, true)) {
// TODO if last up code contains `null()` string then do execute below statement, same for notNull() and same in down code
// TODO if last up code contains `null()` string then do execute below statement, same for notNull() and same in down code
if ($desired->allowNull === true) {
$this->migration->addUpCode($this->recordBuilder->dropColumnNotNull($tableName, $desired));
$this->migration->addDownCode($this->recordBuilder->setColumnNotNull($tableName, $current), true);
Expand Down
Loading