Files
terminalShop-old/pkg/database/migrate.go
marcusDenslow c78f5eb12b
Some checks failed
Deploy / deploy (push) Has been cancelled
refactor: remove putting ssh key in memory at all, just use it for auth
changed the ssh key to just do fingerprinting and not store it at all, and not be able to edit it either in the account page
2026-04-25 10:50:19 +02:00

33 lines
856 B
Go

package database
import (
"fmt"
"log"
"gorm.io/gorm"
"terminalShop/pkg/models"
)
// Migrate runs database migrations
func Migrate(db *gorm.DB) error {
log.Println("Running database migrations...")
// AutoMigrate will create tables, missing columns, and indexes
// It will NOT delete unused columns or change column types
if err := db.AutoMigrate(
&models.Cart{}, // Server-side shipping cart
&models.CartItem{}, // Cart line items
&models.Coffee{},
&models.User{}, // SSH key-based authentication
&models.Card{}, // Saved payment methods
&models.Order{}, // Completed purchases
&models.OrderItem{}, // Line items within orders
&models.Address{}, // Saved addresses
); err != nil {
return fmt.Errorf("migration failed: %w", err)
}
log.Println("Database migrations completed successfully")
return nil
}