feat(dev): allow passing struct name to dev:make-migration mage command (#931)
This commit is contained in:
parent
3e7c0099c8
commit
8d5c665781
|
|
@ -26,8 +26,8 @@ The project consists of:
|
||||||
- **Clean**: `mage build:clean` - Cleans build artifacts
|
- **Clean**: `mage build:clean` - Cleans build artifacts
|
||||||
- **Format**: `mage fmt` - Format Go code before committing
|
- **Format**: `mage fmt` - Format Go code before committing
|
||||||
|
|
||||||
Development helpers under the `dev` namespace:
|
-Development helpers under the `dev` namespace:
|
||||||
- **Migration**: `mage dev:make-migration` - Creates new database migration
|
- **Migration**: `mage dev:make-migration <StructName>` - Creates new database migration. If you omit `<StructName>`, the command will prompt for it.
|
||||||
- **Event**: `mage dev:make-event` - Create an event type
|
- **Event**: `mage dev:make-event` - Create an event type
|
||||||
- **Listener**: `mage dev:make-listener` - Create an event listener
|
- **Listener**: `mage dev:make-listener` - Create an event listener
|
||||||
- **Notification**: `mage dev:make-notification` - Create a notification skeleton
|
- **Notification**: `mage dev:make-notification` - Create a notification skeleton
|
||||||
|
|
@ -114,7 +114,7 @@ Modern Vue 3 composition API application with TypeScript:
|
||||||
|
|
||||||
**Backend Changes:**
|
**Backend Changes:**
|
||||||
1. Create/modify models in `pkg/models/` with proper CRUD and Rights interfaces as required
|
1. Create/modify models in `pkg/models/` with proper CRUD and Rights interfaces as required
|
||||||
2. Add database migration if needed: `mage dev:make-migration`
|
2. Add database migration if needed: `mage dev:make-migration <StructName>`
|
||||||
3. Create/update services in `pkg/services/` for complex business logic
|
3. Create/update services in `pkg/services/` for complex business logic
|
||||||
4. Add API routes in `pkg/routes/api/v1/` following existing patterns
|
4. Add API routes in `pkg/routes/api/v1/` following existing patterns
|
||||||
5. Update Swagger annotations
|
5. Update Swagger annotations
|
||||||
|
|
@ -127,7 +127,7 @@ Modern Vue 3 composition API application with TypeScript:
|
||||||
5. Update Pinia stores if global state changes are needed
|
5. Update Pinia stores if global state changes are needed
|
||||||
|
|
||||||
### Database Changes
|
### Database Changes
|
||||||
1. Run `mage dev:make-migration` and enter the struct name
|
1. Run `mage dev:make-migration <StructName>`
|
||||||
2. Edit the generated migration file in `pkg/migration/`
|
2. Edit the generated migration file in `pkg/migration/`
|
||||||
3. Update corresponding model in `pkg/models/`
|
3. Update corresponding model in `pkg/models/`
|
||||||
4. Update TypeScript interfaces in frontend `src/modelTypes/`
|
4. Update TypeScript interfaces in frontend `src/modelTypes/`
|
||||||
|
|
|
||||||
17
magefile.go
17
magefile.go
|
|
@ -998,13 +998,16 @@ func (Release) Packages() error {
|
||||||
|
|
||||||
type Dev mg.Namespace
|
type Dev mg.Namespace
|
||||||
|
|
||||||
// Creates a new bare db migration skeleton in pkg/migration with the current date
|
// MakeMigration creates a new bare db migration skeleton in pkg/migration.
|
||||||
func (Dev) MakeMigration() error {
|
// If you pass the struct name as an argument, the prompt will be skipped.
|
||||||
|
func (Dev) MakeMigration(name string) error {
|
||||||
reader := bufio.NewReader(os.Stdin)
|
str := strings.TrimSpace(name)
|
||||||
fmt.Print("Enter the name of the struct: ")
|
if str == "" {
|
||||||
str, _ := reader.ReadString('\n')
|
reader := bufio.NewReader(os.Stdin)
|
||||||
str = strings.Trim(str, "\n")
|
fmt.Print("Enter the name of the struct: ")
|
||||||
|
s, _ := reader.ReadString('\n')
|
||||||
|
str = strings.TrimSpace(s)
|
||||||
|
}
|
||||||
|
|
||||||
date := time.Now().Format("20060102150405")
|
date := time.Now().Format("20060102150405")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue