Skip to content

[qa] Use a separate database for migration checks #186

@pandafy

Description

@pandafy

Performing migration checks on user's database sometimes leads to tests failing for sample app of the module.

Here is an example of running migration checks on openwisp-controller

$ SAMPLE_APP=1 openwisp-qa-check \
SAMPLE_APP=1 openwisp-qa-check \
>   --migration-path "./tests/openwisp2/sample_config/migrations/
>                     ./tests/openwisp2/sample_pki/migrations/
>                     ./tests/openwisp2/sample_connection/migrations/
>                     ./tests/openwisp2/sample_geo/migrations/"
SUCCESS: Blank endline check successful!
SUCCESS: Migration name check on "./tests/openwisp2/sample_config/migrations/" with migrations-to-ignore: 0 successful!
SUCCESS: Migration name check on "./tests/openwisp2/sample_pki/migrations/" with migrations-to-ignore: 0 successful!
SUCCESS: Migration name check on "./tests/openwisp2/sample_connection/migrations/" with migrations-to-ignore: 0 successful!
SUCCESS: Migration name check on "./tests/openwisp2/sample_geo/migrations/" with migrations-to-ignore: 0 successful!
SUCCESS: Isort check successful!
SUCCESS: Black check successful!
SUCCESS: Flake8 check successful!
SUCCESS: ReStructuredText check successful!
SUCCESS: Commit message check successful!
Traceback (most recent call last):
  File "tests/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle
    loader.check_consistent_history(connection)
  File "/home/pandafy/openwisp/venv-controller/lib/python3.8/site-packages/django/db/migrations/loader.py", line 295, in check_consistent_history
    raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration account.0001_initial is applied before its dependency sample_users.0001_initial on database 'default'.

We should check if we can use an in-memory database for performing these checks

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestEasy issues for attracting Hacktoberfest participants.enhancement

    Type

    No type

    Projects

    Status

    To do (Python & Django)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions