Skip to content

Commit 1504711

Browse files
committed
refactor: improve IDE autocompletion for schema() method in migrations
- Remove unnecessary @mixin and @method annotations from class PHPDoc - Enhance schema() method PHPDoc with detailed description of available methods - Add example with addForeignKey() method - @return DdlQueryBuilder annotation ensures IDE autocompletion works correctly
1 parent 02d6e3d commit 1504711

File tree

1 file changed

+11
-54
lines changed

1 file changed

+11
-54
lines changed

src/migrations/Migration.php

Lines changed: 11 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,59 +14,6 @@
1414
*
1515
* This class provides common methods for migrations, similar to Yii2's Migration class.
1616
* All migrations should extend this class and implement up() and down() methods.
17-
*
18-
* @mixin DdlQueryBuilder
19-
*
20-
* @method DdlQueryBuilder createTable(string $table, array $columns, array $options = [])
21-
* @method DdlQueryBuilder createTableIfNotExists(string $table, array $columns, array $options = [])
22-
* @method DdlQueryBuilder dropTable(string $table)
23-
* @method DdlQueryBuilder dropTableIfExists(string $table)
24-
* @method DdlQueryBuilder renameTable(string $table, string $newName)
25-
* @method DdlQueryBuilder truncateTable(string $table)
26-
* @method DdlQueryBuilder addColumn(string $table, string $column, \tommyknocker\pdodb\query\schema\ColumnSchema|array|string $type)
27-
* @method DdlQueryBuilder dropColumn(string $table, string $column)
28-
* @method DdlQueryBuilder alterColumn(string $table, string $column, \tommyknocker\pdodb\query\schema\ColumnSchema|array|string $type)
29-
* @method DdlQueryBuilder renameColumn(string $table, string $oldName, string $newName)
30-
* @method DdlQueryBuilder createIndex(string $name, string $table, string|array $columns, bool $unique = false, ?string $where = null, ?array $includeColumns = null, array $options = [])
31-
* @method DdlQueryBuilder dropIndex(string $name, string $table)
32-
* @method DdlQueryBuilder createFulltextIndex(string $name, string $table, string|array $columns, ?string $parser = null)
33-
* @method DdlQueryBuilder createSpatialIndex(string $name, string $table, string|array $columns)
34-
* @method DdlQueryBuilder renameIndex(string $oldName, string $table, string $newName)
35-
* @method DdlQueryBuilder renameForeignKey(string $oldName, string $table, string $newName)
36-
* @method DdlQueryBuilder addForeignKey(string $name, string $table, string|array $columns, string $refTable, string|array $refColumns, ?string $delete = null, ?string $update = null)
37-
* @method DdlQueryBuilder dropForeignKey(string $name, string $table)
38-
* @method DdlQueryBuilder addPrimaryKey(string $name, string $table, string|array $columns)
39-
* @method DdlQueryBuilder dropPrimaryKey(string $name, string $table)
40-
* @method DdlQueryBuilder addUnique(string $name, string $table, string|array $columns)
41-
* @method DdlQueryBuilder dropUnique(string $name, string $table)
42-
* @method DdlQueryBuilder addCheck(string $name, string $table, string $expression)
43-
* @method DdlQueryBuilder dropCheck(string $name, string $table)
44-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema primaryKey(?int $length = null)
45-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema bigPrimaryKey()
46-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema string(?int $length = null)
47-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema text()
48-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema char(?int $length = null)
49-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema integer(?int $length = null)
50-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema bigInteger()
51-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema smallInteger(?int $length = null)
52-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema boolean()
53-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema float(?int $precision = null, ?int $scale = null)
54-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema decimal(int $precision = 10, int $scale = 2)
55-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema date()
56-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema time()
57-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema datetime()
58-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema timestamp()
59-
* @method \tommyknocker\pdodb\query\schema\ColumnSchema json()
60-
* @method bool tableExists(string $table)
61-
* @method bool indexExists(string $name, string $table)
62-
* @method bool foreignKeyExists(string $name, string $table)
63-
* @method bool checkExists(string $name, string $table)
64-
* @method bool uniqueExists(string $name, string $table)
65-
* @method array getIndexes(string $table)
66-
* @method array getForeignKeys(string $table)
67-
* @method array getCheckConstraints(string $table)
68-
* @method array getUniqueConstraints(string $table)
69-
* @method \tommyknocker\pdodb\dialects\DialectInterface getDialect()
7017
*/
7118
abstract class Migration implements MigrationInterface
7219
{
@@ -99,7 +46,13 @@ abstract public function down(): void;
9946
* Provides IDE autocompletion for schema operations.
10047
* All methods from DdlQueryBuilder are available through this method.
10148
*
102-
* @return DdlQueryBuilder
49+
* @return DdlQueryBuilder Returns DdlQueryBuilder instance with all schema methods available.
50+
* IDE will provide autocompletion for methods like:
51+
* - createTable(), dropTable(), renameTable()
52+
* - addColumn(), dropColumn(), alterColumn()
53+
* - createIndex(), dropIndex(), createFulltextIndex()
54+
* - addForeignKey(), dropForeignKey()
55+
* - primaryKey(), string(), integer(), text(), etc.
10356
*
10457
* @example
10558
* // Create a table
@@ -116,6 +69,10 @@ abstract public function down(): void;
11669
* @example
11770
* // Create an index
11871
* $this->schema()->createIndex('idx_email', 'users', 'email');
72+
*
73+
* @example
74+
* // Add foreign key
75+
* $this->schema()->addForeignKey('fk_user_profile', 'profiles', 'user_id', 'users', 'id', 'CASCADE', 'CASCADE');
11976
*/
12077
protected function schema(): DdlQueryBuilder
12178
{

0 commit comments

Comments
 (0)