Skip to content
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

Has there any migration to apply? #615

Closed
jefer94 opened this issue Apr 30, 2024 · 4 comments
Closed

Has there any migration to apply? #615

jefer94 opened this issue Apr 30, 2024 · 4 comments

Comments

@jefer94
Copy link

jefer94 commented Apr 30, 2024

Python: 3.12.3
Lib: 4.2

My tests broke when I tried to delete an auth.User, here is the traceback:

________________________________ AuthenticateTestSuite.test__post__with_token__right_password__passing_callback _________________________________
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/backends/utils.py:105: in _execute
    return self.cursor.execute(sql, params)
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/newrelic/hooks/database_dbapi2.py:37: in execute
    return self.__wrapped__.execute(sql, parameters,
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py:329: in execute
    return super().execute(query, params)
E   sqlite3.OperationalError: no such table: explorer_promptlog

The above exception was the direct cause of the following exception:
breathecode/authenticate/tests/urls/tests_password_token.py:459: in test__post__with_token__right_password__passing_callback
    self.bc.database.delete('auth.User')
breathecode/tests/mixins/breathecode_mixin/database.py:561: in delete
    return model.objects.filter(**lookups).delete()
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/models/query.py:1187: in delete
    collector.collect(del_query)
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/models/deletion.py:348: in collect
    if getattr(on_delete, "lazy_sub_objs", False) or sub_objs:
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/models/query.py:414: in __bool__
    self._fetch_all()
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/models/query.py:1928: in _fetch_all
    self._result_cache = list(self._iterable_class(self))
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/models/query.py:91: in __iter__
    results = compiler.execute_sql(
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/models/sql/compiler.py:1562: in execute_sql
    cursor.execute(sql, params)
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/backends/utils.py:105: in _execute
    return self.cursor.execute(sql, params)
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/newrelic/hooks/database_dbapi2.py:37: in execute
    return self.__wrapped__.execute(sql, parameters,
../../../.local/share/virtualenvs/apiv2-bqPrB3_w/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py:329: in execute
    return super().execute(query, params)
E   django.db.utils.OperationalError: no such table: explorer_promptlog

I'm back to 4.0.2 again, never mind, I'll wait to test the next release.

@jefer94 jefer94 changed the title Have there any migration to apply? Has there any migration to apply? Apr 30, 2024
@chrisclark
Copy link
Owner

Yes -- there are migrations. 00014_promptlog.py should create this table. Have you run migrations?

@jefer94
Copy link
Author

jefer94 commented Apr 30, 2024

No, it just seemed like the table hadn't been created. Actually, in tests the migrations are disabled exit_code = os.system(f'pytest {args} --nomigrations --durations=1'), but the table wasn't created, and the database is destroyed in every execution. I'll run the tests with migrations in a few hours.

@jefer94
Copy link
Author

jefer94 commented May 2, 2024

I could run the test, and yes, it works with migrations, but it's not the solution, the migrations affect our productivity in test environment:

  • With migrations: 119.17s
  • No migrations: 2.32s

chrisclark pushed a commit that referenced this issue May 14, 2024
Fixes issue where python manage.py makemigrations expects PromptLog model to be deleted, as the explorer app doesn't include it in its models.py file. Addresses #615
@chrisclark
Copy link
Owner

This is likely addressed by #618, which has been merged. Please feel free to re-open if this is a separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants