Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions scripts/cli
Original file line number Diff line number Diff line change
Expand Up @@ -293,23 +293,33 @@ function build() {
}

function create_migration() {
MIG_NAME="$1"
MIG_NAME="$(printf '%s\n' "$1" | tr -s ' ' | xargs)"
if [[ -z "$MIG_NAME" ]] || [[ ! "$MIG_NAME" =~ ^[A-Za-z0-9_-]+$ ]]; then
error "Migration name must be non-empty and contain only letters, numbers, underscores, or hyphens"
exit 1
Comment on lines +296 to +299
fi

MIG_VERSION=$(date +%s)
UP_MIG_FILE="${CLI_HOME}/../backend/src/database/migrations/V${MIG_VERSION}__${MIG_NAME}.sql"
DOWN_MIG_FILE="${CLI_HOME}/../backend/src/database/migrations/U${MIG_VERSION}__${MIG_NAME}.sql"
touch $UP_MIG_FILE
touch $DOWN_MIG_FILE
yell "Created ${MIG_FILE}"
touch "$UP_MIG_FILE"
touch "$DOWN_MIG_FILE"
yell "Created $UP_MIG_FILE and $DOWN_MIG_FILE"
}

function create_product_migration() {
MIG_NAME="$1"
MIG_NAME="$(printf '%s\n' "$1" | tr -s ' ' | xargs)"
if [[ -z "$MIG_NAME" ]] || [[ ! "$MIG_NAME" =~ ^[A-Za-z0-9_-]+$ ]]; then
error "Migration name must be non-empty and contain only letters, numbers, underscores, or hyphens"
exit 1
Comment on lines +311 to +314
fi

MIG_VERSION=$(date +%s)
UP_MIG_FILE="${CLI_HOME}/../backend/src/product/migrations/V${MIG_VERSION}__${MIG_NAME}.sql"
DOWN_MIG_FILE="${CLI_HOME}/../backend/src/product/migrations/U${MIG_VERSION}__${MIG_NAME}.sql"
touch $UP_MIG_FILE
touch $DOWN_MIG_FILE
yell "Created ${MIG_FILE}"
touch "$UP_MIG_FILE"
touch "$DOWN_MIG_FILE"
yell "Created $UP_MIG_FILE and $DOWN_MIG_FILE"
}

function build_and_publish() {
Expand Down
Loading