schema with beans instead of arrays
This commit is contained in:
15
beans/Column.php
Normal file
15
beans/Column.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace DatabaseHelper\beans;
|
||||
|
||||
use DatabaseHelper\enums\Type;
|
||||
|
||||
class Column
|
||||
{
|
||||
public string $name;
|
||||
public ?string $default = null;
|
||||
|
||||
public Type $type;
|
||||
|
||||
public bool $isNullable = false;
|
||||
public bool $isUnique = false;
|
||||
}
|
10
beans/Primary.php
Normal file
10
beans/Primary.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace DatabaseHelper\beans;
|
||||
|
||||
use DatabaseHelper\enums\Type;
|
||||
|
||||
class Primary extends Column
|
||||
{
|
||||
public string $name;
|
||||
public bool $autoInc = true;
|
||||
}
|
14
beans/Reference.php
Normal file
14
beans/Reference.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace DatabaseHelper\beans;
|
||||
|
||||
use DatabaseHelper\enums\Propagation;
|
||||
use DatabaseHelper\enums\Type;
|
||||
|
||||
class Reference
|
||||
{
|
||||
public string $name;
|
||||
public ?Schema $otherTable;
|
||||
|
||||
public Propagation $onDelete;
|
||||
public Propagation $onUpdate;
|
||||
}
|
28
beans/Schema.php
Normal file
28
beans/Schema.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace DatabaseHelper\beans;
|
||||
|
||||
use DatabaseHelper\enums\Aggregation;
|
||||
use DatabaseHelper\enums\Charset;
|
||||
use DatabaseHelper\enums\Collation;
|
||||
use DatabaseHelper\enums\Engine;
|
||||
use http\Exception\InvalidArgumentException;
|
||||
|
||||
class Schema
|
||||
{
|
||||
public string $name = '';
|
||||
public Primary $primary;
|
||||
|
||||
/**
|
||||
* @var array<string, Column>
|
||||
*/
|
||||
public array $columns = [];
|
||||
|
||||
/**
|
||||
* @var array<string, Reference>
|
||||
*/
|
||||
public array $references = [];
|
||||
|
||||
public Engine $engine = Engine::INNODB;
|
||||
public Charset $charset = Charset::UTF8;
|
||||
public Collation $collation = Collation::UTF8_GENERAL_CI;
|
||||
}
|
Reference in New Issue
Block a user