variable "migration_files" {
description = "Ordered list of SQL migration files"
type = list(string)
default = [
"001_create_users.sql",
"002_add_email_index.sql",
"003_create_sessions.sql",
"004_add_audit_log.sql",
]
}
variable "batch_size" {
description = "Number of migrations to run in this batch"
type = number
default = 2
}
computed "batch" {
description = "Current batch of migration files"
expression = slice(var.migration_files, 0, var.batch_size)
}
task "migrate-batch" {
description = "Apply the current migration batch"
commands = [
"for f in ${join(" ", computed.batch)}; do psql -f migrations/$f; done",
]
}