Padrino provides generator for quickly generating new migrations to change or manipulate the database schema. These migrations generated will be tailored towards the ORM chosen when generating the application.

Options Default Aliases Description
root . -r specify the root destination path
destroy false -d removes all generated files

Very important to note that migration generators are intended primarily to work within applications created through the Padrino application generator and that follow Padrino conventions. Using migration generators within an existing application not generated by Padrino will likely not work as expected.

Using the migration generator is as simple as:

$ padrino g migration AddFieldsToUsers
$ padrino g migration RemoveFieldsFromUsers

You can also specify desired columns to be added to the migration file:

$ padrino g migration AddFieldsToUsers last_login:datetime crypted_password:string
$ padrino g migration RemoveFieldsFromUsers password:string ip_address:string

The migration generator will then construct the migration file according to your ORM component chosen within db/migrate/xxx_add_fields_to_users.rb including the columns specified in the command.

You can destroy migrations that you created via the destroy option and setting it to true. Default is false.

$ padrino g migration AddFieldsToUsers -d

last updated: 2022-02-22

comments powered by Disqus