Skip to content
Snippets Groups Projects
add.go 1.08 KiB
package commands

import (
	"fmt"
	"datasmith/utils"
)

func Add(tablename string) {
	utils.PromptIfEmpty(&tablename, "Enter the name of the table: ")
	addTable(tablename)
}

func addTable(name string) {
	slug := utils.Slugify(name)

	// TODO: Do Stuff:
	/*
		- Parameter --model (yamL) as file or string
    - if nothing, ask for fields (name, type, primary key, foreign key, unique, not null, auto increment, default value)
		- Check if the table already exists in the datasmith.yaml file
		- Add a new table and columns to the datasmith.yaml file
		- Create a new table file in the sql directory (by database type) sql/slug.sql
		- Generate Test Data for the new table if wanted
		- Add Table to import-sql.sh
		- Add Description to the DBML file
		- Add Description and mermaid and DBML to the README.md file
		- Add Test to gitlab-ci.yml
		- Add to CHANGELOG.md
		- Bump version in datasmith.yaml

	*/

	fmt.Printf("Added new table '%s' to the project\n", slug)
}

// Help returns the help information for the add command
func AddHelp() string {
	return "add [tablename]: Add a table to the project."
}