Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add schema changes for length for postgres #185

Merged
merged 1 commit into from

5 participants

@mvrhov

No description provided.

@travisbot

This pull request passes (merged f9015602 into 8f783fb).

@travisbot

This pull request passes (merged f9015602 into 8f783fb).

lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
@@ -444,6 +444,11 @@ public function getAlterTableSQL(TableDiff $diff)
if ($columnDiff->hasChanged('comment') && $comment = $this->getColumnComment($column)) {
$commentsSQL[] = $this->getCommentOnColumnSQL($diff->name, $column->getName(), $comment);
}
+ if ($columnDiff->hasChanged('length')) {
@guilhermeblanco Owner

Missing line break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
@@ -444,6 +444,11 @@ public function getAlterTableSQL(TableDiff $diff)
if ($columnDiff->hasChanged('comment') && $comment = $this->getColumnComment($column)) {
$commentsSQL[] = $this->getCommentOnColumnSQL($diff->name, $column->getName(), $comment);
}
+ if ($columnDiff->hasChanged('length')) {
+ // here was a server version check before, but DBAL API does not support this anymore.
@guilhermeblanco Owner

Comments should always start with upper cased letter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
@@ -444,6 +444,11 @@ public function getAlterTableSQL(TableDiff $diff)
if ($columnDiff->hasChanged('comment') && $comment = $this->getColumnComment($column)) {
$commentsSQL[] = $this->getCommentOnColumnSQL($diff->name, $column->getName(), $comment);
}
+ if ($columnDiff->hasChanged('length')) {
+ // here was a server version check before, but DBAL API does not support this anymore.
+ $query = 'ALTER ' . $column->getName() . ' TYPE ' . $column->getType()->getSqlDeclaration($column->toArray(), $this);
+ $sql[] = 'ALTER TABLE ' . $diff->name . ' ' . $query;
@guilhermeblanco Owner

Missing line break between the two logical blocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mvrhov

The comment is a remaining of copy/paste (I'll remove it). Regarding the other CS comments.. code uses same CS as the rest of the file. Do you still want me to fix it?

@mvrhov

I've removed the column, but left the CS as is

lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
@@ -619,6 +622,17 @@ public function getSmallIntTypeDeclarationSQL(array $field)
}
/**
+ * Decleration for a UUID field in PostgreSQL
+ *
+ * @param array $field
+ * @return string
+ */
+ public function getGuidTypeDeclartionSQL(array $field)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@beberlei
Owner

@mvrhov pathfinder rule. leave the place better than it was before :-) No need to change everything though, but little steps. Can you also rebase to latest master? There is a conflict in the diff.

lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
((6 lines not shown))
} else {
- $whereClause .= "$classAlias.relname = '" . $table . "'";
+ $schema = "ANY(string_to_array((select setting from pg_catalog.pg_settings where name = 'search_path'),','))";
@guilhermeblanco Owner

Use uppercased keywords.
select => SELECT, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mvrhov

The problem with my previous commit was that I forgot to do a rebase.
This should be solved now....

@travisbot

This pull request passes (merged d0c00d3 into 24ec194).

@beberlei beberlei merged commit 443af38 into doctrine:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 29, 2012
  1. @mvrhov
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View
5 lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
@@ -407,6 +407,11 @@ public function getAlterTableSQL(TableDiff $diff)
if ($columnDiff->hasChanged('comment') && $comment = $this->getColumnComment($column)) {
$commentsSQL[] = $this->getCommentOnColumnSQL($diff->name, $column->getName(), $comment);
}
+
+ if ($columnDiff->hasChanged('length')) {
+ $query = 'ALTER ' . $column->getName() . ' TYPE ' . $column->getType()->getSqlDeclaration($column->toArray(), $this);
+ $sql[] = 'ALTER TABLE ' . $diff->name . ' ' . $query;
+ }
}
foreach ($diff->renamedColumns as $oldColumnName => $column) {
Something went wrong with that request. Please try again.