db2 driver updates

This commit is contained in:
Mark Gregory
2026-11-11 11:11:30 +00:00
parent 984b52f39e
commit 84844311a5
8 changed files with 1051 additions and 4 deletions
+28 -3
View File
@@ -59,7 +59,7 @@ class Db2SchemaGrammar extends Grammar
$type = $this->getType($column);
$statements = [];
if (strcasecmp($current['type'], $type) !== 0) {
if (strcasecmp($current['type'], $type === 'TIMESTAMP' ? 'TIMESTAMP(6)' : $type) !== 0) {
$statements[] = $prefix.' SET DATA TYPE '.$type;
}
if ($current['nullable'] !== (bool) $column->nullable) {
@@ -128,6 +128,12 @@ class Db2SchemaGrammar extends Grammar
return 'DROP INDEX '.$this->wrapIndex($blueprint, $command->index);
}
public function compileRenameIndex(Blueprint $blueprint, Fluent $command)
{
return 'RENAME INDEX '.$this->wrapIndex($blueprint, $command->from)
.' TO '.$this->wrapValue($command->to);
}
private function wrapIndex(Blueprint $blueprint, string $name): string
{
[$schema] = $this->connection->getSchemaBuilder()->parseSchemaAndTable($blueprint->getTable());
@@ -172,6 +178,25 @@ class Db2SchemaGrammar extends Grammar
return 'VARCHAR(' . ($column->length ?: 255) . ')';
}
protected function typeChar(Fluent $column)
{
return 'CHAR('.$column->length.')';
}
protected function typeUuid(Fluent $column)
{
return 'CHAR(36)';
}
protected function typeTime(Fluent $column)
{
if ($column->precision !== null && $column->precision !== 0) {
throw new \InvalidArgumentException('Db2 TIME does not support fractional-second precision.');
}
return 'TIME';
}
protected function typeText(Fluent $column)
{
return 'CLOB(1M)';
@@ -189,12 +214,12 @@ class Db2SchemaGrammar extends Grammar
protected function typeTimestamp(Fluent $column)
{
return 'TIMESTAMP';
return $column->precision === null ? 'TIMESTAMP' : 'TIMESTAMP('.$column->precision.')';
}
protected function typeDateTime(Fluent $column)
{
return 'TIMESTAMP';
return $this->typeTimestamp($column);
}
protected function typeDate(Fluent $column)