Skip to content

Commit

Permalink
Update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kitloong committed Aug 6, 2024
1 parent 6c2c786 commit 7fbf119
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Database/Models/DatabaseTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ abstract protected function makeIndex(string $table, array $index): Index;
* Create a new instance.
*
* @param SchemaTable $table
* @param \Illuminate\Support\Collection<int, SchemaColumn> $columns Key is quoted name.
* @param \Illuminate\Support\Collection<int, SchemaIndex> $indexes Key is name.
* @param \Illuminate\Support\Collection<int, SchemaColumn> $columns
* @param \Illuminate\Support\Collection<int, SchemaIndex> $indexes
* @param \Illuminate\Support\Collection<int, string> $userDefinedTypes
*/
public function __construct(array $table, Collection $columns, Collection $indexes, Collection $userDefinedTypes)
Expand Down
6 changes: 5 additions & 1 deletion src/Database/Models/PgSQL/PgSQLUDTColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function __construct(string $table, array $column)
parent::__construct($table, $column);

$blueprint = new Blueprint($this->stripTablePrefix($table));

// Generate the add column statement with string column type.
$blueprint->addColumn('string', $column['name'], [
'autoIncrement' => $column['auto_increment'],
'collation' => $column['collation'],
Expand All @@ -31,7 +33,9 @@ public function __construct(string $table, array $column)
'nullable' => $column['nullable'],
]);

$sqls = $blueprint->toSql(Schema::getConnection(), Schema::getConnection()->getSchemaGrammar());
$sqls = $blueprint->toSql(Schema::getConnection(), Schema::getConnection()->getSchemaGrammar());

// Replace the string column type with the user-defined type.
$sqls[0] = Str::replaceFirst(' varchar ', ' ' . $column['type'] . ' ', $sqls[0]);

$this->sqls = $sqls;
Expand Down
6 changes: 5 additions & 1 deletion src/Database/Models/SQLSrv/SQLSrvUDTColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ public function __construct(string $table, array $column)
parent::__construct($table, $column);

$blueprint = new Blueprint($this->stripTablePrefix($table));

// Generate the add column statement with string column type.
$blueprint->addColumn('string', $column['name'], [
'autoIncrement' => $column['auto_increment'],
'default' => $this->parseDefault($column['default']),
'nullable' => $column['nullable'],
]);

$sqls = $blueprint->toSql(Schema::getConnection(), Schema::getConnection()->getSchemaGrammar());
$sqls = $blueprint->toSql(Schema::getConnection(), Schema::getConnection()->getSchemaGrammar());

// Replace the string column type with the user-defined type.
$sqls[0] = Str::replaceFirst(' nvarchar() ', ' ' . $column['type'] . ' ', $sqls[0]);

$this->sqls = $sqls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,12 @@ public function up()
"ALTER TABLE ".DB::getTablePrefix()."all_columns ADD COLUMN timestamp_defaultnow timestamp(0) without time zone DEFAULT now() NOT NULL",
);

// Test user defined type column.
DB::statement(
"ALTER TABLE ".DB::getTablePrefix()."all_columns ADD COLUMN status my_status NOT NULL DEFAULT 'PENDING'",
);

// Add a comment so the alter statement will return 2 statements.
DB::statement(
"COMMENT ON column ".DB::getTablePrefix()."all_columns.status IS 'comment a'",
);
Expand All @@ -226,6 +228,7 @@ public function up()
break;

case Driver::SQLSRV->value:
// Test user defined type column.
DB::statement(
"ALTER TABLE ".DB::getTablePrefix()."all_columns ADD accountnumber accountnumber NOT NULL DEFAULT '1008'",
);
Expand Down

0 comments on commit 7fbf119

Please sign in to comment.