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

Create table project sdg xref 66 #385

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dmartin4820
Copy link
Member

Fixes #66

What changes did you make?

  • Created project to sdg many-to-many relationship by updating both project and sdg models
  • Created many-to-many test as well as the other standard test procedures
  • Updated how-to with an example of a many-to-many test

@dmartin4820

This comment was marked as resolved.

@dmartin4820 dmartin4820 mentioned this pull request Sep 30, 2024
15 tasks
@dmartin4820
Copy link
Member Author

Still trying to resolve the merging of the current peopledepot main branch. I'm able to resolve any conflicts between files in my local repo and the incoming changes from the main branch, but I'm getting issues with data migrations.

I went through some of the steps here #378 (comment). When I run step 7 of the linked comment, the error output is shown below. I also ran step 5 and it output CommandError: core's max_migration.txt does not seem to contain a merge conflict. So, it didn't seem necessary in my case.

It appears to fail when applying core 0026. I'm going to try doing the migration without my changes. If that doesn't work, apparently I'm missing something and will require some time to figure out what's really happening. @fyliu @del9ra Any help is appreciated if you were able to resolve some of the data issues.

+ docker-compose exec -T web python manage.py makemigrations
No changes detected
+ docker-compose exec -T web python manage.py migrate core
Operations to perform:
  Apply all migrations: core
Running migrations:
  Applying core.0026_permissiontype_rank_alter_permissiontype_name_and_more...Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
psycopg2.errors.UniqueViolation: could not create unique index "core_permissiontype_rank_key"
DETAIL:  Key (rank)=(0) is duplicated.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/app/manage.py", line 23, in <module>
    main()
  File "/usr/src/app/manage.py", line 19, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
  File "/usr/local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
  File "/usr/local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
  File "/usr/local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python3.10/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/usr/local/lib/python3.10/site-packages/django/db/migrations/operations/fields.py", line 108, in database_forwards
    schema_editor.add_field(
  File "/usr/local/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 713, in add_field
    self.execute(sql, params)
  File "/usr/local/lib/python3.10/site-packages/django/db/backends/postgresql/schema.py", line 48, in execute
    return super().execute(sql, None)
  File "/usr/local/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 201, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 102, in execute
    return super().execute(sql, params)
  File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/usr/local/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
django.db.utils.IntegrityError: could not create unique index "core_permissiontype_rank_key"
DETAIL:  Key (rank)=(0) is duplicated.

Just resolved. Fang suggested deleting my local database. We do this by running the command: ./scripts/buildrun.sh -v. The -v argument will remove Docker volumes, and the local database by consequence.

@dmartin4820 dmartin4820 force-pushed the create_table_project_sdg_xref_66 branch from e9d5461 to a3ff267 Compare September 30, 2024 02:43
Copy link
Member

@del9ra del9ra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks great!

  • The PR was done with the correct branch.
  • The issue was linked properly.
  • The code changes were applied correctly.
    Thank you for your valuable contribution! The documentation for the many-to-many relationship is really helpful for me personally.

@dmartin4820 dmartin4820 requested a review from fyliu October 1, 2024 02:45
@dmartin4820
Copy link
Member Author

@fyliu Del took a look at the PR and didn't have issues. We wanted to check with you to see if you had any additional comments or improvements. Otherwise, I'll squash and merge the PR and move on to other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔖PR ready to merge
Development

Successfully merging this pull request may close these issues.

Create Table: project_sdg_xref
2 participants