Skip to content

Running Commands

Iko supports three ways to run commands โ€” depending on whether you're working interactively or scripting migrations.


1. ๐Ÿ”น Command-Line Mode

Run Iko commands directly in your terminal:

iko create_schema api
iko create_table users
iko deploy

This is the most common mode for quick, one-off tasks or small changes.

You can use both:

  • Ikoโ€™s DSL commands like create_table, create_function, etc.
  • Native Sqitch commands like deploy, revert, status

2. ๐Ÿ”ธ Shell Mode

Start an interactive session with:

iko shell

Or just:

iko

Youโ€™ll get an iko> prompt where you can run commands without typing iko every time:

iko> create_schema auth
iko> create_table sessions
iko> deploy

Useful when youโ€™re exploring or applying a sequence of changes interactively.

3. ๐Ÿ”ป Script Mode

Write reusable Bash scripts inside your scripts/ directory:

# scripts/auth.sh

create_schema auth

create_table_as auth.user <<'SQL'
create table auth.user (
  username text primary key,
  password text not null,
  role name not null
);
SQL

Run the script with:

iko bash auth.sh

Script mode is ideal for:

  • Defining and reusing sets of related migrations
  • Keeping complex changes readable
  • Avoiding repetitive commands

When to Use Each

Mode Best For
CLI Simple changes, quick edits
Shell Interactive sessions, experimenting
Scripts Reusable, readable, and complex changes

โœ… All three modes support the same DSL commands โ€” choose the style that fits your workflow.

๐Ÿงญ What's Next?

๐Ÿ‘‰ Continue to Scripting Iko Migrations