Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change name of file created by migration

Tags:

python

alembic

Its possible to change a name o file create by migration? like this `18b6422c9d3f i prefer organize usign date-time like 201705121927

its possible change configs of alembic to do that?

like image 347
Guilherme Lima Avatar asked May 12 '17 22:05

Guilherme Lima


People also ask

Can we rename migration file?

Yes, you can name them however you want, but they will run in alphabetical order (which is why laravel timestamps them). Also you can change a migrations name after the fact (you've already run the migration).

Can I rename migration file rails?

You can change the migration file name, but you have to perform a few steps: rake db:rollback to the point that queries table is rolled back. Now change the name of migration file, also the contents. Change the name of any Model that may use the table.

How do you name a migration file?

Migration File NamesEach Migration is run in numeric order forward or backwards depending on the method taken. Each migration is numbered using the timestamp when the migration was created, in YYYY-MM-DD-HHIISS format (e.g., 2012-10-31-100537). This helps prevent numbering conflicts when working in a team environment.


1 Answers

You need to edit alembic.ini.

Parameter that you looking for is file_template.

From docs:

file_template - this is the naming scheme used to generate new migration files. The value present is the default, so is commented out. Tokens available include:

  • %%(rev)s - revision id
  • %%(slug)s - a truncated string derived from the revision message
  • %%(year)d, %%(month).2d, %%(day).2d, %%(hour).2d, %%(minute).2d, %%(second).2d - components of the create date, by default datetime.datetime.now() unless the timezone configuration option is also used.

By default it is set to %%(rev)s_%%(slug)s.

like image 124
vishes_shell Avatar answered Sep 30 '22 13:09

vishes_shell