-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrations are missing for 5.0 #124
Comments
Latest release is missing a migration file which is causing our makemigrations check to fail. jazzband/django-robots#124
Latest release is missing a migration file which is causing our makemigrations check to fail. jazzband/django-robots#124
I also have this issue, seems that a |
Thanks for the report. This needs more basic information. I am guessing this is #112 related. I didn't sit on that code review nor merge it but I'll take responsibility as the one who cut the 5.0 release. @VdeJong @michaeljcollinsuk, anyone else experiencing this:
I have a preliminary PR started at #129 but I want to be deliberate about understanding the what and why before we publish a fix. Anything else on your environments and isolating this would be helpful. It's appreciated! |
Same issue here after upgrading to django-robots==5.0
|
When trying to run makemigrations it try to create a migration file for robots:
|
Having same issue, trying to make migration with those same 2 changes
|
@fabien-michel @amourousias Thank you for the additional feedback |
@fabien-michel @amourousias Can you provide the content of the file? e.g. what's inside of |
Hi @umarmughal824 and @smithdc1 In regards to #112, by the looks of it there's a missing migration. Any suggestions for how we approach this? Any reason why a migration would be missing for |
|
I think this is related: https://docs.djangoproject.com/en/4.1/releases/3.2/#customizing-type-of-auto-created-primary-keys The 0002 migration changed the auto fields to You can set the default in from django.apps import AppConfig
class RobotsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'robots' so it works for everyone. |
@jan-szejko-steelseries Are you open to making a pull request? In regards to any PRs that'd work for existing and new installations - across django versions: PRs and tests are welcome. |
@tony Here you go. |
@tony What's the progress? I can't run |
@jan-szejko-steelseries Sorry for the delay - I'm not available during the weekdays (I will give this my undivided attention on Saturday) |
In re: #124 missing migration This may, in turn, create migrations for those who manually created them. Each situation depends on the system
In re: #124 missing migration This may, in turn, create migrations for those who manually created them. Each situation depends on the system
Looking for testers for 6.0b0 (PyPI, GitHub release, changes)I've released 6.0b0, which has @jan-szejko-steelseries's patch from #134 I am looking for feedback on this before release☝️ 5.0 users: Getting migrations back on trackIf you already applied a custom migration, you may need to resolve this (once) If you ran If you do run into migration issues (conflicts with custom migrations) I'm also interested in steps you took to resolve the conflicts. cc: @amourousias @fabien-michel @VdeJong @jan-szejko-steelseries @michaeljcollinsuk @mattaustin @jonprindiville, @svandeneertwegh @justin-ven from #125 |
Hey @tony, thank you for the beta release! Just wanted to confirm, that it solves the "missing" migrations issue and I see no adverse effects. |
@fdemmer Thank you for the feedback! I am deliberating whether to release 6.0 now as its been a few months, we may not be able to count on more reviewers. Any more reviewers available to try 6.0b? (PyPI, GitHub release, changes) |
Here's what I did. With the beta release installed and with only two files in /env/lib/python3.9/site-packages/robots/migrations/, showmigrations doesn't show any problems: $ ./manage.py showmigrations robots
robots
[X] 0001_initial
[X] 0002_alter_id_fields But looking at the DB, there are problems: > from django.db.migrations.recorder import MigrationRecorder
> pp(list(MigrationRecorder.Migration.objects.filter(app='robots').values()))
[{'id': 618,
'app': 'robots',
'name': '0001_initial',
'applied': datetime.datetime(2021, 8, 18, 13, 56, 24, 74487, tzinfo=datetime.timezone.utc)},
{'id': 859,
'app': 'robots',
'name': '0002_alter_id_fields',
'applied': datetime.datetime(2022, 1, 25, 19, 41, 47, 400304, tzinfo=datetime.timezone.utc)},
{'id': 963,
'app': 'robots',
'name': '0003_auto_20220419_1535',
'applied': datetime.datetime(2022, 6, 7, 21, 24, 27, 326008, tzinfo=datetime.timezone.utc)},
{'id': 1016,
'app': 'robots',
'name': '0003_alter_rule_id_alter_url_id',
'applied': datetime.datetime(2022, 10, 11, 19, 22, 58, 916935, tzinfo=datetime.timezone.utc)}] Oof. It shows four migrations, two of which we don't have source files for anymore. (Make sure you specifically look and see what files you have. I don't think installing the beta clobbers the 'extra' migrations if you have them. I went overboard and rm -rf'd the robots directory and lost them.) Hmm. Let's see the column types in the DB ( => \d+ robots_url
Table "public.robots_url"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
---------+------------------------+-----------+----------+----------------------------------------+----------+--------------+-------------
id | integer | | not null | nextval('robots_url_id_seq'::regclass) | plain | |
pattern | character varying(255) | | not null | | extended | | Same for robots_rule. That type should be bigint instead of integer. So how to get there? Here's one way: Our goal is to $ cd env/lib/python3.9/site-packages/robots/migrations
$ cp 0002_alter_id_fields.py 0003_alter_rule_id_alter_url_id.py # filename shown in the .values() above
$ cp 0002_alter_id_fields.py 0003_auto_20220419_1535.py # ditto
$ ./manage.py makemigrations --merge robots # required because there are multiple leaf nodes in the migration graph
Merging robots
Branch 0002_alter_id_fields
- Alter field id on rule
- Alter field id on url
Branch 0003_alter_rule_id_alter_url_id
- Alter field id on rule
- Alter field id on url
Branch 0003_auto_20220419_1535
- Alter field id on rule
- Alter field id on url
Merging will only work if the operations printed above do not conflict
with each other (working on different fields or models)
Should these migration branches be merged? [y/N] y
Created new merge migration env/lib/python3.9/site-packages/robots/migrations/0004_merge_20230728_1649.py
$ ./manage.py migrate --fake robots 0001
Operations to perform:
Target specific migration: 0001_initial, from robots
Running migrations:
Rendering model states... DONE
Unapplying robots.0002_alter_id_fields... FAKED
Unapplying robots.0003_alter_rule_id_alter_url_id... FAKED
Unapplying robots.0003_auto_20220419_1535... FAKED Now, back in django shell: >>> pp(list(MigrationRecorder.Migration.objects.filter(app='robots').values()))
[{'id': 618,
'app': 'robots',
'name': '0001_initial',
'applied': datetime.datetime(2021, 8, 18, 13, 56, 24, 74487, tzinfo=datetime.timezone.utc)}] Looking good, only one migration showing in the DB. Let's check the column type => \d+ robots_url
Table "public.robots_url"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
---------+------------------------+-----------+----------+----------------------------------------+----------+--------------+-------------
id | integer | | not null | nextval('robots_url_id_seq'::regclass) | plain | |
pattern | character varying(255) | | not null | | extended | | So now we can |
I am too missing migrations running the new django-robots 5.0 version |
Hey hey 👋 I have got a production Django 3.2 app which still sets its own A while back when trying to move from A few days ago I successfully transitioned the app from using cc @tony @jan-szejko-steelseries thanks! |
@jonprindiville Thank you for getting back! I will publish |
I got this message after upgrading to 5.0.
The migration is forgotten to include in the commit.
The text was updated successfully, but these errors were encountered: