source/Spiral/Database/Drivers/SQLite/Schemas/IndexSchema.php 1 location
|
@@ 22-32 (lines=11) @@
|
19 |
|
* |
20 |
|
* @return IndexSchema |
21 |
|
*/ |
22 |
|
public static function createInstance(string $table, array $schema, array $columns): self |
23 |
|
{ |
24 |
|
$index = new self($table, $schema['name']); |
25 |
|
$index->type = $schema['unique'] ? self::UNIQUE : self::NORMAL; |
26 |
|
|
27 |
|
foreach ($columns as $column) { |
28 |
|
$index->columns[] = $column['name']; |
29 |
|
} |
30 |
|
|
31 |
|
return $index; |
32 |
|
} |
33 |
|
} |
34 |
|
|
source/Spiral/Database/Drivers/MySQL/Schemas/MySQLIndex.php 1 location
|
@@ 20-30 (lines=11) @@
|
17 |
|
* |
18 |
|
* @return MySQLIndex |
19 |
|
*/ |
20 |
|
public static function createInstance(string $table, string $name, array $schema): self |
21 |
|
{ |
22 |
|
$index = new self($table, $name); |
23 |
|
|
24 |
|
foreach ($schema as $definition) { |
25 |
|
$index->type = $definition['Non_unique'] ? self::NORMAL : self::UNIQUE; |
26 |
|
$index->columns[] = $definition['Column_name']; |
27 |
|
} |
28 |
|
|
29 |
|
return $index; |
30 |
|
} |
31 |
|
} |