TL,DR:
piccolo migrations forwards foo.bar migration1
ok
piccolo migrations forwards foo.bar migration2
ok
piccolo migrations backwards foo.bar
ok
piccolo migrations forwards foo.bar migration1
migration1 is unrecognised
should be 🏁 No migrations need to be run
So I have quite a few apps and migrations that have become dependent on each other, and to make them work correctly I use this script:
#!/bin/bash
set -e
piccolo migrations forwards session_auth
piccolo migrations forwards user
piccolo migrations forwards apps.employee
piccolo migrations forwards apps.car
piccolo migrations forwards apps.price 2024-05-21T06:27:34:451504 # <-- breaks here
piccolo migrations forwards apps.rent
piccolo migrations forwards apps.price # again because of subsequent dependent migrations
piccolo migrations forwards all # everything else
python main.py
the specified migration in app "apps.price" is needed by subsequent migrations in dependent apps (apps.rent).
Everything was working fine until I decided to add new migration to the apps.price.
The structure of migrations directory is:
appsprice_2024_05_21t06_27_34_451504.py # created back when piccolo was 1.5.0
appsprice_2024_05_21t06_31_03_491490.py # created back when piccolo was 1.5.0
appsprice_2024_05_21t06_54_59_701243.py # created back when piccolo was 1.5.0
appsprice_2026_02_24t22_16_29_046939.py # fresh piccolo version
appsprice_2026_02_24t22_20_02_371610.py # fresh piccolo version
What is happening in
|
message = f"{self.migration_id} is unrecognised" |
print(ids)
['2024-05-21T06:27:34:451504', '2024-05-21T06:31:03:491490', '2024-05-21T06:54:59:701243', '2026-02-24T22:16:29:046939', '2026-02-24T22:20:02:371610']
print(already_ran)
['2024-05-21T06:27:34:451504', '2024-05-21T06:31:03:491490', '2024-05-21T06:54:59:701243']
print(havent_run)
['2026-02-24T22:16:29:046939', '2026-02-24T22:20:02:371610']
And of course the mentioned 2024-05-21T06:27:34:451504 is absent in havent_run because it is already ran and piccolo shows 2024-05-21T06:27:34:451504 is unrecognised.
What I propose:
change this line to
if len(havent_run) == 0 or self.migration_id in already_ran: # or reuse set(already_ran)
so then piccolo successfully prints 🏁 No migrations need to be run
TL,DR:
should be
🏁 No migrations need to be runSo I have quite a few apps and migrations that have become dependent on each other, and to make them work correctly I use this script:
the specified migration in app "apps.price" is needed by subsequent migrations in dependent apps (apps.rent).
Everything was working fine until I decided to add new migration to the apps.price.
The structure of migrations directory is:
What is happening in
piccolo/piccolo/apps/migrations/commands/forwards.py
Line 63 in c9d27e6
And of course the mentioned
2024-05-21T06:27:34:451504is absent inhavent_runbecause it is already ran and piccolo shows2024-05-21T06:27:34:451504 is unrecognised.What I propose:
piccolo/piccolo/apps/migrations/commands/forwards.py
Line 45 in c9d27e6
change this line to
so then piccolo successfully prints
🏁 No migrations need to be run