jekader opened a new issue, #8411:
URL: https://github.com/apache/incubator-devlake/issues/8411

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   I tried deploying a fresh instance of DevLake v1.0.1 via Helm and got stuck 
with a failing migration:
   
   ```
   [Execute] pending scripts: 65, executed scripts: 270, total: 335"
   [migrator] applying migration script add updated_date field in 
_tool_azuredevops_gitrepositories:20240223170000"
   "\x1b[31;1m/app/impls/dalgorm/dalgorm.go:146 \x1b[35;1mError 1060 (42S21): 
Duplicate column name 'updated_date'\n\x1b[0m\x1b[33m[16.018ms] 
\x1b[34;1m[rows:0]\x1b[0m ALTER TABLE _tool_azuredevops_gitrepositories add 
COLUMN updated_date datetime(3) DEFAULT NULL"
   failed to execute migration\n\tcaused by: Error 1060 (42S21): Duplicate 
column name 'updated_date' (400)\n\tWraps: (2) Error 1060 (42S21): Duplicate 
column name 'updated_date'\n\tError types: (1) *hintdetail.withDetail (2) 
*mysql.MySQLError"
   HTTP 400 error\n\tcaused by: error executing migration (400)\n\tWraps: (2) 
Error 1060 (42S21): Duplicate column name 'updated_date' (400)\n\tWraps: (3) 
Error 1060 (42S21): Duplicate column name 'updated_date'\n\tError types: (1) 
*hintdetail.withDetail (2) *hintdetail.withDetail (3) *mysql.MySQLError"
   ```
   
   ### What do you expect to happen
   
   All migrations should succeed
   
   ### How to reproduce
   
   Simple helm deploy with all defaults
   
   ### Anything else
   
   This seems to be caused by the migration not checking if the column exists 
in the first place:
   
https://github.com/apache/incubator-devlake/blob/main/backend/python/plugins/azuredevops/azuredevops/migrations.py#L197-L201
   
   A workaround is removing the column manually, then re-triggering migrations
   `ALTER TABLE _tool_azuredevops_gitrepositories drop COLUMN updated_date;`
   
   A proper solution is checking if the column exists before attempting to 
alter the table. This is done for some migrations but a couple are inconsistent 
and should be fixed.
   
   ### Version
   
   v1.0.1
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@devlake.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to