-
Notifications
You must be signed in to change notification settings - Fork 5
Cli
Our cli has two main funcionalities:
- Generate and destroy code
- Manage migrations and database
The code generation funcionality create two routes types
- CRUD
- USECASE
The crud command generate:
- routes and handlers on cmd/http folder
- domain with ID field on internal/aplication/domain
- service for each route with a type for request, response and a service file for your business rules
- repository based on your domain for mysql database comunication
Command example for users crud:
go run cmd/cli/main.go create-domain users
The usecase command generate:
- single route and handler without any dependecy injection
- service with a type for request, response and a service file for your business rules
Command example for user login usecase:
go run cmd/cli/main.go create-domain user_login --type=usecase
The migrator is based on atlas: https://atlasgo.io/getting-started If you want can use atlas for manage your database without use the cli
The migrator has 3 commands:
- migrate
- inspect
- generate
this command read the tools/migrator/schema/schema.my.hcl file and migrate for the real database connceted with env configuration
Command example for migration:
/app # go run cmd/cli/main.go migrate
Applied 2 changes:
CREATE TABLE `dummies` (
`id` char(26) NOT NULL,
`name` char(255) NOT NULL,
PRIMARY KEY (`id`)
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci
CREATE TABLE `report_routes` (
`id` char(26) NOT NULL,
PRIMARY KEY (`id`)
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci
this command read the connceted database and print on console a hcl with this configuration
example:
go run cmd/cli/main.go inspect
Similar to inspect but generate a hcl file on tools/migrator/generated, if you want to use the generated hcl on zord migrations just replace tools/migrator/schema/schema.my.hcl with this file content
example:
go run cmd/cli/main.go generate