Skip to content

class Athena::ORM::Migrations::Generator
inherits Reference #

Writes the file of a new migration.

configuration = AORM::Migrations::Configuration.new "App::Migrations", "src/migrations"
generator = AORM::Migrations::Generator.new configuration

generator.generate_migration "App::Migrations::Version20261014120000" # => "src/migrations/version20261014120000.cr"

Constructors#

Methods#

#generate_migration(fqcn : String, up : String | Nil = nil, down : String | Nil = nil) : String#

Writes the migration named fqcn to the configured directory, with up and down as the bodies of its #up and #down, and returns the path of the file. The directory is created if it doesn't exist.

Raises an ArgumentError if fqcn isn't in the configured namespace.

View source