sevens / consoler
A console & migration library specifically built for the Altvel Framework.
v0.1.0
2020-11-14 00:08 UTC
Requires
- php: >=7.2.0
- sevens/model-trait: v1.0.0
- sevens/vars: v1.0.0
This package is auto-updated.
Last update: 2025-03-14 10:43:56 UTC
README
Built Specifically for Altvel and can only be ported with a lot of code change. It is a closed code structure.
Console Commands
=> Console Command
Installation
=> This will already be pre-installed with Altvel Framework
composer require sevens/consoler
Initializing the SchemaMap Engine
=> Since You're most likely using Altvel Framework Engineer Console, You won't be setting this up.
$schemaMap = new SchemaMap($config = [ 'directory' => __DIR__.'/migration', 'migrator' => 'Migration.php', 'populator' => 'Population.php' ]);
###Migrator
=> id is automatically generated on all tables by the schemaMap Engine
=> constraints: a table can only have one primary key and it will be autogenerated
=> Add your migrations to the Migration.php file in the migration folder
=> migrations are logged in Migration.History in the Altvel Engineer Console,
Example Use Cases
return[ 'apps' => [ #the referenced table must already exist and the name must be exact to avoid errors #$type can be one of ['int','string'] on a foreign key column 'token' => $this->foreign_key($table='sessions_table', $column='session' $type='string'), //$key can be one of ['unique','fulltext', ''] 'name' => $this->string($max_length=125, $null=true, $key='fulltext'), 'pos' => $this->integer($max_length=10), //in other to specify a maximum length, float should be used instead of a double 'account_balance' => $this->double(), 'ledger' => $this->float($max_length=16), 'is_verified' => $this->oneOf($options=["'true'", "'false'"], $default="'false'" ), 'created_at' => $this->datetime() ], 'users' => [ 'name' => $this->string($max_length=125, $null=false), 'email' => $this->string($max_length=125, $null=false, $key='unique'), 'password' => $this->string($max_length=125), 'backup_pass' => $this->string($max_length=150), 'activation' => $this->string($max_length=225), 'verified' => $this->oneOf($options=["'true'", "'false'"], $default="'false'" ), 'created_at' => $this->dateTime(), 'deleted' => $this->oneOf($options=["'true'", "'false'"], $default="'false'" ) ], 'contact_us' => [ 'name' => $this->string($max_length=125, $null=false), 'email' => $this->string($max_length=125), 'feedback' => $this->string($max_length=1025), 'created_at' => $this->datetime(), 'deleted' => $this->oneOf($options=["'true'", "'false'"], $default="'false'" ) ], 'user_sessions' => [ 'user_id' => $this->foreign_key($table='users', $column='id', $type = 'int' ), 'session' => $this->string($max_length=225, $null=false), 'user_agent' => $this->string($max_length=225, $null=false), 'push_token' => $this->string($max_length=225, $null=false), 'created_at' => $this->dateTime(), 'deleted' => $this->oneOf($options=["'true'", "'false'"], $default="'false'" ) ], ];
###Populator file
Populate a table with data by adding array of arrays to the population.php return array in this format
return [ 'table name' => [ 'column name' => 'value' , 'column name' => 'value' , 'column name' => 'value' ], 'table name' => [...], ];
Example Use Case
return [ 'users' => [ [ 'name' => "Elisha TemmyScope", 'email' => "esdentemmy@gmail.com", 'password' => hash("password"), 'activation' => "random code", 'verified' => "false", 'created_at' => date("Y-m-d h:i:s"), 'deleted' => "false" ] ], ];