cli icon indicating copy to clipboard operation
cli copied to clipboard

Expand migration generator to support special behavior for create_ prefix

Open cllns opened this issue 1 year ago • 0 comments

Right now (er, once #201 is merged), regardless of the name of the migration, it just gets created as an empty migration:

ROM::SQL.migration do
  # Add your migration here.
  #
  # See https://sequel.jeremyevans.net/rdoc/files/doc/migration_rdoc.html for details.
end

We should be a little bit smarter than that, and if someone does hanami generate migration create_books, it should create something like this:

ROM::SQL.migration do
  change do
    create_table :books do
      primary_key :id
    end
  end
  # Reference https://sequel.jeremyevans.net/rdoc/files/doc/migration_rdoc.html
end

And, going further we could also support something lke: hanami generate migration create_books name description quantity:int:

ROM::SQL.migration do
  change do
    create_table :books do
      primary_key :id
      String :name 
      String :description
      Integer :quantity
    end
  end
  # Reference https://sequel.jeremyevans.net/rdoc/files/doc/migration_rdoc.html
end

And we could later expand to things like name:not_null, but let's not be too ambitious with this first enhancement

cllns avatar Jul 14 '24 21:07 cllns