inex / IXP-Manager

Full stack web application powering peering at over 200 Internet Exchange Points (IXPs) globally.

Home Page:https://www.ixpmanager.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migrations fail on initial setup with an empty database

NetaliDev opened this issue · comments

commented
ISSUE TYPE

Bug Report

OS

NixOS 23.05

VERSION
define( 'APPLICATION_VERSION', '6.3.1' );
define( 'APPLICATION_VERDATE', '2023062000' );
ENVIRONMENT
[root@ixp-manager:~]# /nix/store/yl0s59c1yabcrqfgch2akbpnp6yzyzr7-php-with-extensions-8.2.7/bin/php -v
PHP 8.2.7 (cli) (built: Jun  6 2023 21:28:56) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies

[root@ixp-manager:~]# /nix/store/yl0s59c1yabcrqfgch2akbpnp6yzyzr7-php-with-extensions-8.2.7/bin/php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imap
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
random
readline
Reflection
session
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache
CONFIGURATION
APP_DEBUG="false"
APP_LOG="single"
APP_LOG_LEVEL="info"
APP_TIMEZONE="UTC"
APP_URL="https://ixp-manager.example.com"
CACHE_DRIVER="array"
GRAPHER_BACKENDS="dummy"
GRAPHER_BACKEND_MRTG_DBTYPE="rrd"
GRAPHER_CACHE_ENABLED="true"
IXP_IRRDB_BGPQ3_PATH="/nix/store/nypx2ff0sf3hgv29iim990igzg9krdi8-bgpq3-0.1.36.1/bin/bgpq3"
SUMMARY

The migrations fail on initial setup.

STEPS TO REPRODUCE
  1. Create a clean DB for IXP-Manager.
  2. Run artisan migrate --force twice
EXPECTED RESULTS

The migrations should finish without errors.

ACTUAL RESULTS
[root@ixp-manager:~]# artisan db:wipe --force
Dropped all tables successfully.

[root@ixp-manager:~]# artisan migrate --force
Migration table created successfully.
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table (0.26ms)
Migrating: 2018_08_08_100000_create_telescope_entries_table
Migrated:  2018_08_08_100000_create_telescope_entries_table (0.08ms)
Migrating: 2019_03_25_211956_create_failed_jobs_table
Migrated:  2019_03_25_211956_create_failed_jobs_table (0.05ms)
Migrating: 2020_02_06_204556_create_docstore_directories
Migrated:  2020_02_06_204556_create_docstore_directories (0.05ms)
Migrating: 2020_02_06_204608_create_docstore_files
Migrated:  2020_02_06_204608_create_docstore_files (0.05ms)
Migrating: 2020_02_06_204911_create_docstore_logs
Migrated:  2020_02_06_204911_create_docstore_logs (0.05ms)
Migrating: 2020_03_09_110945_create_docstore_customer_directories
Migrated:  2020_03_09_110945_create_docstore_customer_directories (0.05ms)
Migrating: 2020_03_09_111505_create_docstore_customer_files
Migrated:  2020_03_09_111505_create_docstore_customer_files (0.05ms)
Migrating: 2020_06_01_143931_database_schema_at_end_v5
*** Importing base IXP Manager schema...
Migrated:  2020_06_01_143931_database_schema_at_end_v5 (546.65ms)
Migrating: 2020_07_21_094354_create_route_server_filters
Migrated:  2020_07_21_094354_create_route_server_filters (46.69ms)
Migrating: 2020_09_03_153723_add_timestamps
Migrated:  2020_09_03_153723_add_timestamps (579.36ms)
Migrating: 2020_09_18_095136_delete_ixp_table

In Connection.php line 712:

  SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'ixp_id' doesn't exist in table (SQL: alter table `infrastructure` drop `ixp_id`)


In Connection.php line 501:

  SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'ixp_id' doesn't exist in table



[root@ixp-manager:~]# artisan migrate --force
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table (0.28ms)
Migrating: 2018_08_08_100000_create_telescope_entries_table
Migrated:  2018_08_08_100000_create_telescope_entries_table (0.05ms)
Migrating: 2019_03_25_211956_create_failed_jobs_table
Migrated:  2019_03_25_211956_create_failed_jobs_table (0.05ms)
Migrating: 2020_02_06_204556_create_docstore_directories
Migrated:  2020_02_06_204556_create_docstore_directories (0.05ms)
Migrating: 2020_02_06_204608_create_docstore_files
Migrated:  2020_02_06_204608_create_docstore_files (0.05ms)
Migrating: 2020_02_06_204911_create_docstore_logs
Migrated:  2020_02_06_204911_create_docstore_logs (0.05ms)
Migrating: 2020_03_09_110945_create_docstore_customer_directories
Migrated:  2020_03_09_110945_create_docstore_customer_directories (0.04ms)
Migrating: 2020_03_09_111505_create_docstore_customer_files
Migrated:  2020_03_09_111505_create_docstore_customer_files (0.07ms)
Migrating: 2020_09_18_095136_delete_ixp_table

In Connection.php line 712:

  SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'ixpmanager.customer_to_ixp' (SQL: drop table `customer_to_ixp`)


In Connection.php line 501:

  SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'ixpmanager.customer_to_ixp'
IMPORTANCE

I try to package IXP-Manager for NixOS for our new IXP and encountered this issue.

ADDITIONAL INFORMATION

My current workaround is to remove everything that relates to the ixp and customer_to_ixp tables from 2021-as-at-end-v5.sql and then delete the failing migration 2020_09_18_095136_delete_ixp_table, but I would feel better if the migrations would work out of the box.

Hi @NetaliDev

The migrations fail on initial setup.

I can't replicate this for on initial setup - it works fine via the installer script on Ubuntu 20.04 and 22.04.

I can replicate the issue when I wipe and migrate again.

The difference here is the installer is running as root MySQL user and the artisan script runs as the ixpmanager user.

I've committed the privilege escalation required to make this work as the artisan ixpmanager MySQL user now.