Created
January 6, 2015 06:01
-
-
Save tikitikipoo/2af4f9804da7f2619063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/Vendor/cakephp/cakephp/lib/Cake/Model/Datasource/Database/Postgres.php | |
556行目 | |
if ($boolToInt) { | |
$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 { | |
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 if ($original['type'] === 'integer' && $col['type'] === 'boolean') { | |
$colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)) . " USING cast({$fieldName} as BOOLEAN)"; | |
} else if ($original['type'] === 'datetime' && $col['type'] === 'integer') { | |
$colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)) . " USING EXTRACT(EPOCH FROM {$fieldName})"; | |
} else if ($original['type'] === 'integer' && $col['type'] === 'datetime') { | |
$colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)) . " USING timestamp with time zone 'epoch' + {$fieldName} * interval '1 second'"; | |
} else { | |
$colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment