Skip to content

Instantly share code, notes, and snippets.

@barryo
Last active May 18, 2019 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryo/ef7f0246bf823f59bd62c140e437ac11 to your computer and use it in GitHub Desktop.
Save barryo/ef7f0246bf823f59bd62c140e437ac11 to your computer and use it in GitHub Desktop.
Sample run of IXP Manager upgrade from v4.9.x to v5.0.0
$ git fetch --all
Fetching origin
remote: Enumerating objects: 381, done.
remote: Counting objects: 100% (381/381), done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 713 (delta 342), reused 358 (delta 327), pack-reused 332
Receiving objects: 100% (713/713), 1.13 MiB | 2.37 MiB/s, done.
Resolving deltas: 100% (500/500), completed with 170 local objects.
From https://github.com/inex/IXP-Manager
* [new branch] release-v5 -> origin/release-v5
# for thsi example, I'm using the v5 release branch rather than the v5.0.0 tag
$ git checkout -b release-v5
Switched to a new branch 'release-v5'
$ # Upgrade composer first:
$ php ./composer.phar selfupdate
Updating to version 1.8.5 (stable channel).
Downloading (100%)
Use composer self-update --rollback to return to version 1.8.4
$ # And update the libraries
$ $php ./composer.phar install --no-dev --prefer-dist
Loading composer repositories with package information
Installing dependencies from lock file
Package operations: 15 installs, 32 updates, 5 removals
- Removing symfony/polyfill-php70 (v1.10.0)
- Removing smarty/smarty (v3.1.33)
- Removing mtdowling/cron-expression (v1.2.1)
- Removing graham-campbell/flysystem (v4.1.0)
- Removing graham-campbell/manager (v3.0.0)
- Installing phpoption/phpoption (1.5.0): Loading from cache
- Updating vlucas/phpdotenv (v2.5.2 => v3.3.3): Loading from cache
- Updating symfony/css-selector (v3.4.21 => v4.2.4): Loading from cache
- Installing symfony/polyfill-php72 (v1.10.0): Loading from cache
- Updating symfony/var-dumper (v3.4.21 => v4.2.4): Loading from cache
- Updating symfony/routing (v3.4.21 => v4.2.4): Loading from cache
- Updating symfony/process (v3.4.21 => v4.2.4): Loading from cache
- Updating symfony/http-foundation (v3.4.21 => v4.2.4): Loading from cache
- Installing symfony/contracts (v1.0.2): Loading from cache
- Updating symfony/event-dispatcher (v3.4.21 => v4.2.4): Loading from cache
- Updating symfony/debug (v3.4.21 => v4.2.4): Loading from cache
- Updating symfony/http-kernel (v3.4.21 => v4.2.4): Loading from cache
- Updating symfony/finder (v3.4.21 => v4.2.4): Loading from cache
- Updating symfony/console (v3.4.21 => v4.2.4): Loading from cache
- Installing symfony/polyfill-intl-idn (v1.10.0): Loading from cache
- Installing symfony/polyfill-iconv (v1.10.0): Loading from cache
- Updating swiftmailer/swiftmailer (v6.1.3 => v6.2.0): Loading from cache
- Installing opis/closure (3.1.6): Loading from cache
- Updating symfony/translation (v3.4.21 => v4.2.4): Loading from cache
- Updating nesbot/carbon (1.36.2 => 2.16.0): Loading from cache
- Updating league/flysystem (1.0.49 => 1.0.50): Loading from cache
- Installing dragonmantank/cron-expression (v2.2.0): Loading from cache
- Updating doctrine/inflector (v1.2.0 => v1.3.0): Loading from cache
- Updating laravel/framework (v5.5.44 => v5.8.4): Loading from cache
- Updating anahkiasen/former (4.1.10 => 4.2.0): Loading from cache
- Updating barryvdh/laravel-dompdf (v0.8.3 => v0.8.4): Loading from cache
- Updating beberlei/doctrineextensions (v1.1.5 => v1.2.0): Loading from cache
- Updating doctrine/annotations (v1.4.0 => v1.6.0): Downloading (100%)
- Installing doctrine/reflection (v1.0.0): Loading from cache
- Installing doctrine/event-manager (v1.0.0): Downloading (100%)
- Updating doctrine/collections (v1.4.0 => v1.5.0): Downloading (100%)
- Updating doctrine/cache (v1.6.2 => v1.8.0): Downloading (100%)
- Installing doctrine/persistence (v1.1.0): Loading from cache
- Updating doctrine/common (v2.7.3 => v2.10.0): Loading from cache
- Updating doctrine/dbal (v2.5.13 => v2.9.2): Loading from cache
- Updating doctrine/instantiator (1.0.5 => 1.1.0): Loading from cache
- Updating fideloper/proxy (3.3.4 => 4.1.0): Loading from cache
- Updating symfony/serializer (v3.4.21 => v4.2.4): Loading from cache
- Updating doctrine/orm (v2.5.14 => v2.6.3): Loading from cache
- Updating laravel-doctrine/orm (1.4.9 => 1.4.10): Downloading (100%)
- Updating luketowers/purifier (3.0.5 => 3.0.6): Downloading (100%)
- Updating nikic/php-parser (v4.1.1 => v4.2.1): Loading from cache
- Installing predis/predis (v1.1.1): Loading from cache
- Installing cakephp/chronos (1.2.4): Loading from cache
- Installing laravel/horizon (v3.0.6): Loading from cache
- Installing moontoast/math (1.1.2): Loading from cache
- Installing laravel/telescope (v2.0.2): Loading from cache
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: anahkiasen/former
Discovered Package: barryvdh/laravel-dompdf
Discovered Package: fideloper/proxy
Discovered Package: intervention/image
Discovered Package: laravel-doctrine/orm
Discovered Package: laravel/horizon
Discovered Package: laravel/telescope
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: parsedown/laravel
Package manifest generated successfully.
$ # Restart Memcached and clear the cache. Do not forget / skip this step!
$ systemctl restart memcached.service
$ php artisan cache:clear
Application cache cleared!
$ # DB Migrations - see what will change:
$ php artisan doctrine:schema:update --sql
Checking if database connected to default entity manager needs updating...
CREATE TABLE customer_to_users (id INT AUTO_INCREMENT NOT NULL, customer_id INT NOT NULL, user_id INT NOT NULL, privs INT NOT NULL, extra_attributes JSON DEFAULT NULL COMMENT '(DC2Type:json)', last_login_date DATETIME DEFAULT NULL, last_login_from TINYTEXT DEFAULT NULL, created_at DATETIME NOT NULL, INDEX IDX_337AD7F69395C3F3 (customer_id), INDEX IDX_337AD7F6A76ED395 (user_id), UNIQUE INDEX customer_user (customer_id, user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
ALTER TABLE customer_to_users ADD CONSTRAINT FK_337AD7F69395C3F3 FOREIGN KEY (customer_id) REFERENCES cust (id);
ALTER TABLE customer_to_users ADD CONSTRAINT FK_337AD7F6A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE cust ADD in_manrs TINYINT(1) DEFAULT '0' NOT NULL, ADD in_peeringdb TINYINT(1) DEFAULT '0' NOT NULL, DROP peeringDb;
ALTER TABLE user_logins DROP FOREIGN KEY FK_6341CC99A76ED395;
DROP INDEX at_idx ON user_logins;
ALTER TABLE user_logins ADD customer_to_user_id INT DEFAULT NULL, CHANGE user_id user_id INT DEFAULT NULL;
ALTER TABLE user_logins ADD CONSTRAINT FK_6341CC99D43FEAE2 FOREIGN KEY (customer_to_user_id) REFERENCES customer_to_users (id);
CREATE INDEX IDX_6341CC99D43FEAE2 ON user_logins (customer_to_user_id);
CREATE INDEX at_idx ON user_logins (at);
ALTER TABLE user_logins RENAME INDEX idx_6341cc99a76ed395 TO user_id_idx;
ALTER TABLE user DROP FOREIGN KEY FK_8D93D649DA0209B9;
ALTER TABLE user ADD CONSTRAINT FK_8D93D649DA0209B9 FOREIGN KEY (custid) REFERENCES cust (id) ON DELETE SET NULL;
ALTER TABLE contact DROP FOREIGN KEY FK_4C62E638A76ED395;
DROP INDEX UNIQ_4C62E638A76ED395 ON contact;
ALTER TABLE contact DROP user_id;
ALTER TABLE routers ADD rpki TINYINT(1) DEFAULT '0' NOT NULL;
ALTER TABLE location CHANGE notes notes LONGTEXT DEFAULT NULL
$ # Migrate doctrine:
$ php artisan doctrine:schema:update --force
Checking if database connected to default entity manager needs updating...
Updating database schema...
Database schema updated successfully! "18" queries were executed
$ # Do Laravel's migrations:
$ php artisan migrate --force
Migrating: 2018_08_08_100000_create_telescope_entries_table
Migrated: 2018_08_08_100000_create_telescope_entries_table
Migrating: 2019_03_25_211956_create_failed_jobs_table
Migrated: 2019_03_25_211956_create_failed_jobs_table
$ # Restart Memcached (yes, again). Do not forget / skip this step!
$ systemctl restart memcached.service
$ # Ensure file permissions are still correct.
$ chown -R $MY_WWW_USER: ${IXPROOT}/storage $IXPROOT/vendor $IXPROOT/var $IXPROOT/bootstrap/cache
$ chmod -R ${IXPROOT}/storage $IXPROOT/vendor $IXPROOT/var $IXPROOT/bootstrap/cache
# Clear out all caches:
$ ${IXPROOT}/artisan cache:clear
Application cache cleared!
$ ${IXPROOT}/artisan config:clear
Configuration cache cleared!
$ ${IXPROOT}/artisan doctrine:clear:metadata:cache
Clearing result cache entries for default entity manager
Successfully deleted cache entries.
$ ${IXPROOT}/artisan doctrine:clear:query:cache
Clearing result cache entries for default entity manager
Successfully deleted cache entries.
$ ${IXPROOT}/artisan doctrine:clear:result:cache
Clearing result cache entries for default entity manager
Successfully deleted cache entries.
$ ${IXPROOT}/artisan route:clear
Route cache cleared!
$ ${IXPROOT}/artisan view:clear
Compiled views cleared!
$ ### Users
$ # expunge login logs >6 months
$ php artisan utils:expunge-logs -v
Expunging user login records > 6 months... [done]
$ # refactor user/customer entries for n:1 to n:m (customer:user)
$ # (you'll get warnings but as long as you are doing this as part of the V5.0.09 upgrade, it is safe)
$ php artisan update:customer2users
ONLY RUN ONCE AND ONLY WHEN UPGRADING TO IXP Manager v5.0.0 from v4.9.x
THIS WILL TRUNCATE THE customer:user n:m TABLE - meaning any users created after upgrading to v5.0.0 will be unlinked from their customers.
This command will restructure the customer/user data from 1:m to n:m.
Generally, this command should only ever be run once and only when migrating to V5.0.0.
Are you sure you wish to proceed? (yes/no) [no]:
> yes
The customer_to_users table has been truncated
Migration in progress, please wait...
697/697 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Migration completed successfully
$ # delete CUSTADMIN users (optional but recommended)
$ php artisan update:remove-custadmins
ONLY RUN ONCE AND ONLY WHEN UPGRADING TO IXP Manager v5.0.0 from v4.9.x
THIS WILL DELETE ALL the CUSTADMIN from the USER TABLE.
This command will remove all the custadmin from the user table.
Generally, this command should only ever be run once and only when migrating to V5.0.0.
Are you sure you wish to proceed? (yes/no) [no]:
> yes
Migration in progress, please wait...
243/243 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Migration completed successfully
$ # promote `CUSTUSER`s to `CUSTADMIN`s (optional but highly recommended)
$ php artisan update:promote-custusers
ONLY RUN ONCE AND ONLY WHEN UPGRADING TO IXP Manager v5.0.0 from v4.9.x
THIS HAS TO BE RUN AFTER THE COMMAND : update:remove-custadmins
THIS WILL PROMOTE ALL the CUSTUSER INTO CUSTADMIN.
This command will promote all the CustUser into CustAdmin.
Generally, this command should only ever be run once and only when migrating to V5.0.0.
Are you sure you wish to proceed? (yes/no) [no]:
> yes
Migration in progress, please wait...
440/440 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Migration completed successfully
$ # Disable maintenance mode:
$ ./artisan up
$ # House keeping
$ rm -rf /srv/ixpmanager/var
$ rm -rf /srv/ixpmanager/public/bower_components
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment