RadicalxChange / rxc-voice

An app for decentralized democratic governance.
https://voice.radicalxchange.org/
Other
42 stars 14 forks source link

migrations issue w/ docker instructions #103

Open whatSocks opened 2 years ago

whatSocks commented 2 years ago

Describe the bug

there seems to be a missing migration on the docker instructions. I can try to work around it.

to get around this issue, i changed

default=django.utils.timezone.now

to

default=1

in the migrations file.

here's the error:

 Applying main.0002_auto_20220618_1234...Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1774, in get_prep_value
    return int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.datetime'

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

Traceback (most recent call last):
  File "/backend/RxcVoiceApi/./manage.py", line 22, in <module>
    main()
  File "/backend/RxcVoiceApi/./manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 243, in handle
    post_migrate_state = executor.migrate(
  File "/usr/local/lib/python3.9/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 "/usr/local/lib/python3.9/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 "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/operations/fields.py", line 104, in database_forwards
    schema_editor.add_field(
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 455, in add_field
    definition, params = self.column_sql(model, field, include_default=True)
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 223, in column_sql
    default_value = self.effective_default(field)
  File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 303, in effective_default
    return field.get_db_prep_save(self._effective_default(field), self.connection)
  File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 971, in get_db_prep_save
    return self.target_field.get_db_prep_save(value, connection=connection)
  File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 823, in get_db_prep_save
    return self.get_db_prep_value(value, connection=connection, prepared=False)
  File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 2388, in get_db_prep_value
    value = self.get_prep_value(value)
  File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1776, in get_prep_value
    raise e.__class__(
TypeError: Field 'id' expected a number but got datetime.datetime(2022, 6, 18, 16, 42, 30, 390586, tzinfo=<UTC>).
alexrandaccio commented 2 years ago

@whatSocks thanks for posting the logs!