Skip to Content

Goofer ORM CLI

The Goofer ORM Command Line Interface (CLI) provides a set of tools to help you manage your database schema, generate code, and perform other common tasks. It’s designed to make working with Goofer ORM easier and more efficient.

Overview

The CLI offers the following capabilities:

  • Database schema management (migrations)
  • Code generation
  • Entity scaffolding
  • Database seeding
  • Configuration management

Installation

To use the Goofer ORM CLI, you need to install it first. See the Installation page for detailed instructions.

Basic Usage

The basic syntax for the CLI is:

goofer [command] [subcommand] [options]

For example:

# Generate a migration goofer migrate create initial_schema # Apply pending migrations goofer migrate up # Generate an entity goofer generate entity User

Getting Help

You can get help for any command by using the --help flag:

# Get general help goofer --help # Get help for a specific command goofer migrate --help # Get help for a specific subcommand goofer migrate create --help

Available Commands

The CLI provides several commands for different tasks:

Migration Commands

  • migrate create: Create a new migration
  • migrate up: Apply pending migrations
  • migrate down: Revert the last migration
  • migrate status: Show migration status

See Migration Commands for more details.

Generate Commands

  • generate entity: Generate a new entity
  • generate repository: Generate a repository for an entity
  • generate migration: Generate a migration from entity definitions

See Generate Commands for more details.

Configuration Commands

  • config init: Initialize a new configuration file
  • config show: Show the current configuration
  • config set: Set a configuration value

See Configuration for more details.

Configuration

The CLI can be configured using a goofer.yaml file in your project directory. This file allows you to customize the behavior of the CLI.

See Configuration for more details on how to configure the CLI.

Examples

Here are some common examples of using the CLI:

Creating and Applying Migrations

# Create a new migration goofer migrate create create_users_table # Apply pending migrations goofer migrate up # Revert the last migration goofer migrate down # Check migration status goofer migrate status

Generating Entities

# Generate a User entity goofer generate entity User --fields "id:uint:primaryKey,autoIncrement name:string:notnull email:string:unique,notnull" # Generate a Post entity with a relation to User goofer generate entity Post --fields "id:uint:primaryKey,autoIncrement title:string:notnull content:string:notnull user_id:uint:notnull" --relations "user:belongsTo:User:user_id"

Initializing a New Project

# Initialize a new project goofer init my-project # Initialize with a specific database goofer init my-project --db postgres

Next Steps

Last updated on