|
14 | 14 | * |
15 | 15 | * This class provides common methods for migrations, similar to Yii2's Migration class. |
16 | 16 | * 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() |
17 | 70 | */ |
18 | 71 | abstract class Migration implements MigrationInterface |
19 | 72 | { |
@@ -43,7 +96,26 @@ abstract public function down(): void; |
43 | 96 | /** |
44 | 97 | * Get DDL Query Builder for schema operations. |
45 | 98 | * |
| 99 | + * Provides IDE autocompletion for schema operations. |
| 100 | + * All methods from DdlQueryBuilder are available through this method. |
| 101 | + * |
46 | 102 | * @return DdlQueryBuilder |
| 103 | + * |
| 104 | + * @example |
| 105 | + * // Create a table |
| 106 | + * $this->schema()->createTable('users', [ |
| 107 | + * 'id' => $this->schema()->primaryKey(), |
| 108 | + * 'name' => $this->schema()->string(255)->notNull(), |
| 109 | + * 'email' => $this->schema()->string(255)->notNull()->unique(), |
| 110 | + * ]); |
| 111 | + * |
| 112 | + * @example |
| 113 | + * // Add a column |
| 114 | + * $this->schema()->addColumn('users', 'status', $this->schema()->string(20)->defaultValue('active')); |
| 115 | + * |
| 116 | + * @example |
| 117 | + * // Create an index |
| 118 | + * $this->schema()->createIndex('idx_email', 'users', 'email'); |
47 | 119 | */ |
48 | 120 | protected function schema(): DdlQueryBuilder |
49 | 121 | { |
|
0 commit comments