#!/bin/bash

# omarchy:summary=Create a new Omarchy migration in the current source tree.

set -euo pipefail

cd "${OMARCHY_PATH:-$(pwd)}"
mkdir -p migrations
migration_file="migrations/$(git log -1 --format=%cd --date=unix).sh"
touch "$migration_file"

if [[ ${1:-} != "--no-edit" ]]; then
  nvim "$migration_file"
fi

printf '%s\n' "$PWD/$migration_file"
