Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

probably this isn't the right way to do the PartSerializer #41

Open
hcientist opened this issue Oct 20, 2023 · 0 comments
Open

probably this isn't the right way to do the PartSerializer #41

hcientist opened this issue Oct 20, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@hcientist
Copy link
Contributor

So i added a field to the model and serializer, but I think I done bad because when trying to migrate from scratch (brand new db) i get the following which seems to come from teleband/musics/migrations/0016_seed_pieces_later.py (perhaps due to the PartCreateSerializer or its create function?):

Traceback (most recent call last):
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedColumn: column "chord_scale_pattern" of relation "musics_part" does not exist
LINE 1: ...ame", "part_type_id", "piece_id", "sample_audio", "chord_sca...
                                                             ^


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

Traceback (most recent call last):
  File "/Users/tgm/dev/cprbk-test/manage.py", line 31, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/Users/tgm/dev/cprbk-test/teleband/musics/migrations/0016_seed_pieces_later.py", line 117, in update_site_forward
    serializer.create(serializer.validated_data)
  File "/Users/tgm/dev/cprbk-test/teleband/musics/api/serializers.py", line 135, in create
    ps.create(parts_data)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/rest_framework/serializers.py", line 703, in create
    return [
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/rest_framework/serializers.py", line 704, in <listcomp>
    self.child.create(attrs) for attrs in validated_data
  File "/Users/tgm/dev/cprbk-test/teleband/musics/api/serializers.py", line 101, in create
    part = Part.objects.create(piece=piece, **validated_data)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/models/query.py", line 453, in create
    obj.save(force_insert=True, using=self.db)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/models/base.py", line 739, in save
    self.save_base(using=using, force_insert=force_insert,
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/models/base.py", line 776, in save_base
    updated = self._save_table(
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/models/base.py", line 881, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/models/base.py", line 919, in _do_insert
    return manager._insert(
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/models/query.py", line 1270, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1416, in execute_sql
    cursor.execute(sql, params)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/backends/utils.py", line 79, in _execute
    with self.db.wrap_database_errors:
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/Users/tgm/.asdf/installs/python/3.10.11/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "chord_scale_pattern" of relation "musics_part" does not exist
LINE 1: ...ame", "part_type_id", "piece_id", "sample_audio", "chord_sca...
                                                             ^
@hcientist hcientist added the bug Something isn't working label Oct 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant