mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-06 11:32:40 +00:00
Merge branch 'postgres_altercolum_error' into master
Merge changes from #5512 into master. This fixes changing columns in postgres to integer from string types.
This commit is contained in:
commit
827465fa30
2 changed files with 41 additions and 3 deletions
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
/**
|
||||
* PostgreSQL layer for DBO.
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
|
@ -558,7 +556,11 @@ class Postgres extends DboSource {
|
|||
$colList[] = 'ALTER COLUMN ' . $fieldName . ' SET DEFAULT NULL';
|
||||
$colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)) . ' USING CASE WHEN TRUE THEN 1 ELSE 0 END';
|
||||
} else {
|
||||
$colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col));
|
||||
if ($original['type'] === 'text' && $col['type'] === 'integer') {
|
||||
$colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)) . " USING cast({$fieldName} as INTEGER)";
|
||||
} else {
|
||||
$colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($nullable)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue