@@ -17,7 +17,7 @@ migration filename is a timestamp, which also serves as the migration ID.
1717.. code-block :: bash
1818
1919 piccolo_migrations/
20- 2018-09-04T19:44:09 .py
20+ 2021-08-06T16-22-51-415781 .py
2121
2222 The contents of an empty migration file looks like this:
2323
@@ -26,11 +26,13 @@ The contents of an empty migration file looks like this:
2626 from piccolo.apps.migrations.auto import MigrationManager
2727
2828
29- ID = ' 2018-09-04T19:44:09'
29+ ID = ' 2021-08-06T16:22:51:415781'
30+ VERSION = " 0.29.0" # The version of Piccolo used to create it
31+ DESCRIPTION = " Optional description"
3032
3133
3234 async def forwards ():
33- manager = MigrationManager(migration_id = ID )
35+ manager = MigrationManager(migration_id = ID , app_name = " my_app " , description = DESCRIPTION )
3436
3537 def run ():
3638 print (f " running { ID } " )
@@ -52,7 +54,9 @@ This is a **bad example**:
5254
5355 from ..tables import Band
5456
55- ID = ' 2018-09-04T19:44:09'
57+ ID = ' 2021-08-06T16:22:51:415781'
58+ VERSION = " 0.29.0" # The version of Piccolo used to create it
59+ DESCRIPTION = " Optional description"
5660
5761
5862 async def forwards ():
@@ -69,6 +73,8 @@ someone runs your migrations in the future, they will get different results.
6973Make your migrations completely independent of other code, so they're
7074self contained and repeatable.
7175
76+ -------------------------------------------------------------------------------
77+
7278Auto migrations
7379---------------
7480
@@ -102,3 +108,19 @@ Auto migrations can accommodate most schema changes. There may be some rare edge
102108cases where a single migration is trying to do too much in one go, and fails.
103109To avoid these situations, create auto migrations frequently, and keep them
104110fairly small.
111+
112+ -------------------------------------------------------------------------------
113+
114+ Migration descriptions
115+ ----------------------
116+
117+ To make the migrations more memorable, you can give them a description. Inside
118+ the migration file, you can set a ``DESCRIPTION `` global variable manually, or
119+ can specify it when creating the migration:
120+
121+ .. code-block :: bash
122+
123+ piccolo migrations new my_app --auto --desc=" Adding name column"
124+
125+ The Piccolo CLI will then use this description where appropriate when dealing
126+ with migrations.
0 commit comments