From 8db1b6c467fee498f02a48d8002a6954ed628188 Mon Sep 17 00:00:00 2001 From: darkalchemy Date: Mon, 29 Jun 2020 05:18:52 -0400 Subject: [PATCH] update: phinx --- README.md | 1 + app/Migrations/Migration.php | 3 +- app/Migrations/MigrationStub.php.stub | 10 +- composer.json | 3 +- composer.lock | 272 ++++-------------- config/phinx.php | 3 +- ...0200208201552_create_activations_table.php | 2 +- ...200208201809_create_persistences_table.php | 2 +- .../20200208201824_create_reminders_table.php | 2 +- ...20200208201855_create_role_users_table.php | 4 +- .../20200208201925_create_throttle_table.php | 2 +- .../20200210020722_create_email_table.php | 12 +- 12 files changed, 77 insertions(+), 239 deletions(-) diff --git a/README.md b/README.md index 642ec79..6b26a24 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ If you want to use redis as your session handler, you should add this to php.ini composer cleanup # runs php_cs_fixer composer clear_cache # clears all file based caches composer compile # compile all twig templates +composer create-migration # create new migration class composer migrate # migrate the database composer rollback # rollback all database changes composer set-perms # set writable perms for cache/log folders for both webserver and cli diff --git a/app/Migrations/Migration.php b/app/Migrations/Migration.php index cc36b96..8fad62f 100644 --- a/app/Migrations/Migration.php +++ b/app/Migrations/Migration.php @@ -15,9 +15,8 @@ class Migration extends AbstractMigration { protected Builder $schema; - protected function init() + public function init() { - parent::init(); $this->schema = Capsule::schema(); } } diff --git a/app/Migrations/MigrationStub.php.stub b/app/Migrations/MigrationStub.php.stub index f6e3379..6a740cc 100644 --- a/app/Migrations/MigrationStub.php.stub +++ b/app/Migrations/MigrationStub.php.stub @@ -23,10 +23,6 @@ class $className extends $baseClassName $table->timestamp('last_login')->nullable(); $table->timestamps(); }); - - $this->schema->table('users', function (Blueprint $table) { - - }); } /** @@ -34,10 +30,12 @@ class $className extends $baseClassName */ public function down() { - $this->schema->table('', function (Blueprint $table) { + // rollback + $this->schema->table('users', function (Blueprint $table) { }); - $this->schema->drop(''); + // or drop + $this->schema->drop('users'); } } diff --git a/composer.json b/composer.json index 27803af..565e608 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "odan/session": "^4.0", "php-di/slim-bridge": "^3.0", "phpmailer/phpmailer": "^6.1", - "robmorgan/phinx": "^0.11.4", + "robmorgan/phinx": "^0.12.3", "selective/config": "^0.1.1", "slim/csrf": "^1.0", "slim/flash": "^0.4.0", @@ -70,6 +70,7 @@ "dump": "composer dump-autoload -a", "post-update-cmd": "composer dump-autoload -o", "post-create-project-cmd": "php -r \"copy('config/settings.example.php', 'config/settings.php');\"", + "create-migration": "vendor/bin/phinx create -c config/phinx.php --ansi -- ", "migrate": "vendor/bin/phinx migrate -c config/phinx.php -e default --ansi", "rollback": "vendor/bin/phinx rollback -c config/phinx.php -e default --ansi -t 0", "translate": "php bin/utilities.php translate", diff --git a/composer.lock b/composer.lock index 724c114..2a2593f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,52 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ecabd7135e6539b3e92311dfe36163d9", + "content-hash": "e0b8a933d54642a353371ad160c0163f", "packages": [ - { - "name": "cakephp/cache", - "version": "3.9.0", - "source": { - "type": "git", - "url": "https://github.com/cakephp/cache.git", - "reference": "e8ec4e77fb288adda318e08053f5f540870aeb9d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/cakephp/cache/zipball/e8ec4e77fb288adda318e08053f5f540870aeb9d", - "reference": "e8ec4e77fb288adda318e08053f5f540870aeb9d", - "shasum": "" - }, - "require": { - "cakephp/core": "^3.6.0", - "php": ">=5.6.0", - "psr/simple-cache": "^1.0.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Cake\\Cache\\": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "CakePHP Community", - "homepage": "https://github.com/cakephp/cache/graphs/contributors" - } - ], - "description": "Easy to use Caching library with support for multiple caching backends", - "homepage": "https://cakephp.org", - "keywords": [ - "cache", - "caching", - "cakephp" - ], - "time": "2020-06-16T00:54:28+00:00" - }, { "name": "cakephp/chronos", "version": "2.0.5", @@ -107,20 +63,20 @@ }, { "name": "cakephp/collection", - "version": "3.9.0", + "version": "4.0.9", "source": { "type": "git", "url": "https://github.com/cakephp/collection.git", - "reference": "387cc755ef04a98f8a4461281090465238421d69" + "reference": "96bfd16c815fb8cbdaf736d5dc5dc9236af76567" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/collection/zipball/387cc755ef04a98f8a4461281090465238421d69", - "reference": "387cc755ef04a98f8a4461281090465238421d69", + "url": "https://api.github.com/repos/cakephp/collection/zipball/96bfd16c815fb8cbdaf736d5dc5dc9236af76567", + "reference": "96bfd16c815fb8cbdaf736d5dc5dc9236af76567", "shasum": "" }, "require": { - "php": ">=5.6.0" + "php": ">=7.2.0" }, "type": "library", "autoload": { @@ -149,25 +105,25 @@ "collections", "iterators" ], - "time": "2020-06-13T12:25:53+00:00" + "time": "2020-05-20T14:35:50+00:00" }, { "name": "cakephp/core", - "version": "3.9.0", + "version": "4.0.9", "source": { "type": "git", "url": "https://github.com/cakephp/core.git", - "reference": "76b9450dc68c81f93bca7827cfbb42a53a5f7737" + "reference": "44f2d71250fa8e2d88e93580987bfc2ab0f4455b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/core/zipball/76b9450dc68c81f93bca7827cfbb42a53a5f7737", - "reference": "76b9450dc68c81f93bca7827cfbb42a53a5f7737", + "url": "https://api.github.com/repos/cakephp/core/zipball/44f2d71250fa8e2d88e93580987bfc2ab0f4455b", + "reference": "44f2d71250fa8e2d88e93580987bfc2ab0f4455b", "shasum": "" }, "require": { - "cakephp/utility": "^3.6.0", - "php": ">=5.6.0" + "cakephp/utility": "^4.0", + "php": ">=7.2.0" }, "suggest": { "cakephp/cache": "To use Configure::store() and restore().", @@ -199,28 +155,29 @@ "core", "framework" ], - "time": "2020-06-16T00:54:28+00:00" + "time": "2020-06-12T16:55:29+00:00" }, { "name": "cakephp/database", - "version": "3.9.0", + "version": "4.0.9", "source": { "type": "git", "url": "https://github.com/cakephp/database.git", - "reference": "b90f74859237ff507eb20c47c3b84d564c543688" + "reference": "b7ba8b442cfc3c35acb642824e7a6615763044ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/database/zipball/b90f74859237ff507eb20c47c3b84d564c543688", - "reference": "b90f74859237ff507eb20c47c3b84d564c543688", + "url": "https://api.github.com/repos/cakephp/database/zipball/b7ba8b442cfc3c35acb642824e7a6615763044ab", + "reference": "b7ba8b442cfc3c35acb642824e7a6615763044ab", "shasum": "" }, "require": { - "cakephp/cache": "^3.6.0", - "cakephp/core": "^3.6.0", - "cakephp/datasource": "^3.6.0", - "cakephp/log": "^3.6.0", - "php": ">=5.6.0" + "cakephp/core": "^4.0", + "cakephp/datasource": "^4.0", + "php": ">=7.2.0" + }, + "suggest": { + "cakephp/i18n": "If you are using locale-aware datetime formats or Chronos types." }, "type": "library", "autoload": { @@ -247,25 +204,27 @@ "database abstraction", "pdo" ], - "time": "2020-06-14T02:01:05+00:00" + "time": "2020-06-12T16:55:29+00:00" }, { "name": "cakephp/datasource", - "version": "3.9.0", + "version": "4.0.9", "source": { "type": "git", "url": "https://github.com/cakephp/datasource.git", - "reference": "ef310daf569dc11ef473a9ba0c52429025f672ec" + "reference": "385cf016158ba7c81d78836050eed262f4a8c072" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/datasource/zipball/ef310daf569dc11ef473a9ba0c52429025f672ec", - "reference": "ef310daf569dc11ef473a9ba0c52429025f672ec", + "url": "https://api.github.com/repos/cakephp/datasource/zipball/385cf016158ba7c81d78836050eed262f4a8c072", + "reference": "385cf016158ba7c81d78836050eed262f4a8c072", "shasum": "" }, "require": { - "cakephp/core": "^3.6.0", - "php": ">=5.6.0" + "cakephp/core": "^4.0", + "php": ">=7.2.0", + "psr/log": "^1.1", + "psr/simple-cache": "^1.0" }, "suggest": { "cakephp/cache": "If you decide to use Query caching.", @@ -297,70 +256,25 @@ "entity", "query" ], - "time": "2020-06-16T00:54:28+00:00" - }, - { - "name": "cakephp/log", - "version": "3.9.0", - "source": { - "type": "git", - "url": "https://github.com/cakephp/log.git", - "reference": "02940591797475c2d384af12432561204d6ecdf9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/cakephp/log/zipball/02940591797475c2d384af12432561204d6ecdf9", - "reference": "02940591797475c2d384af12432561204d6ecdf9", - "shasum": "" - }, - "require": { - "cakephp/core": "^3.6.0", - "php": ">=5.6.0", - "psr/log": "^1.0.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Cake\\Log\\": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "CakePHP Community", - "homepage": "https://github.com/cakephp/log/graphs/contributors" - } - ], - "description": "CakePHP logging library with support for multiple different streams", - "homepage": "https://cakephp.org", - "keywords": [ - "Streams", - "cakephp", - "log", - "logging" - ], - "time": "2020-06-16T00:54:28+00:00" + "time": "2020-06-02T17:54:38+00:00" }, { "name": "cakephp/utility", - "version": "3.9.0", + "version": "4.0.9", "source": { "type": "git", "url": "https://github.com/cakephp/utility.git", - "reference": "27d9c7409ad89272e2483e3196aabc47385d3db6" + "reference": "21772f1f404c651890ab10277f32f7a2d77872d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/utility/zipball/27d9c7409ad89272e2483e3196aabc47385d3db6", - "reference": "27d9c7409ad89272e2483e3196aabc47385d3db6", + "url": "https://api.github.com/repos/cakephp/utility/zipball/21772f1f404c651890ab10277f32f7a2d77872d6", + "reference": "21772f1f404c651890ab10277f32f7a2d77872d6", "shasum": "" }, "require": { - "cakephp/core": "^3.6.0", - "php": ">=5.6.0" + "cakephp/core": "^4.0", + "php": ">=7.2.0" }, "suggest": { "ext-intl": "To use Text::transliterate() or Text::slug()", @@ -395,7 +309,7 @@ "string", "utility" ], - "time": "2020-06-14T02:01:05+00:00" + "time": "2020-05-29T20:56:19+00:00" }, { "name": "cartalyst/sentinel", @@ -2704,34 +2618,37 @@ }, { "name": "robmorgan/phinx", - "version": "0.11.7", + "version": "0.12.3", "source": { "type": "git", "url": "https://github.com/cakephp/phinx.git", - "reference": "3cdde73e0c33c410e076108b3e1603fabb5b330d" + "reference": "c63dcecbad83ae5723498e8b78163a4988d118f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/phinx/zipball/3cdde73e0c33c410e076108b3e1603fabb5b330d", - "reference": "3cdde73e0c33c410e076108b3e1603fabb5b330d", + "url": "https://api.github.com/repos/cakephp/phinx/zipball/c63dcecbad83ae5723498e8b78163a4988d118f6", + "reference": "c63dcecbad83ae5723498e8b78163a4988d118f6", "shasum": "" }, "require": { - "cakephp/collection": "^3.7", - "cakephp/database": "^3.7", - "php": ">=5.6", + "cakephp/collection": "^4.0", + "cakephp/database": "^4.0", + "php": ">=7.2", + "psr/container": "^1.0", "symfony/config": "^3.4|^4.0|^5.0", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/yaml": "^3.4|^4.0|^5.0" + "symfony/console": "^3.4|^4.0|^5.0" }, "require-dev": { "cakephp/cakephp-codesniffer": "^3.0", "ext-json": "*", - "phpunit/phpunit": ">=5.7,<8.0", - "sebastian/comparator": ">=1.2.3" + "ext-pdo": "*", + "phpunit/phpunit": "^8.5", + "sebastian/comparator": ">=1.2.3", + "symfony/yaml": "^3.4|^4.0|^5.0" }, "suggest": { "ext-json": "Install if using JSON configuration format", + "ext-pdo": "PDO extension is needed", "symfony/yaml": "Install if using YAML configuration format" }, "bin": [ @@ -2780,7 +2697,7 @@ "migrations", "phinx" ], - "time": "2020-05-09T13:59:05+00:00" + "time": "2020-06-25T23:01:19+00:00" }, { "name": "selective/config", @@ -4823,83 +4740,6 @@ ], "time": "2020-05-20T17:43:50+00:00" }, - { - "name": "symfony/yaml", - "version": "v5.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "ea342353a3ef4f453809acc4ebc55382231d4d23" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/ea342353a3ef4f453809acc4ebc55382231d4d23", - "reference": "ea342353a3ef4f453809acc4ebc55382231d4d23", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<4.4" - }, - "require-dev": { - "symfony/console": "^4.4|^5.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "bin": [ - "Resources/bin/yaml-lint" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-05-20T17:43:50+00:00" - }, { "name": "twig/twig", "version": "v3.0.3", diff --git a/config/phinx.php b/config/phinx.php index ac0db7a..3639e45 100644 --- a/config/phinx.php +++ b/config/phinx.php @@ -6,8 +6,7 @@ require_once __DIR__ . '/../bootstrap/app.php'; -$db = $container->get(Configuration::class) - ->getArray('db'); +$db = $container->get(Configuration::class)->getArray('db'); return [ 'paths' => [ diff --git a/database/migrations/20200208201552_create_activations_table.php b/database/migrations/20200208201552_create_activations_table.php index d62d70b..0d72470 100644 --- a/database/migrations/20200208201552_create_activations_table.php +++ b/database/migrations/20200208201552_create_activations_table.php @@ -14,7 +14,7 @@ public function up() { $this->schema->create('activations', function (Blueprint $table) { $table->increments('id'); - $table->integer('user_id')->unsigned(); + $table->unsignedInteger('user_id'); $table->string('code'); $table->tinyInteger('completed')->default(0); $table->timestamp('completed_at')->nullable(); diff --git a/database/migrations/20200208201809_create_persistences_table.php b/database/migrations/20200208201809_create_persistences_table.php index 31f1626..180e241 100644 --- a/database/migrations/20200208201809_create_persistences_table.php +++ b/database/migrations/20200208201809_create_persistences_table.php @@ -14,7 +14,7 @@ public function up() { $this->schema->create('persistences', function (Blueprint $table) { $table->increments('id'); - $table->integer('user_id')->unsigned(); + $table->unsignedInteger('user_id'); $table->string('code')->unique(); $table->timestamps(); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade'); diff --git a/database/migrations/20200208201824_create_reminders_table.php b/database/migrations/20200208201824_create_reminders_table.php index 2acd788..1a6f23b 100644 --- a/database/migrations/20200208201824_create_reminders_table.php +++ b/database/migrations/20200208201824_create_reminders_table.php @@ -14,7 +14,7 @@ public function up() { $this->schema->create('reminders', function (Blueprint $table) { $table->increments('id'); - $table->integer('user_id')->unsigned(); + $table->unsignedInteger('user_id'); $table->string('code'); $table->tinyInteger('completed')->default(0); $table->timestamp('completed_at')->nullable(); diff --git a/database/migrations/20200208201855_create_role_users_table.php b/database/migrations/20200208201855_create_role_users_table.php index 6b04d0b..ee001d0 100644 --- a/database/migrations/20200208201855_create_role_users_table.php +++ b/database/migrations/20200208201855_create_role_users_table.php @@ -13,8 +13,8 @@ class CreateRoleUsersTable extends Migration public function up() { $this->schema->create('role_users', function (Blueprint $table) { - $table->integer('user_id')->unsigned(); - $table->integer('role_id')->unsigned(); + $table->unsignedInteger('user_id'); + $table->unsignedInteger('role_id'); $table->timestamps(); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade'); }); diff --git a/database/migrations/20200208201925_create_throttle_table.php b/database/migrations/20200208201925_create_throttle_table.php index e58f194..de90592 100644 --- a/database/migrations/20200208201925_create_throttle_table.php +++ b/database/migrations/20200208201925_create_throttle_table.php @@ -14,7 +14,7 @@ public function up() { $this->schema->create('throttle', function (Blueprint $table) { $table->increments('id'); - $table->integer('user_id')->unsigned()->nullable(); + $table->unsignedInteger('user_id')->nullable(); $table->string('type'); $table->string('ip')->nullable(); $table->timestamps(); diff --git a/database/migrations/20200210020722_create_email_table.php b/database/migrations/20200210020722_create_email_table.php index 0a26c5b..9ea1738 100644 --- a/database/migrations/20200210020722_create_email_table.php +++ b/database/migrations/20200210020722_create_email_table.php @@ -14,12 +14,12 @@ public function up() { $this->schema->create('email', function (Blueprint $table) { $table->increments('id'); - $table->integer('user_id')->unsigned(); - $table->tinyInteger('priority')->unsigned()->default(10)->index(); - $table->tinyInteger('sent')->unsigned()->default(0)->index(); - $table->integer('cancelled')->unsigned()->default(0); - $table->integer('send_count')->unsigned()->default(0); - $table->integer('error_count')->unsigned()->default(0); + $table->unsignedInteger('user_id'); + $table->unsignedTinyInteger('priority')->default(10)->index(); + $table->unsignedTinyInteger('sent')->default(0)->index(); + $table->unsignedInteger('cancelled')->default(0); + $table->unsignedInteger('send_count')->default(0); + $table->unsignedInteger('error_count')->default(0); $table->text('subject'); $table->longText('body'); $table->dateTime('date_sent')->nullable()->index();