Skip to content

Commit 7fbf119

Browse files
committed
Update comment
1 parent 6c2c786 commit 7fbf119

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/Database/Models/DatabaseTable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ abstract protected function makeIndex(string $table, array $index): Index;
6161
* Create a new instance.
6262
*
6363
* @param SchemaTable $table
64-
* @param \Illuminate\Support\Collection<int, SchemaColumn> $columns Key is quoted name.
65-
* @param \Illuminate\Support\Collection<int, SchemaIndex> $indexes Key is name.
64+
* @param \Illuminate\Support\Collection<int, SchemaColumn> $columns
65+
* @param \Illuminate\Support\Collection<int, SchemaIndex> $indexes
6666
* @param \Illuminate\Support\Collection<int, string> $userDefinedTypes
6767
*/
6868
public function __construct(array $table, Collection $columns, Collection $indexes, Collection $userDefinedTypes)

src/Database/Models/PgSQL/PgSQLUDTColumn.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public function __construct(string $table, array $column)
2323
parent::__construct($table, $column);
2424

2525
$blueprint = new Blueprint($this->stripTablePrefix($table));
26+
27+
// Generate the add column statement with string column type.
2628
$blueprint->addColumn('string', $column['name'], [
2729
'autoIncrement' => $column['auto_increment'],
2830
'collation' => $column['collation'],
@@ -31,7 +33,9 @@ public function __construct(string $table, array $column)
3133
'nullable' => $column['nullable'],
3234
]);
3335

34-
$sqls = $blueprint->toSql(Schema::getConnection(), Schema::getConnection()->getSchemaGrammar());
36+
$sqls = $blueprint->toSql(Schema::getConnection(), Schema::getConnection()->getSchemaGrammar());
37+
38+
// Replace the string column type with the user-defined type.
3539
$sqls[0] = Str::replaceFirst(' varchar ', ' ' . $column['type'] . ' ', $sqls[0]);
3640

3741
$this->sqls = $sqls;

src/Database/Models/SQLSrv/SQLSrvUDTColumn.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ public function __construct(string $table, array $column)
2222
parent::__construct($table, $column);
2323

2424
$blueprint = new Blueprint($this->stripTablePrefix($table));
25+
26+
// Generate the add column statement with string column type.
2527
$blueprint->addColumn('string', $column['name'], [
2628
'autoIncrement' => $column['auto_increment'],
2729
'default' => $this->parseDefault($column['default']),
2830
'nullable' => $column['nullable'],
2931
]);
3032

31-
$sqls = $blueprint->toSql(Schema::getConnection(), Schema::getConnection()->getSchemaGrammar());
33+
$sqls = $blueprint->toSql(Schema::getConnection(), Schema::getConnection()->getSchemaGrammar());
34+
35+
// Replace the string column type with the user-defined type.
3236
$sqls[0] = Str::replaceFirst(' nvarchar() ', ' ' . $column['type'] . ' ', $sqls[0]);
3337

3438
$this->sqls = $sqls;

tests/resources/database/migrations/general/2020_03_21_000000_expected_create_all_columns_table.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,12 @@ public function up()
212212
"ALTER TABLE ".DB::getTablePrefix()."all_columns ADD COLUMN timestamp_defaultnow timestamp(0) without time zone DEFAULT now() NOT NULL",
213213
);
214214

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

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

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

0 commit comments

Comments
 (0)