YunoHost-Apps / kimai2_ynh

Kimai v2 package for YunoHost
https://www.kimai.org/
MIT License
13 stars 8 forks source link

New release - Kimai 0.6 #8

Closed kevinpapst closed 5 years ago

kevinpapst commented 5 years ago

Hi @anmol26s , the next version is ready for installation: https://github.com/kevinpapst/kimai2/releases/tag/0.6

I can't remember any BC break, but please test the upgrade first. And let me know if you need any support!

anmol26s commented 5 years ago

Hi @kevinpapst Thanks for your wonderful work. I tried upgrading from test branch but migration is failing.

> ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL
118849 DEBUG Migration 20181031220003 failed during Execution. Error An exception occurred while executing 'ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL':
118849 WARNING 03:23:49 ERROR     [console] Error thrown while running command "doctrine:migrations:migrate -n". Message: "An exception occurred while executing 'ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL':\n\nSQLSTATE[HY000]: General error: 1832 Cannot change column 'customer_id': used in a foreign key constraint 'FK_407F12069395C3F3'" ["exception" => Doctrine\DBAL\Exception\DriverException { …},"command" => "doctrine:migrations:migrate -n","message" => """  An exception occurred while executing 'ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL':\n  \n  SQLSTATE[HY000]: General error: 1832 Cannot change column 'customer_id': used in a foreign key constraint 'FK_407F12069395C3F3'  """]
118850 DEBUG 
118850 WARNING 
118850 DEBUG SQLSTATE[HY000]: General error: 1832 Cannot change column 'customer_id': used in a foreign key constraint 'FK_407F12069395C3F3'
kevinpapst commented 5 years ago

Oha, thats bad. Did you upgrade from 0.5? Works form me:

Migrating up to 20181031220003 from 20180924111853

  ++ migrating 20181031220003

     -> ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL
     -> ALTER TABLE kimai2_timesheet ADD project_id INT DEFAULT NULL AFTER activity_id
     -> ALTER TABLE kimai2_timesheet ADD CONSTRAINT FK_4F60C6B1166D1F9C FOREIGN KEY (project_id) REFERENCES kimai2_projects (id) ON DELETE CASCADE
     -> CREATE INDEX IDX_4F60C6B1166D1F9C ON kimai2_timesheet (project_id)
     -> UPDATE kimai2_timesheet SET project_id = (SELECT project_id FROM kimai2_activities WHERE id = activity_id)
     -> ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHANGE activity_id activity_id INT NOT NULL

  ++ migrated (0.33s)

I guess I have to setup 0.5 from scratch and test again.

anmol26s commented 5 years ago

yes I upgrade from 0.5 to 0.6.

kevinpapst commented 5 years ago

Okay, I tested it again from a fresh 0.5 installation, worked as well. And if I generate the database migration again, I get the same "ALTER statements". Also tested the upgrade in on my live system, which worked as well.

Lets see if this is probably another reason... Can you show me the full output, not only the exception part? I am interested in the part Migrating up to 20181031220003 from xxxxx.

anmol26s commented 5 years ago

Here is the log:

exec_composer /var/www/kimai2 install --no-dev --optimize-autoloader
102374 DEBUG + local WORKDIR=/var/www/kimai2
102374 DEBUG + shift 1
102374 DEBUG + COMPOSER_HOME=/var/www/kimai2/.composer
102374 DEBUG + sudo /usr/bin/php7.2 /var/www/kimai2/composer.phar install --no-dev --optimize-autoloader -d /var/www/kimai2
102677 WARNING Do not run Composer as root/super user! See https://getcomposer.org/root for details
102777 WARNING Loading composer repositories with package information
102779 WARNING Installing dependencies from lock file
102780 WARNING Package operations: 105 installs, 0 updates, 0 removals
102780 WARNING   - Installing ocramius/package-versions (1.3.0): Loading from cache
102780 WARNING   - Installing symfony/flex (v1.1.1): Loading from cache
102881 WARNING   - Installing beberlei/doctrineextensions (v1.1.5): Loading from cache
102881 WARNING   - Installing symfony/polyfill-mbstring (v1.9.0): Loading from cache
102882 WARNING   - Installing symfony/polyfill-ctype (v1.9.0): Loading from cache
102882 WARNING   - Installing doctrine/lexer (v1.0.1): Loading from cache
102983 WARNING   - Installing doctrine/annotations (v1.6.0): Loading from cache
102983 WARNING   - Installing doctrine/reflection (v1.0.0): Loading from cache
102983 WARNING   - Installing doctrine/event-manager (v1.0.0): Loading from cache
102984 WARNING   - Installing doctrine/collections (v1.5.0): Loading from cache
103084 WARNING   - Installing doctrine/cache (v1.8.0): Loading from cache
103084 WARNING   - Installing doctrine/persistence (v1.0.1): Loading from cache
103085 WARNING   - Installing doctrine/inflector (v1.3.0): Loading from cache
103085 WARNING   - Installing doctrine/common (v2.9.0): Loading from cache
103185 WARNING   - Installing symfony/doctrine-bridge (v4.1.6): Loading from cache
103186 WARNING   - Installing doctrine/doctrine-cache-bundle (1.3.3): Loading from cache
103186 WARNING   - Installing doctrine/instantiator (1.1.0): Loading from cache
103286 WARNING   - Installing symfony/console (v4.1.6): Loading from cache
103287 WARNING   - Installing zendframework/zend-eventmanager (3.2.1): Loading from cache
103287 WARNING   - Installing zendframework/zend-code (3.3.1): Loading from cache
103388 WARNING   - Installing ocramius/proxy-manager (2.1.1): Loading from cache
103388 WARNING   - Installing doctrine/dbal (v2.8.0): Loading from cache
103489 WARNING   - Installing doctrine/migrations (v1.8.1): Loading from cache
103490 WARNING   - Installing egulias/email-validator (2.1.6): Loading from cache
103490 WARNING   - Installing erusev/parsedown (1.7.1): Loading from cache
103591 WARNING   - Installing willdurand/negotiation (v2.3.1): Loading from cache
103591 WARNING   - Installing willdurand/jsonp-callback-validator (v1.1.0): Loading from cache
103591 WARNING   - Installing symfony/templating (v4.1.6): Loading from cache
103692 WARNING   - Installing symfony/inflector (v4.1.6): Loading from cache
103692 WARNING   - Installing symfony/property-access (v4.1.6): Loading from cache
103693 WARNING   - Installing symfony/http-foundation (v4.1.6): Loading from cache
103793 WARNING   - Installing symfony/event-dispatcher (v4.1.6): Loading from cache
103794 WARNING   - Installing psr/log (1.0.2): Loading from cache
103794 WARNING   - Installing symfony/debug (v4.1.6): Loading from cache
103895 WARNING   - Installing symfony/http-kernel (v4.1.6): Loading from cache
103895 WARNING   - Installing symfony/security (v4.1.6): Loading from cache
103998 WARNING   - Installing symfony/routing (v4.1.6): Loading from cache
104000 WARNING   - Installing symfony/finder (v4.1.6): Loading from cache
104102 WARNING   - Installing symfony/filesystem (v4.1.6): Loading from cache
104102 WARNING   - Installing psr/container (1.0.0): Loading from cache
104103 WARNING   - Installing symfony/dependency-injection (v4.1.6): Loading from cache
104217 WARNING   - Installing symfony/config (v4.1.6): Loading from cache
104217 WARNING   - Installing psr/simple-cache (1.0.1): Loading from cache
104318 WARNING   - Installing psr/cache (1.0.1): Loading from cache
104318 WARNING   - Installing symfony/cache (v4.1.6): Loading from cache
104319 WARNING   - Installing symfony/framework-bundle (v4.1.6): Loading from cache
104419 WARNING   - Installing friendsofsymfony/rest-bundle (2.4.0): Loading from cache
104522 WARNING   - Installing twig/twig (v2.5.0): Loading from cache
104523 WARNING   - Installing symfony/translation (v4.1.6): Loading from cache
104624 WARNING   - Installing symfony/validator (v4.1.6): Loading from cache
104725 WARNING   - Installing symfony/twig-bridge (v4.1.6): Loading from cache
104726 WARNING   - Installing symfony/twig-bundle (v4.1.6): Loading from cache
104726 WARNING   - Installing symfony/security-bundle (v4.1.6): Loading from cache
104827 WARNING   - Installing symfony/options-resolver (v4.1.6): Loading from cache
104831 WARNING   - Installing symfony/intl (v4.1.6): Loading from cache
105137 WARNING   - Installing symfony/polyfill-intl-icu (v1.9.0): Loading from cache
105238 WARNING   - Installing symfony/form (v4.1.6): Loading from cache
105238 WARNING   - Installing paragonie/random_compat (v2.0.17): Loading from cache
105339 WARNING   - Installing friendsofsymfony/user-bundle (v2.1.2): Loading from cache
105340 WARNING   - Installing jdorn/sql-formatter (v1.2.17): Loading from cache
105440 WARNING   - Installing jms/metadata (1.6.0): Loading from cache
105441 WARNING   - Installing phpoption/phpoption (1.5.0): Loading from cache
105441 WARNING   - Installing jms/parser-lib (1.0.0): Loading from cache
105442 WARNING   - Installing phpcollection/phpcollection (0.5.0): Loading from cache
105543 WARNING   - Installing jms/serializer (1.13.0): Loading from cache
105643 WARNING   - Installing jms/serializer-bundle (2.4.2): Loading from cache
105644 WARNING   - Installing kevinpapst/adminlte-bundle (2.1.2): Loading from cache
105747 WARNING   - Installing zircote/swagger-php (2.0.13): Loading from cache
105747 WARNING   - Installing symfony/property-info (v4.1.6): Loading from cache
105849 WARNING   - Installing webmozart/assert (1.3.0): Loading from cache
105849 WARNING   - Installing phpdocumentor/reflection-common (1.0.1): Loading from cache
105849 WARNING   - Installing phpdocumentor/type-resolver (0.4.0): Loading from cache
105850 WARNING   - Installing phpdocumentor/reflection-docblock (4.3.0): Loading from cache
105950 WARNING   - Installing exsyst/swagger (v0.4.1): Loading from cache
105951 WARNING   - Installing nelmio/api-doc-bundle (v3.3.0): Loading from cache
106253 WARNING   - Installing pclzip/pclzip (2.8.2): Loading from cache
106254 WARNING   - Installing markbaker/complex (1.4.6): Loading from cache
106254 WARNING   - Installing phpoffice/phpspreadsheet (1.4.1): Loading from cache
106456 WARNING   - Installing zendframework/zend-escaper (2.6.0): Loading from cache
106557 WARNING   - Installing phpoffice/common (0.2.9): Loading from cache
106557 WARNING   - Installing phpoffice/phpword (0.15.0): Loading from cache
106558 WARNING   - Installing sensio/framework-extra-bundle (v5.2.1): Loading from cache
106658 WARNING   - Installing symfony/dotenv (v4.1.6): Loading from cache
106658 WARNING   - Installing symfony/expression-language (v4.1.6): Loading from cache
106659 WARNING   - Installing monolog/monolog (1.23.0): Loading from cache
106759 WARNING   - Installing symfony/monolog-bridge (v4.1.6): Loading from cache
106760 WARNING   - Installing symfony/monolog-bundle (v3.3.0): Loading from cache
106760 WARNING   - Installing doctrine/orm (v2.6.2): Loading from cache
106962 WARNING   - Installing doctrine/doctrine-bundle (1.9.1): Loading from cache
106962 WARNING   - Installing doctrine/doctrine-migrations-bundle (v1.3.1): Loading from cache
106962 WARNING   - Installing symfony/orm-pack (v1.0.5): Loading from cache
107063 WARNING   - Installing symfony/polyfill-php72 (v1.9.0): Loading from cache
107064 WARNING   - Installing symfony/var-dumper (v4.1.6): Loading from cache
107064 WARNING   - Installing symfony/web-profiler-bundle (v4.1.6): Loading from cache
107164 WARNING   - Installing symfony/stopwatch (v4.1.6): Loading from cache
107165 WARNING   - Installing symfony/profiler-pack (v1.0.3): Loading from cache
107165 WARNING   - Installing symfony/serializer (v4.1.6): Loading from cache
107265 WARNING   - Installing swiftmailer/swiftmailer (v6.1.3): Loading from cache
107266 WARNING   - Installing symfony/swiftmailer-bundle (v3.2.3): Loading from cache
107366 WARNING   - Installing symfony/asset (v4.1.6): Loading from cache
107367 WARNING   - Installing symfony/webpack-encore-pack (v1.0.3): Loading from cache
107468 WARNING   - Installing symfony/yaml (v4.1.6): Loading from cache
107468 WARNING   - Installing twig/extensions (v1.5.2): Loading from cache
107569 WARNING   - Installing pagerfanta/pagerfanta (v2.0.1): Loading from cache
107569 WARNING   - Installing white-october/pagerfanta-bundle (v1.2.2): Loading from cache
107973 WARNING Generating optimized autoload files
109680 DEBUG ocramius/package-versions:  Generating version class...
109681 DEBUG ocramius/package-versions: ...done generating version class
115800 WARNING Executing script cache:clear [OK]
116101 DEBUG 
116101 WARNING Executing script assets:install [OK]
116102 DEBUG + cd /var/www/kimai2
116102 DEBUG + sudo /usr/bin/php7.2 bin/console cache:clear --env=prod
116302 DEBUG 
116303 DEBUG  // Clearing the cache for the prod environment with debug false
116303 DEBUG 
121630 DEBUG  [OK] Cache for the "prod" environment (debug=false) was successfully cleared.
121630 DEBUG 
121631 DEBUG + cd /var/www/kimai2
121631 DEBUG + sudo /usr/bin/php7.2 bin/console cache:warmup --env=prod
121935 DEBUG 
121936 DEBUG  // Warming up the cache for the prod environment with debug false
121936 DEBUG 
122638 DEBUG  [OK] Cache for the "prod" environment (debug=false) was successfully warmed.
122639 DEBUG 
122639 DEBUG + cd /var/www/kimai2
122639 DEBUG + sudo /usr/bin/php7.2 bin/console doctrine:migrations:migrate -n
122940 DEBUG 
122941 DEBUG                     Application Migrations
122941 DEBUG 
122941 DEBUG 
122941 DEBUG Migrating up to 20181031220003 from 20180924111853
122942 DEBUG 
122942 DEBUG   ++ migrating 20181031220003
122942 DEBUG 
122942 DEBUG      -> ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL
122942 DEBUG Migration 20181031220003 failed during Execution. Error An exception occurred while executing 'ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL':
122942 DEBUG 
122943 DEBUG SQLSTATE[HY000]: General error: 1832 Cannot change column 'customer_id': used in a foreign key constraint 'FK_407F12069395C3F3'
123043 DEBUG + ynh_exit_properly
123044 WARNING 04:40:41 ERROR     [console] Error thrown while running command "doctrine:migrations:migrate -n". Message: "An exception occurred while executing 'ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL':\n\nSQLSTATE[HY000]: General error: 1832 Cannot change column 'customer_id': used in a foreign key constraint 'FK_407F12069395C3F3'" ["exception" => Doctrine\DBAL\Exception\DriverException { …},"command" => "doctrine:migrations:migrate -n","message" => """  An exception occurred while executing 'ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL':\n  \n  SQLSTATE[HY000]: General error: 1832 Cannot change column 'customer_id': used in a foreign key constraint 'FK_407F12069395C3F3'  """]
123044 DEBUG + local exit_code=1
123044 WARNING 
123044 DEBUG + '[' 1 -eq 0 ']'
123044 WARNING In AbstractMySQLDriver.php line 126:
123045 DEBUG + trap '' EXIT
123045 WARNING 
123045 DEBUG + set +eu
123045 WARNING   An exception occurred while executing 'ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL':
123045 DEBUG + echo -e '!!\n  kimai2'\''s script has encountered an error. Its execution was cancelled.\n!!'
123045 WARNING 
123046 DEBUG + type -t ynh_clean_setup
123046 WARNING   SQLSTATE[HY000]: General error: 1832 Cannot change column 'customer_id': used in a foreign key constraint 'FK_407F12069395C3F3'
123046 DEBUG + ynh_clean_setup
123046 WARNING 
123047 DEBUG + ynh_restore_upgradebackup
123047 WARNING 
123047 DEBUG + echo 'Upgrade failed.'
123048 WARNING In PDOConnection.php line 109:
123048 DEBUG + local app_bck=kimai2
123048 WARNING 
123048 DEBUG + NO_BACKUP_UPGRADE=0
123048 WARNING   SQLSTATE[HY000]: General error: 1832 Cannot change column 'customer_id': used in a foreign key constraint 'FK_407F12069395C3F3'
123048 DEBUG + '[' 0 -eq 0 ']'
123049 WARNING 
123049 DEBUG + sudo yunohost backup list
123049 WARNING 
123049 DEBUG + grep -q kimai2-pre-upgrade1
123049 WARNING In PDOConnection.php line 107:
123049 WARNING 
123049 WARNING   SQLSTATE[HY000]: General error: 1832 Cannot change column 'customer_id': used in a foreign key constraint 'FK_407F12069395C3F3'
123050 WARNING 
123050 WARNING 
123050 WARNING doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]
123050 WARNING 
123050 WARNING !!
123050 WARNING   kimai2's script has encountered an error. Its execution was cancelled.
123051 WARNING !!
123051 WARNING Upgrade failed.
kevinpapst commented 5 years ago

Okay, then the upgrade way is correct.

Then I guess this is somehow related to MySQL vs MariaDB. MariaDB is not fully compatible with MySQL - I am currently investigating another problem where a query fails on MySQL which works on MariaDB.

Could you manually change the migration class before starting the update? I need to test a different SQL (first dropping the foreign key and then re-adding it after the update)

kevinpapst commented 5 years ago

You would need to replace this line: https://github.com/kevinpapst/kimai2/blob/master/src/Migrations/Version20181031220003.php#L59 with these three lines:

            $this->addSql('ALTER TABLE ' . $projects . ' DROP FOREIGN KEY FK_407F12069395C3F3');
            $this->addSql('ALTER TABLE ' . $projects . ' CHANGE customer_id customer_id INT NOT NULL');
            $this->addSql('ALTER TABLE ' . $projects . ' ADD CONSTRAINT FK_407F12069395C3F3 FOREIGN KEY (customer_id) REFERENCES ' . $customers . ' (id) ON DELETE CASCADE');
anmol26s commented 5 years ago

Sqlite works well. Can't this be fixed at your end?

kevinpapst commented 5 years ago

I cannot reproduce the problem. Did you see my postings above? Can you run the adjusted migration manually on your test server?

kevinpapst commented 5 years ago

Can you try my linked PR? It works like before for me, maybe removing and adding the Foreign keys fixes the MySQL problem. I don't want to create another tag just for testing and without knowing if it really fixes the issue ;-)

anmol26s commented 5 years ago

Can you please a quick branch for test so that I can test it? It would be so helpful.

kevinpapst commented 5 years ago

I guess I don't understand :-( Do you need a branch with the adapted migration? This is already existing in the linked PR: https://github.com/kevinpapst/kimai2/pull/430 Branch: fix-migration - see https://github.com/kevinpapst/kimai2/tree/fix-migration

anmol26s commented 5 years ago

Thanks for the pointing out the branch. I am sometimes very stupid in these things :D This branch is failing too.

Logs:

  - Installing white-october/pagerfanta-bundle (v1.2.2): Loading from cache
82109 WARNING Generating optimized autoload files
83723 DEBUG ocramius/package-versions:  Generating version class...
83723 DEBUG ocramius/package-versions: ...done generating version class
88444 WARNING Executing script cache:clear [OK]
88645 DEBUG 
88646 WARNING Executing script assets:install [OK]
88746 DEBUG + cd /var/www/kimai2
88747 DEBUG + sudo /usr/bin/php7.2 bin/console cache:clear --env=prod
88847 DEBUG 
88848 DEBUG  // Clearing the cache for the prod environment with debug false
88848 DEBUG 
94173 DEBUG  [OK] Cache for the "prod" environment (debug=false) was successfully cleared.
94174 DEBUG 
94174 DEBUG + cd /var/www/kimai2
94174 DEBUG + sudo /usr/bin/php7.2 bin/console cache:warmup --env=prod
94376 DEBUG 
94377 DEBUG  // Warming up the cache for the prod environment with debug false
94377 DEBUG 
94980 DEBUG  [OK] Cache for the "prod" environment (debug=false) was successfully warmed.
94980 DEBUG 
94981 DEBUG + cd /var/www/kimai2
94981 DEBUG + sudo /usr/bin/php7.2 bin/console doctrine:migrations:migrate -n
95181 DEBUG 
95182 DEBUG                     Application Migrations
95184 DEBUG 
95185 DEBUG 
95185 DEBUG Migrating up to 20181031220003 from 20180924111853
95285 DEBUG 
95286 DEBUG   ++ migrating 20181031220003
95286 DEBUG 
95286 DEBUG      -> ALTER TABLE kimai2_projects DROP FOREIGN KEY FK_407F12069395C3F3
95286 DEBUG      -> ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL
95387 DEBUG      -> ALTER TABLE kimai2_projects ADD CONSTRAINT FK_407F12069395C3F3 FOREIGN KEY (customer_id) REFERENCES kimai2_customers (id) ON DELETE CASCADE
95488 DEBUG      -> ALTER TABLE kimai2_timesheet ADD project_id INT DEFAULT NULL AFTER activity_id
95488 DEBUG      -> ALTER TABLE kimai2_timesheet ADD CONSTRAINT FK_4F60C6B1166D1F9C FOREIGN KEY (project_id) REFERENCES kimai2_projects (id) ON DELETE CASCADE
95689 DEBUG      -> CREATE INDEX IDX_4F60C6B1166D1F9C ON kimai2_timesheet (project_id)
95790 DEBUG      -> UPDATE kimai2_timesheet SET project_id = (SELECT project_id FROM kimai2_activities WHERE id = activity_id)
95790 WARNING 16:37:36 ERROR     [console] Error thrown while running command "doctrine:migrations:migrate -n". Message: "An exception occurred while executing 'ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHANGE activity_id activity_id INT NOT NULL':\n\nSQLSTATE[HY000]: General error: 1832 Cannot change column 'project_id': used in a foreign key constraint 'FK_4F60C6B1166D1F9C'" ["exception" => Doctrine\DBAL\Exception\DriverException { …},"command" => "doctrine:migrations:migrate -n","message" => """  An exception occurred while executing 'ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHANGE activity_id activity_id INT NOT NULL':\n  \n  SQLSTATE[HY000]: General error: 1832 Cannot change column 'project_id': used in a foreign key constraint 'FK_4F60C6B1166D1F9C'  """]
95791 DEBUG      -> ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHANGE activity_id activity_id INT NOT NULL
95791 WARNING 
95791 DEBUG Migration 20181031220003 failed during Execution. Error An exception occurred while executing 'ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHANGE activity_id activity_id INT NOT NULL':
95792 WARNING In AbstractMySQLDriver.php line 126:
95792 DEBUG 
95793 WARNING 
95794 DEBUG SQLSTATE[HY000]: General error: 1832 Cannot change column 'project_id': used in a foreign key constraint 'FK_4F60C6B1166D1F9C'
95794 WARNING   An exception occurred while executing 'ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHAN
95794 DEBUG + ynh_exit_properly
95794 WARNING   GE activity_id activity_id INT NOT NULL':
95795 DEBUG + local exit_code=1
95795 WARNING 
95795 DEBUG + '[' 1 -eq 0 ']'
95796 WARNING   SQLSTATE[HY000]: General error: 1832 Cannot change column 'project_id': used in a foreign key constraint 'FK_4F60C6B1166D1F9C'
95796 DEBUG + trap '' EXIT
95797 WARNING 
95797 DEBUG + set +eu
95797 WARNING 
95798 DEBUG + echo -e '!!\n  kimai2'\''s script has encountered an error. Its execution was cancelled.\n!!'
95798 WARNING In PDOConnection.php line 109:
95798 DEBUG + type -t ynh_clean_setup
95798 WARNING 
95798 DEBUG + ynh_clean_setup
95799 WARNING   SQLSTATE[HY000]: General error: 1832 Cannot change column 'project_id': used in a foreign key constraint 'FK_4F60C6B1166D1F9C'
95802 DEBUG + ynh_restore_upgradebackup
95803 WARNING 
95806 DEBUG + echo 'Upgrade failed.'
95808 WARNING 
95808 DEBUG + local app_bck=kimai2
95809 WARNING In PDOConnection.php line 107:
95810 DEBUG + NO_BACKUP_UPGRADE=0
95811 WARNING 
95812 DEBUG + '[' 0 -eq 0 ']'
95813 WARNING   SQLSTATE[HY000]: General error: 1832 Cannot change column 'project_id': used in a foreign key constraint 'FK_4F60C6B1166D1F9C'
95813 DEBUG + sudo yunohost backup list
95814 WARNING 
95814 DEBUG + grep -q kimai2-pre-upgrade2
95814 WARNING 
95814 WARNING doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]
95815 WARNING 
95815 WARNING !!
95815 WARNING   kimai2's script has encountered an error. Its execution was cancelled.
95815 WARNING !!
95815 WARNING Upgrade failed.
kevinpapst commented 5 years ago

Thats painful... it's almost 2019 and we still have to workaround weird database behavior :-( which MySQL version are you using?

Ok, but the test was more or less successful, now we know that dropping the foreign key and recreating it seems to be working. I'll update the branch for the next failing statement later and give you another ping.

kevinpapst commented 5 years ago

Pushed another update, please pull and try again

anmol26s commented 5 years ago

Unfortunately it fails again. Mysql version Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1

WARNING Generating optimized autoload files
91878 DEBUG ocramius/package-versions:  Generating version class...
91879 DEBUG ocramius/package-versions: ...done generating version class
96006 WARNING Executing script cache:clear [OK]
96207 DEBUG 
96208 WARNING Executing script assets:install [OK]
96208 DEBUG + cd /var/www/kimai2
96209 DEBUG + sudo /usr/bin/php7.2 bin/console cache:clear --env=prod
96410 DEBUG 
96410 DEBUG  // Clearing the cache for the prod environment with debug false
96410 DEBUG 
100530 DEBUG  [OK] Cache for the "prod" environment (debug=false) was successfully cleared.
100531 DEBUG 
100531 DEBUG + cd /var/www/kimai2
100531 DEBUG + sudo /usr/bin/php7.2 bin/console cache:warmup --env=prod
100732 DEBUG 
100732 DEBUG  // Warming up the cache for the prod environment with debug false
100732 DEBUG 
101334 DEBUG  [OK] Cache for the "prod" environment (debug=false) was successfully warmed.
101335 DEBUG 
101335 DEBUG + cd /var/www/kimai2
101335 DEBUG + sudo /usr/bin/php7.2 bin/console doctrine:migrations:migrate -n
101637 DEBUG 
101637 DEBUG                     Application Migrations
101638 DEBUG 
101638 DEBUG 
101638 DEBUG Migrating up to 20181031220003 from 20180924111853
101639 DEBUG 
101639 DEBUG   ++ migrating 20181031220003
101639 DEBUG 
101639 DEBUG      -> ALTER TABLE kimai2_projects DROP FOREIGN KEY FK_407F12069395C3F3
101640 DEBUG      -> ALTER TABLE kimai2_projects CHANGE customer_id customer_id INT NOT NULL
101740 DEBUG      -> ALTER TABLE kimai2_projects ADD CONSTRAINT FK_407F12069395C3F3 FOREIGN KEY (customer_id) REFERENCES kimai2_customers (id) ON DELETE CASCADE
101941 DEBUG      -> ALTER TABLE kimai2_timesheet ADD project_id INT DEFAULT NULL AFTER activity_id
102042 DEBUG      -> CREATE INDEX IDX_4F60C6B1166D1F9C ON kimai2_timesheet (project_id)
102143 DEBUG      -> UPDATE kimai2_timesheet SET project_id = (SELECT project_id FROM kimai2_activities WHERE id = activity_id)
102144 WARNING 17:33:23 ERROR     [console] Error thrown while running command "doctrine:migrations:migrate -n". Message: "An exception occurred while executing 'ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHANGE activity_id activity_id INT NOT NULL':\n\nSQLSTATE[HY000]: General error: 1832 Cannot change column 'activity_id': used in a foreign key constraint 'FK_4F60C6B181C06096'" ["exception" => Doctrine\DBAL\Exception\DriverException { …},"command" => "doctrine:migrations:migrate -n","message" => """  An exception occurred while executing 'ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHANGE activity_id activity_id INT NOT NULL':\n  \n  SQLSTATE[HY000]: General error: 1832 Cannot change column 'activity_id': used in a foreign key constraint 'FK_4F60C6B181C06096'  """]
102144 DEBUG      -> ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHANGE activity_id activity_id INT NOT NULL
102144 WARNING 
102145 DEBUG Migration 20181031220003 failed during Execution. Error An exception occurred while executing 'ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHANGE activity_id activity_id INT NOT NULL':
102146 WARNING In AbstractMySQLDriver.php line 126:
102146 DEBUG 
102146 WARNING 
102146 DEBUG SQLSTATE[HY000]: General error: 1832 Cannot change column 'activity_id': used in a foreign key constraint 'FK_4F60C6B181C06096'
102147 WARNING   An exception occurred while executing 'ALTER TABLE kimai2_timesheet CHANGE project_id project_id INT NOT NULL, CHANGE user user INT NOT NULL, CHAN
102147 DEBUG + ynh_exit_properly
102147 WARNING   GE activity_id activity_id INT NOT NULL':
102147 DEBUG + local exit_code=1
102147 WARNING 
102147 DEBUG + '[' 1 -eq 0 ']'
102147 WARNING   SQLSTATE[HY000]: General error: 1832 Cannot change column 'activity_id': used in a foreign key constraint 'FK_4F60C6B181C06096'
102148 DEBUG + trap '' EXIT
102148 WARNING 
102148 DEBUG + set +eu
102148 WARNING 
102148 DEBUG + echo -e '!!\n  kimai2'\''s script has encountered an error. Its execution was cancelled.\n!!'
102148 WARNING In PDOConnection.php line 109:
102148 DEBUG + type -t ynh_clean_setup
102149 WARNING 
102149 DEBUG + ynh_clean_setup
102149 WARNING   SQLSTATE[HY000]: General error: 1832 Cannot change column 'activity_id': used in a foreign key constraint 'FK_4F60C6B181C06096'
102149 DEBUG + ynh_restore_upgradebackup
102149 WARNING 
102149 DEBUG + echo 'Upgrade failed.'
102150 WARNING 
102150 DEBUG + local app_bck=kimai2
102150 WARNING In PDOConnection.php line 107:
102150 DEBUG + NO_BACKUP_UPGRADE=0
102150 WARNING 
102150 DEBUG + '[' 0 -eq 0 ']'
102151 WARNING   SQLSTATE[HY000]: General error: 1832 Cannot change column 'activity_id': used in a foreign key constraint 'FK_4F60C6B181C06096'
102151 DEBUG + sudo yunohost backup list
102151 WARNING 
102151 DEBUG + grep -q kimai2-pre-upgrade1
102151 WARNING 
102151 WARNING doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]
102152 WARNING 
102152 WARNING !!
102152 WARNING   kimai2's script has encountered an error. Its execution was cancelled.
102152 WARNING !!
102152 WARNING Upgrade failed.
kevinpapst commented 5 years ago

And one more try ... there were two more foreign keys on the timesheet table

kevinpapst commented 5 years ago

And btw: I use mysql Ver 15.1 Distrib 10.3.10-MariaDB, for osx10.14 (x86_64) using readline 5.1. So 10.1.26 compared to 10.3.10. Its a YunoHost global installation, which can't be upgraded, right?

anmol26s commented 5 years ago

So 10.1.26 compared to 10.3.10. Its a YunoHost global installation, which can't be upgraded, right?

Yes the Yunohost has Debian 9 and ships with mysql version provided with it. Normal users don't care about it because they don't have to see the core and just see there apps and goodies. For stability of all the apps this gets updated with Debain version.

I am going to try with the latest fixes.

anmol26s commented 5 years ago

Finally it worked :tada: Will you release a minor version or push these fixed in the 0.6?

kevinpapst commented 5 years ago

I will release 0.6.1, will let you know later.

kevinpapst commented 5 years ago

And "HOORAY" ;-) thanks for your support!

kevinpapst commented 5 years ago

Created new tag 0.6.1: https://github.com/kevinpapst/kimai2/releases/tag/0.6.1

anmol26s commented 5 years ago

Updated to version 0.6.1.

kevinpapst commented 5 years ago

Thanks for the quick update!