kanboard: Unable to run SQL migrations v1.2.16 to v1.2.17 (sqlite)
Actual behaviour
I’m running kanboard in a docker-container. With the newest/latest container my installation doesn’t migrate the sqlite-database automatically or manual and shows the following error-message only:
Internal Error: Unable to run SQL migrations: Running migration \Schema\version_125, SQLSTATE[HY000]: General error: 1 table tasks_new has 32 columns but 34 values were supplied (You may have to fix it manually)
A manual start of the migration via the docker-console with bash-5.0# ./cli db:migrate doesn’t work as well and shows the same message.
I couldn’t find “tasks_new” while opening the sqlite-db manually with a DB-Browser.
Expected behaviour
I expect, that the migration finishes and I can use kanboard as usual.
Steps to reproduce
Change the docker-compose.yml image from image kanboard/kanboard:v1.2.16 to image: kanboard/kanboard:latest and run “docker-compose pull” and “docker-compose up”.
Logs
None. Only the usual docker-update log without errors.
Configuration (before the upgrade, because the new one doesn’t work)
- Kanboard version: v1.2.16
- Database type and version: sqlite, 3.32.1
- PHP version: 7.3.23
- OS: Linux 5.4.35
- Browser: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (4 by maintainers)
Well, you first have to know which tables were altered when you installed your plugins, and how (which columns were added and what type of data do the columns contain). There are two ways of doing that.
First solution, you compare the
app/Schema/Sqlite.phpfile of Kanboard (here) with the current schema of your database. You can open your database with DBeaver Community or with DB Browser for SQLite. In my case for instance, when I open my SQLite database and I go to thetaskstable, I can see that there are two columns that do no appear in theapp/Schema/Sqlite.phpfile of Kanboard:owner_gpandowner_ms. I’m lucky: only thetaskstable was altered by my plugins.Second solution, you go to the Github page of all of your plugins, you locate the file which contain the SQLite database modifications, and identify the requests that have the
ALTERkeyword in it. Using the Group_Assign module example, here is the file, and you can see on line 33 that it does a request to alter thetaskstable to add aowner_gpcolumn. In my case, theowner_msI mentioned earlier must have come from another plugin. That’s why you should do this for each of your plugins.Either way, once you know which tables were edited, the name of the columns that were added and their type, you should edit the
app/Schema/Sqlite.phpof the new release of Kanboard to add these two columns, just like I explained on my message from January 20th. Then replace all the files in the Kanboard folder on your server with the files from the new release, including theapp/Schema/Sqlite.phpfile that you edited, and run the upgrade. Don’t forget to backup your DB file though.Who performed your Kanboard install, and could they not help you with that?
I can confirm that it works great and allowed us to upgrade our 1.2.16 instance to version 1.2.18 by manually editing the
app/Schema/Sqlite.phpas described. To be even more explicit, we edited the following lines (L49-L50) of the file, from this:To this:
The upgrade succeeded, no error message, no data or functionalities lost. Thank you for your help!
Maybe this process could be described in a documentation, or at least in the Release message on Github? Like “If you use plugins that edit tables (e.g. Group_Assign), you have to manually apply the database changes to the
Sqlite.phpfile”?Ok, I’m assuming the issue is solved now according to your last update.
If you still have a problem, reach out the author of this plugin: https://github.com/creecros/Group_assign/issues
The plugin “Group_Assign” adds 2 extra columns
owner_msandowner_gp: https://github.com/creecros/Group_assign/blob/master/Schema/Sqlite.phpIf you want to keep this plugin, you will have to change the migration manually on your installation to add these 2 columns: https://github.com/kanboard/kanboard/blob/master/app/Schema/Sqlite.php#L13-L56
You can also choose to skip the migration 125. The only change here is to add a foreign key for
swimlane_id. If that your choice, then update the fieldversionin tableschema_versionto the value125.Note that v1.2.18 has been released to fix a different Sqlite issue. See https://github.com/kanboard/kanboard/releases/tag/v1.2.18
@sebw Well, you should be careful about “getting rid” of columns, they may contain useful data created by the plugins that you may lose if you just delete them. Or maybe I misunderstood what you said.
@gerroon If you go with sebw’s solution, you should make a backup of your database file so that you can revert to it if anything goes wrong. One solution can be to go to your Kanboard’s plugin page, and for each plugin you have installed, go to their respective Github repository, and ask the developer if their plugin adds columns to the database. That way, you would be able to correct the
app/Schema/Sqlite.phpappropriately. But I understand that it’s a delicate process if you’re not tech-savvy.Ideally, this particularity should be taken care of by Kanboard’s upgrade process, or at least documented…
@gerroon I used DBeaver Community to fix my sqlite DB as I only know MySQL. I was able to get rid of the conflicting columns with a few clicks. Feel free to share your DB with me, I can try to have a look at what is wrong in it.
Edit: I added the missing columns in a wrong order (needs to be owner_gp first then owner_ms. Migration worked properly now.
I’ve the same problem updating from 1.2.16 to 1.2.18. I modified Sqlite.php to add the missing columns and migration worked then. But tasks are loosing all already assigned groups.