improve migration class
This commit is contained in:
11
Schema.php
11
Schema.php
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace DatabaseHelper;
|
||||
|
||||
use DatabaseHelper\enums\Aggregation;
|
||||
use DatabaseHelper\enums\Charset;
|
||||
use DatabaseHelper\enums\Collation;
|
||||
use DatabaseHelper\enums\Engine;
|
||||
@@ -38,6 +39,12 @@ class Schema
|
||||
return false;
|
||||
}
|
||||
|
||||
public function countEntries(): int {
|
||||
return Database::makeQuery($this)
|
||||
->aggregate('*', 'count', Aggregation::COUNT)
|
||||
->query();
|
||||
}
|
||||
|
||||
public function columnType(string $col) {
|
||||
return $this->columns[$col]['type'];
|
||||
}
|
||||
@@ -46,10 +53,6 @@ class Schema
|
||||
return $this->columns['primary']['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a deep copy of this instance.
|
||||
* @return Schema
|
||||
*/
|
||||
public function copy(): Schema {
|
||||
$copy = new Schema($this->name);
|
||||
$copy->columns = genericDeepCopy($this->columns);
|
||||
|
Reference in New Issue
Block a user