[Bug] Missing migrations?
Hi!
After updading the dependencies, including django-comments-xtd, the tests on my app fail with
raise InvalidBasesError(
django.db.migrations.exceptions.InvalidBasesError: Cannot resolve bases for [<ModelState: 'django_comments_xtd.XtdComment'>]
This can happen if you are inheriting models from an app with migrations (e.g. contrib.auth)
So I ran python manage.py makemigrations django_comments_xtd and it seems it is missing a migration, or it is not able to access the existing ones:
Migrations for 'django_comments_xtd':
.venv/lib/python3.12/site-packages/django_comments_xtd/migrations/0001_initial.py
+ Create model BlackListedDomain
+ Create model XtdComment
(the tests ran fine after that)
Hi @Ash-Crow, thanks for telling. I had such a situation maybe 2 years ago. The message makes me think that it might have to do with a migration applied to the django-contrib-comments. But I have not been able to reproduce it.
The migrations that create the models BlackListedDomain and XtdComment are 8 years old.
Could you please paste here the content of the file it created on your environment?
I mean .venv/lib/python3.12/site-packages/django_comments_xtd/migrations/0001_initial.py.
Thank you
Yes it's strange (especially as it created the migration, but didn't run it when I tried to migrate - which I guess is normal considering that the app was already installed and working)
# Generated by Django 5.1.7 on 2025-03-25 16:39
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("django_comments", "0004_add_object_pk_is_removed_index"),
]
operations = [
migrations.CreateModel(
name="BlackListedDomain",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("domain", models.CharField(db_index=True, max_length=200)),
],
options={
"ordering": ("domain",),
},
),
migrations.CreateModel(
name="XtdComment",
fields=[
(
"comment_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="django_comments.comment",
),
),
("thread_id", models.IntegerField(db_index=True, default=0)),
("parent_id", models.IntegerField(default=0)),
("level", models.SmallIntegerField(default=0)),
("order", models.IntegerField(db_index=True, default=1)),
(
"followup",
models.BooleanField(
blank=True, default=False, help_text="Notify follow-up comments"
),
),
("nested_count", models.IntegerField(db_index=True, default=0)),
],
options={
"verbose_name": "comment",
"verbose_name_plural": "comments",
"ordering": ("submit_date",),
"permissions": [("can_moderate", "Can moderate comments")],
"abstract": False,
},
bases=("django_comments.comment",),
),
]
Hello. I have the same problem after the update.The migrations directory does not appear when installing the new version 2.10.5. Version 2.10.4 works fine. In the new release, setup.py was removed. Instead, pyproject.toml was added. It contains the following lines (maybe the problem is because of them):
[tool.ruff]
exclude = [
"docs/",
"venv/",
"django_comments_xtd/migrations/",
"django_comments_xtd/tests/migrations/",
"example/**/migrations/",
]
Hi @gagaga67, thanks, but I don't think it is related. Ruff is the linter and code formatter, with those lines in the pyproject.toml we tell Ruff, the formatter, to exclude those directories when reformatting code. See that Ruff didn't reformatted them; the django_comments_xtd/migrations/ directory has not changed in 4 years. So it has to be something else. What was it remains a mystery so far.
This bug has been fixed in version 2.10.6. Thank you!