@@ -159,26 +159,3 @@ |
||
| 159 | 159 | private function getTemplateClass(): string |
| 160 | 160 | { |
| 161 | 161 | return <<<EOF |
| 162 | - <?php |
|
| 163 | - namespace Platine\Framework\Migration; |
|
| 164 | - |
|
| 165 | - use Platine\Framework\Migration\AbstractMigration; |
|
| 166 | - |
|
| 167 | - class %classname% extends AbstractMigration |
|
| 168 | - { |
|
| 169 | - |
|
| 170 | - public function up(): void |
|
| 171 | - { |
|
| 172 | - //Action when migrate up |
|
| 173 | - |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - public function down(): void |
|
| 177 | - { |
|
| 178 | - //Action when migrate down |
|
| 179 | - |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - EOF; |
|
| 183 | - } |
|
| 184 | -} |
|
@@ -159,26 +159,3 @@ |
||
| 159 | 159 | private function getTemplateClass(): string |
| 160 | 160 | { |
| 161 | 161 | return <<<EOF |
| 162 | - <?php |
|
| 163 | - namespace Platine\Framework\Migration; |
|
| 164 | - |
|
| 165 | - use Platine\Framework\Migration\AbstractMigration; |
|
| 166 | - |
|
| 167 | - class %classname% extends AbstractMigration |
|
| 168 | - { |
|
| 169 | - |
|
| 170 | - public function up(): void |
|
| 171 | - { |
|
| 172 | - //Action when migrate up |
|
| 173 | - |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - public function down(): void |
|
| 177 | - { |
|
| 178 | - //Action when migrate down |
|
| 179 | - |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - EOF; |
|
| 183 | - } |
|
| 184 | -} |
|
@@ -159,26 +159,3 @@ |
||
| 159 | 159 | private function getTemplateClass(): string |
| 160 | 160 | { |
| 161 | 161 | return <<<EOF |
| 162 | - <?php |
|
| 163 | - namespace Platine\Framework\Migration; |
|
| 164 | - |
|
| 165 | - use Platine\Framework\Migration\AbstractMigration; |
|
| 166 | - |
|
| 167 | - class %classname% extends AbstractMigration |
|
| 168 | - { |
|
| 169 | - |
|
| 170 | - public function up(): void |
|
| 171 | - { |
|
| 172 | - //Action when migrate up |
|
| 173 | - |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - public function down(): void |
|
| 177 | - { |
|
| 178 | - //Action when migrate down |
|
| 179 | - |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - EOF; |
|
| 183 | - } |
|
| 184 | -} |
|
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ) { |
| 81 | 81 | parent::__construct($app, $repository, $config, $filesystem); |
| 82 | 82 | $this->setName('migration:create') |
| 83 | - ->setDescription('Create a new migration'); |
|
| 83 | + ->setDescription('Create a new migration'); |
|
| 84 | 84 | |
| 85 | 85 | $this->addArgument('name', 'name of migration', null, false, true); |
| 86 | 86 | } |
@@ -158,26 +158,3 @@ discard block |
||
| 158 | 158 | private function getTemplateClass(): string |
| 159 | 159 | { |
| 160 | 160 | return <<<EOF |
| 161 | - <?php |
|
| 162 | - namespace Platine\Framework\Migration; |
|
| 163 | - |
|
| 164 | - use Platine\Framework\Migration\AbstractMigration; |
|
| 165 | - |
|
| 166 | - class %classname% extends AbstractMigration |
|
| 167 | - { |
|
| 168 | - |
|
| 169 | - public function up(): void |
|
| 170 | - { |
|
| 171 | - //Action when migrate up |
|
| 172 | - |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - public function down(): void |
|
| 176 | - { |
|
| 177 | - //Action when migrate down |
|
| 178 | - |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - EOF; |
|
| 182 | - } |
|
| 183 | -} |
|
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | * @template T |
| 62 | 62 | * @extends AbstractCommand<T> |
| 63 | 63 | */ |
| 64 | -class MigrationCreateCommand extends AbstractCommand |
|
| 65 | -{ |
|
| 64 | +class MigrationCreateCommand extends AbstractCommand { |
|
| 66 | 65 | |
| 67 | 66 | /** |
| 68 | 67 | * The migration name |
@@ -90,8 +89,7 @@ discard block |
||
| 90 | 89 | /** |
| 91 | 90 | * {@inheritodc} |
| 92 | 91 | */ |
| 93 | - public function execute() |
|
| 94 | - { |
|
| 92 | + public function execute() { |
|
| 95 | 93 | $writer = $this->io()->writer(); |
| 96 | 94 | |
| 97 | 95 | $version = date('Ymd_His'); |
@@ -160,26 +158,3 @@ discard block |
||
| 160 | 158 | private function getTemplateClass(): string |
| 161 | 159 | { |
| 162 | 160 | return <<<EOF |
| 163 | - <?php |
|
| 164 | - namespace Platine\Framework\Migration; |
|
| 165 | - |
|
| 166 | - use Platine\Framework\Migration\AbstractMigration; |
|
| 167 | - |
|
| 168 | - class %classname% extends AbstractMigration |
|
| 169 | - { |
|
| 170 | - |
|
| 171 | - public function up(): void |
|
| 172 | - { |
|
| 173 | - //Action when migrate up |
|
| 174 | - |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - public function down(): void |
|
| 178 | - { |
|
| 179 | - //Action when migrate down |
|
| 180 | - |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - EOF; |
|
| 184 | - } |
|
| 185 | -} |
|
@@ -4,8 +4,7 @@ |
||
| 4 | 4 | use Platine\Database\Schema\CreateTable; |
| 5 | 5 | use Platine\Framework\Migration\AbstractMigration; |
| 6 | 6 | |
| 7 | -class AddRolesTable20210705065247 extends AbstractMigration |
|
| 8 | -{ |
|
| 7 | +class AddRolesTable20210705065247 extends AbstractMigration { |
|
| 9 | 8 | |
| 10 | 9 | public function up(): void |
| 11 | 10 | { |
@@ -10,21 +10,21 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function up(): void |
| 12 | 12 | { |
| 13 | - //Action when migrate up |
|
| 13 | + //Action when migrate up |
|
| 14 | 14 | $this->create('roles', function (CreateTable $table) { |
| 15 | 15 | $table->integer('id') |
| 16 | - ->autoincrement() |
|
| 17 | - ->primary(); |
|
| 16 | + ->autoincrement() |
|
| 17 | + ->primary(); |
|
| 18 | 18 | $table->string('name') |
| 19 | - ->description('The role name') |
|
| 20 | - ->notNull(); |
|
| 19 | + ->description('The role name') |
|
| 20 | + ->notNull(); |
|
| 21 | 21 | $table->string('description') |
| 22 | - ->description('The role description'); |
|
| 22 | + ->description('The role description'); |
|
| 23 | 23 | $table->datetime('created_at') |
| 24 | - ->description('role created at') |
|
| 25 | - ->notNull(); |
|
| 24 | + ->description('role created at') |
|
| 25 | + ->notNull(); |
|
| 26 | 26 | $table->datetime('updated_at') |
| 27 | - ->description('role updated at'); |
|
| 27 | + ->description('role updated at'); |
|
| 28 | 28 | |
| 29 | 29 | $table->engine('INNODB'); |
| 30 | 30 | }); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function down(): void |
| 34 | 34 | { |
| 35 | - //Action when migrate down |
|
| 35 | + //Action when migrate down |
|
| 36 | 36 | $this->drop('roles'); |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | public function up(): void |
| 12 | 12 | { |
| 13 | 13 | //Action when migrate up |
| 14 | - $this->create('roles', function (CreateTable $table) { |
|
| 14 | + $this->create('roles', function(CreateTable $table) { |
|
| 15 | 15 | $table->integer('id') |
| 16 | 16 | ->autoincrement() |
| 17 | 17 | ->primary(); |
@@ -4,8 +4,7 @@ |
||
| 4 | 4 | use Platine\Database\Schema\CreateTable; |
| 5 | 5 | use Platine\Framework\Migration\AbstractMigration; |
| 6 | 6 | |
| 7 | -class AddConfigTable20210708043103 extends AbstractMigration |
|
| 8 | -{ |
|
| 7 | +class AddConfigTable20210708043103 extends AbstractMigration { |
|
| 9 | 8 | |
| 10 | 9 | public function up(): void |
| 11 | 10 | { |
@@ -10,39 +10,39 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function up(): void |
| 12 | 12 | { |
| 13 | - //Action when migrate up |
|
| 13 | + //Action when migrate up |
|
| 14 | 14 | $this->create('config', function (CreateTable $table) { |
| 15 | 15 | $table->integer('id') |
| 16 | - ->autoincrement() |
|
| 17 | - ->primary(); |
|
| 16 | + ->autoincrement() |
|
| 17 | + ->primary(); |
|
| 18 | 18 | $table->integer('parent_id') |
| 19 | - ->description('The parent config'); |
|
| 19 | + ->description('The parent config'); |
|
| 20 | 20 | $table->string('env') |
| 21 | - ->description('The config environment') |
|
| 22 | - ->index(); |
|
| 21 | + ->description('The config environment') |
|
| 22 | + ->index(); |
|
| 23 | 23 | $table->string('module') |
| 24 | - ->description('The module') |
|
| 25 | - ->index() |
|
| 26 | - ->notNull(); |
|
| 24 | + ->description('The module') |
|
| 25 | + ->index() |
|
| 26 | + ->notNull(); |
|
| 27 | 27 | $table->string('name') |
| 28 | - ->description('The config name') |
|
| 29 | - ->index(); |
|
| 28 | + ->description('The config name') |
|
| 29 | + ->index(); |
|
| 30 | 30 | $table->string('value') |
| 31 | - ->description('The config value'); |
|
| 31 | + ->description('The config value'); |
|
| 32 | 32 | $table->string('type') |
| 33 | - ->description('The config data type'); |
|
| 33 | + ->description('The config data type'); |
|
| 34 | 34 | $table->text('comment') |
| 35 | - ->description('The config description'); |
|
| 35 | + ->description('The config description'); |
|
| 36 | 36 | $table->integer('status') |
| 37 | - ->size('tiny') |
|
| 38 | - ->description('The config status') |
|
| 39 | - ->defaultValue(0) |
|
| 40 | - ->notNull(); |
|
| 37 | + ->size('tiny') |
|
| 38 | + ->description('The config status') |
|
| 39 | + ->defaultValue(0) |
|
| 40 | + ->notNull(); |
|
| 41 | 41 | $table->datetime('created_at') |
| 42 | - ->description('created date') |
|
| 43 | - ->notNull(); |
|
| 42 | + ->description('created date') |
|
| 43 | + ->notNull(); |
|
| 44 | 44 | $table->datetime('updated_at') |
| 45 | - ->description('updated date'); |
|
| 45 | + ->description('updated date'); |
|
| 46 | 46 | |
| 47 | 47 | $table->foreign('parent_id') |
| 48 | 48 | ->references('config', 'id') |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | public function down(): void |
| 56 | 56 | { |
| 57 | - //Action when migrate down |
|
| 57 | + //Action when migrate down |
|
| 58 | 58 | $this->drop('config'); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | public function up(): void |
| 12 | 12 | { |
| 13 | 13 | //Action when migrate up |
| 14 | - $this->create('config', function (CreateTable $table) { |
|
| 14 | + $this->create('config', function(CreateTable $table) { |
|
| 15 | 15 | $table->integer('id') |
| 16 | 16 | ->autoincrement() |
| 17 | 17 | ->primary(); |
@@ -70,17 +70,17 @@ |
||
| 70 | 70 | */ |
| 71 | 71 | public function register(): void |
| 72 | 72 | { |
| 73 | - $this->app->bind(Configuration::class, function (ContainerInterface $app) { |
|
| 73 | + $this->app->bind(Configuration::class, function(ContainerInterface $app) { |
|
| 74 | 74 | /** @template T @var Config<T> $config */ |
| 75 | 75 | $config = $app->get(Config::class); |
| 76 | 76 | $driver = $config->get('database.default', 'default'); |
| 77 | 77 | |
| 78 | 78 | return new Configuration($config->get('database.connections.' . $driver, [])); |
| 79 | 79 | }); |
| 80 | - $this->app->share(Pool::class, function (ContainerInterface $app) { |
|
| 80 | + $this->app->share(Pool::class, function(ContainerInterface $app) { |
|
| 81 | 81 | return new Pool($app->get(Config::class)->get('database', [])); |
| 82 | 82 | }); |
| 83 | - $this->app->share(Connection::class, function (ContainerInterface $app) { |
|
| 83 | + $this->app->share(Connection::class, function(ContainerInterface $app) { |
|
| 84 | 84 | return new Connection( |
| 85 | 85 | $app->get(Configuration::class), |
| 86 | 86 | $app->get(LoggerInterface::class) |
@@ -62,8 +62,7 @@ |
||
| 62 | 62 | * @class DatabaseServiceProvider |
| 63 | 63 | * @package Platine\Framework\Service\Provider |
| 64 | 64 | */ |
| 65 | -class DatabaseServiceProvider extends ServiceProvider |
|
| 66 | -{ |
|
| 65 | +class DatabaseServiceProvider extends ServiceProvider { |
|
| 67 | 66 | |
| 68 | 67 | /** |
| 69 | 68 | * {@inheritdoc} |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | ) { |
| 72 | 72 | parent::__construct($app, $repository, $config, $filesystem); |
| 73 | 73 | $this->setName('migration:migrate') |
| 74 | - ->setDescription('Upgrade migration to latest'); |
|
| 74 | + ->setDescription('Upgrade migration to latest'); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -58,8 +58,7 @@ discard block |
||
| 58 | 58 | * @template T |
| 59 | 59 | * @extends AbstractCommand<T> |
| 60 | 60 | */ |
| 61 | -class MigrationMigrateCommand extends AbstractCommand |
|
| 62 | -{ |
|
| 61 | +class MigrationMigrateCommand extends AbstractCommand { |
|
| 63 | 62 | |
| 64 | 63 | /** |
| 65 | 64 | * Create new instance |
@@ -79,8 +78,7 @@ discard block |
||
| 79 | 78 | /** |
| 80 | 79 | * {@inheritodc} |
| 81 | 80 | */ |
| 82 | - public function execute() |
|
| 83 | - { |
|
| 81 | + public function execute() { |
|
| 84 | 82 | $io = $this->io(); |
| 85 | 83 | $writer = $io->writer(); |
| 86 | 84 | $writer->boldYellow('MIGRATION UPGRADE TO LATEST', true)->eol(); |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | ) { |
| 72 | 72 | parent::__construct($app, $repository, $config, $filesystem); |
| 73 | 73 | $this->setName('migration:reset') |
| 74 | - ->setDescription('Rollback all migration done before'); |
|
| 74 | + ->setDescription('Rollback all migration done before'); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -58,8 +58,7 @@ discard block |
||
| 58 | 58 | * @template T |
| 59 | 59 | * @extends AbstractCommand<T> |
| 60 | 60 | */ |
| 61 | -class MigrationResetCommand extends AbstractCommand |
|
| 62 | -{ |
|
| 61 | +class MigrationResetCommand extends AbstractCommand { |
|
| 63 | 62 | |
| 64 | 63 | /** |
| 65 | 64 | * Create new instance |
@@ -79,8 +78,7 @@ discard block |
||
| 79 | 78 | /** |
| 80 | 79 | * {@inheritodc} |
| 81 | 80 | */ |
| 82 | - public function execute() |
|
| 83 | - { |
|
| 81 | + public function execute() { |
|
| 84 | 82 | $io = $this->io(); |
| 85 | 83 | $writer = $io->writer(); |
| 86 | 84 | $writer->boldYellow('ALL MIGRATION ROLLBACK', true)->eol(); |
@@ -117,7 +117,7 @@ |
||
| 117 | 117 | protected function createMigrationTable(): void |
| 118 | 118 | { |
| 119 | 119 | $tableName = $this->table; |
| 120 | - $this->schema->create($tableName, function (CreateTable $table) { |
|
| 120 | + $this->schema->create($tableName, function(CreateTable $table) { |
|
| 121 | 121 | $table->string('version', 20) |
| 122 | 122 | ->description('The migration version') |
| 123 | 123 | ->primary(); |
@@ -60,8 +60,7 @@ discard block |
||
| 60 | 60 | * @template T |
| 61 | 61 | * @extends AbstractCommand<T> |
| 62 | 62 | */ |
| 63 | -class MigrationInitCommand extends AbstractCommand |
|
| 64 | -{ |
|
| 63 | +class MigrationInitCommand extends AbstractCommand { |
|
| 65 | 64 | |
| 66 | 65 | /** |
| 67 | 66 | * The schema to use |
@@ -91,8 +90,7 @@ discard block |
||
| 91 | 90 | /** |
| 92 | 91 | * {@inheritodc} |
| 93 | 92 | */ |
| 94 | - public function execute() |
|
| 95 | - { |
|
| 93 | + public function execute() { |
|
| 96 | 94 | $io = $this->io(); |
| 97 | 95 | $writer = $io->writer(); |
| 98 | 96 | $writer->boldYellow('MIGRATION INITIALIZATION', true); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | ) { |
| 83 | 83 | parent::__construct($app, $repository, $config, $filesystem); |
| 84 | 84 | $this->setName('migration:init') |
| 85 | - ->setDescription('Initialize the migration by creating migration table'); |
|
| 85 | + ->setDescription('Initialize the migration by creating migration table'); |
|
| 86 | 86 | |
| 87 | 87 | $this->schema = $schema; |
| 88 | 88 | } |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | $tableName = $this->table; |
| 121 | 121 | $this->schema->create($tableName, function (CreateTable $table) { |
| 122 | 122 | $table->string('version', 20) |
| 123 | - ->description('The migration version') |
|
| 124 | - ->primary(); |
|
| 123 | + ->description('The migration version') |
|
| 124 | + ->primary(); |
|
| 125 | 125 | $table->string('description') |
| 126 | - ->description('The migration description'); |
|
| 126 | + ->description('The migration description'); |
|
| 127 | 127 | $table->datetime('created_at') |
| 128 | 128 | ->description('Migration run time'); |
| 129 | 129 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ) { |
| 73 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
| 74 | 74 | $this->setName('migration:exec') |
| 75 | - ->setDescription('Execute the migration up/down for one version'); |
|
| 75 | + ->setDescription('Execute the migration up/down for one version'); |
|
| 76 | 76 | |
| 77 | 77 | $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
| 78 | 78 | if (!in_array($val, ['up', 'down'])) { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | )); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - return $val; |
|
| 85 | + return $val; |
|
| 86 | 86 | }); |
| 87 | 87 | |
| 88 | 88 | $this->addOption('-i|--id', 'the migration version', null, false, true); |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | $this->setName('migration:exec') |
| 75 | 75 | ->setDescription('Execute the migration up/down for one version'); |
| 76 | 76 | |
| 77 | - $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
|
| 77 | + $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function($val) { |
|
| 78 | 78 | if (!in_array($val, ['up', 'down'])) { |
| 79 | 79 | throw new RuntimeException(sprintf( |
| 80 | 80 | 'Invalid argument type [%s], must be one of [up, down]', |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | * @template T |
| 60 | 60 | * @extends AbstractCommand<T> |
| 61 | 61 | */ |
| 62 | -class MigrationExecuteCommand extends AbstractCommand |
|
| 63 | -{ |
|
| 62 | +class MigrationExecuteCommand extends AbstractCommand { |
|
| 64 | 63 | |
| 65 | 64 | /** |
| 66 | 65 | * Create new instance |
@@ -93,8 +92,7 @@ discard block |
||
| 93 | 92 | /** |
| 94 | 93 | * {@inheritodc} |
| 95 | 94 | */ |
| 96 | - public function execute() |
|
| 97 | - { |
|
| 95 | + public function execute() { |
|
| 98 | 96 | $type = $this->getArgumentValue('type'); |
| 99 | 97 | |
| 100 | 98 | $io = $this->io(); |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | protected function getExecuted(string $orderDir = 'ASC'): array |
| 215 | 215 | { |
| 216 | 216 | $migrations = $this->repository |
| 217 | - ->query() |
|
| 218 | - ->orderBy('version', $orderDir) |
|
| 219 | - ->all(); |
|
| 217 | + ->query() |
|
| 218 | + ->orderBy('version', $orderDir) |
|
| 219 | + ->all(); |
|
| 220 | 220 | $result = []; |
| 221 | 221 | |
| 222 | 222 | foreach ($migrations as $entity) { |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | protected function getMigrationClassName(string $description, string $version): string |
| 236 | 236 | { |
| 237 | 237 | return Str::camel($description, false) |
| 238 | - . Str::replaceFirst('_', '', $version); |
|
| 238 | + . Str::replaceFirst('_', '', $version); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -65,8 +65,7 @@ |
||
| 65 | 65 | * @package Platine\Framework\Migration\Command |
| 66 | 66 | * @template T |
| 67 | 67 | */ |
| 68 | -abstract class AbstractCommand extends Command |
|
| 69 | -{ |
|
| 68 | +abstract class AbstractCommand extends Command { |
|
| 70 | 69 | |
| 71 | 70 | /** |
| 72 | 71 | * The migration repository |