grafana / oncall

Developer-friendly incident response with brilliant Slack integration
GNU Affero General Public License v3.0
3.49k stars 288 forks source link

Error when updating to v1.3.48 with django migration script #3222

Closed spedou closed 1 year ago

spedou commented 1 year ago

What went wrong?

Hello!

When updating the oncall-engine deployement to v1.3.48, I get this error trace on the django database migrations job

 File "/usr/local/lib/python3.11/site-packages/django/db/migrations/operations/fields.py", line 235, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 830, in alter_field
    self._alter_field(
File "/usr/local/lib/python3.11/site-packages/django/db/backends/postgresql/schema.py", line 287, in _alter_field
    super()._alter_field(
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 1055, in _alter_field
    self.execute(
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/postgresql/schema.py", line 48, in execute
    return super().execute(sql, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 201, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/usr/local/lib/python3.11/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.11/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.ProgrammingError: cannot cast type integer to jsonb
LINE 1: ..." TYPE jsonb USING "going_oncall_notification_timing"::jsonb
                                                                ^

  Applying mobile_app.0011_alter_mobileappusersettings_going_oncall_notification_timing...

command : python manage.py migrate

I think this is due to this PR : #3103

Grafana OnCall Version

v1.3.48

Product Area

Other

Grafana OnCall Platform?

Kubernetes

User's Browser?

No response

Anything else to add?

No response

max9933 commented 1 year ago

Can confirm experiencing the same issue when updating, having to stick on 1.3.43 currently

agilob commented 1 year ago

Still here 4 minor releases later

+ release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 › oncall-migrate
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate postgresql.database (10.43.114.118:5432) open
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate Operations to perform:
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   Apply all migrations: admin, alerts, auth, auth_token, base, contenttypes, email, fcm_django, heartbeat, labels, mobile_app, oss_installation, phone_notifications, schedules, sessions, slack, social_django, telegram, twilioapp, user_management, webhooks, zvonok
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate Running migrations:
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate Traceback (most recent call last):
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 87, in _execute
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     return self.cursor.execute(sql)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate            ^^^^^^^^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate psycopg2.errors.CannotCoerce: cannot cast type integer to jsonb
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate LINE 1: ..." TYPE jsonb USING "going_oncall_notification_timing"::jsonb
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate                                                                 ^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate The above exception was the direct cause of the following exception:
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate Traceback (most recent call last):
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/etc/app/manage.py", line 15, in <module>
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     execute_from_command_line(sys.argv)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     utility.execute()
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     self.fetch_command(subcommand).run_from_argv(self.argv)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     self.execute(*args, **cmd_options)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     output = self.handle(*args, **options)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     res = handle_func(*args, **kwargs)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     post_migrate_state = executor.migrate(
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate                          ^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     state = self._migrate_all_forwards(
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     state = self.apply_migration(
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate             ^^^^^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     state = migration.apply(state, schema_editor)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     operation.database_forwards(
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/migrations/operations/fields.py", line 235, in database_forwards
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     schema_editor.alter_field(from_model, from_field, to_field)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 830, in alter_field
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     self._alter_field(
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/backends/postgresql/schema.py", line 287, in _alter_field
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     super()._alter_field(
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 1055, in _alter_field
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     self.execute(
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/backends/postgresql/schema.py", line 48, in execute
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     return super().execute(sql, None)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate            ^^^^^^^^^^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 201, in execute
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     cursor.execute(sql, params)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     return self._execute_with_wrappers(
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     return executor(sql, params, many, context)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     with self.db.wrap_database_errors:
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     raise dj_exc_value.with_traceback(traceback) from exc_value
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 87, in _execute
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate     return self.cursor.execute(sql)
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate            ^^^^^^^^^^^^^^^^^^^^^^^^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate django.db.utils.ProgrammingError: cannot cast type integer to jsonb
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate LINE 1: ..." TYPE jsonb USING "going_oncall_notification_timing"::jsonb
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate                                                                 ^
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate
release-oncall-engine-migrate-2023-11-02-14-34-07-qjfp7 oncall-migrate   Applying mobile_app.0011_alter_mobileappusersettings_going_oncall_notification_timing...
joeyorlando commented 1 year ago

👋 thanks for reporting this, a fix for this was added in #3260. Keep an eye out for the next release which should come out (hopefully) before the end of the week

agilob commented 1 year ago

thanks :+1:

joeyorlando commented 1 year ago

hi there, a fix for this was included in v1.3.53 (just released). Feel free to open a separate issue if you're still running into this.