piccolo icon indicating copy to clipboard operation
piccolo copied to clipboard

Rename the `forwards` function in the migration file to `migrate`

Open dantownsend opened this issue 3 years ago • 4 comments

The Piccolo migrations look something like this:

from piccolo.apps.migrations.auto.migration_manager import MigrationManager


ID = "2022-02-26T17:38:44:758593"
VERSION = "0.69.2" # The version of Piccolo used to create it
DESCRIPTION = "Optional description"


async def forwards():
    manager = MigrationManager(
        migration_id=ID,
        app_name="my_app",
        description=DESCRIPTION
    )

    def run():
        # Replace this with something useful:
        print(f"running {ID}")

    manager.add_raw(run)
    return manager

As pointed out in this comment, it's a bit confusing to have the function called forwards.

What it actually does is return a MigrationManager instance. Whether we're running the migration forwards or backwards, we call that function to get the MigrationManager instance.

A more accurate name for the function would be something like migrate. Any thoughts? Is there another better name? Or just leave as it is?

dantownsend avatar Oct 03 '22 12:10 dantownsend

migrations migrate? May be just run?

northpowered avatar Oct 05 '22 13:10 northpowered

Been using run as a universal convention in my own "before piccolo" system, for migrations and background tasks. migrations run is short and obvious.

gnat avatar Oct 09 '22 06:10 gnat

piccolo migrations run

devsarvesh92 avatar Oct 20 '22 07:10 devsarvesh92

transit or shift? mutate xD

hoosnick avatar Jul 12 '23 22:07 hoosnick