AlfHou / hammond

Self hosted vehicle and expense management system. Like Clarkson, but better
GNU Affero General Public License v3.0
143 stars 19 forks source link

Conflict between AutoMigration and Migration #114

Open Goloso98 opened 3 months ago

Goloso98 commented 3 months ago

Describe the bug Using a fresh database, main runs starting database init which first will run AutoMigrate on all models, including Vehicle with VIN field already in it. After that proceeds to "normal" migration which will try to add VIN again and will error because AutoMigrate already did and because it errors wont sign that migration as done.

hammond  | 2024/08/24 17:27:12 /api/db/migrations.go:39 record not found
hammond  | [0.081ms] [rows:0] SELECT * FROM `migrations` WHERE name="2022_03_08_13_16_AddVIN" ORDER BY `migrations`.`id` LIMIT 1
hammond  | ALTER TABLE vehicles ADD COLUMN vin text
hammond  | 
hammond  | 2024/08/24 17:27:12 /api/db/migrations.go:42 duplicate column name: vin
hammond  | [0.015ms] [rows:0] ALTER TABLE vehicles ADD COLUMN vin text

To Reproduce Steps to reproduce the behavior:

  1. New installation
  2. Fresh database
  3. Error on migrate

Expected behavior On a fresh install it add all migrations as done.