Add CLI support for model generation

This commit is contained in:
M.RIZKI I 2025-08-21 05:40:06 +07:00
parent 1295b207bb
commit 2698f0845e
4 changed files with 0 additions and 57 deletions

View File

@ -1,8 +0,0 @@
package entity
type User struct {
ID uint
Name string `gorm:"column:name"`
Email string `gorm:"column:email"`
}

View File

@ -1,16 +0,0 @@
package migrations
import (
"gorm.io/gorm/configs"
"gorm.io/gorm/internal/models"
)
// Up migrates table User
func UpUser() {
configs.DB.AutoMigrate(&models.User{})
}
// Down rolls back table User
func DownUser() {
configs.DB.Migrator().DropTable(&models.User{})
}

View File

@ -1,17 +0,0 @@
package migrations
import "fmt"
func MigrateAll() {
fmt.Println("Running migrations...")
UpUser()
// Add other migrations here
fmt.Println("Migrations completed!")
}
func RollbackAll() {
fmt.Println("Rolling back migrations...")
DownUser()
// Add other rollbacks here
fmt.Println("Rollback completed!")
}

View File

@ -1,16 +0,0 @@
package models
import (
"time"
"gorm.io/gorm"
)
type User struct {
ID uint `gorm:"primaryKey"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
Name string `gorm:"column:name"`
Email string `gorm:"column:email"`
}