piccolo-orm / piccolo

A fast, user friendly ORM and query builder which supports asyncio.
https://piccolo-orm.com/
MIT License
1.45k stars 91 forks source link

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

Open dantownsend opened 2 years ago

dantownsend commented 2 years ago

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?

northpowered commented 2 years ago

migrations migrate? May be just run?

gnat commented 2 years ago

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

devsarvesh92 commented 2 years ago

piccolo migrations run

hoosnick commented 1 year ago

transit or shift? mutate xD