dracidoupe / graveyard

Open Source reimplementation of https://www.dracidoupe.cz/
https://nove.dracidoupe.cz/
MIT License
6 stars 4 forks source link

Figure out how to fix the ID migration #309

Closed Almad closed 3 years ago

Almad commented 3 years ago

This is thanks to https://github.com/dracidoupe/graveyard/pull/301/files#diff-86135d276669269b1692dfa7761ae91795c079b3cce63c4f20b795c59c340223R18

I verified the id field is not in the DB, but apparently there is a migration framework model mismatch.

My best guess is to alter the old migration, make the ID into a new one and --fake it on production.

(gvenv) almad@hyuga graveyard % time heroku run python manage.py migrate -a dracidoupe
Running python manage.py migrate on ⬢ dracidoupe... up, run.4636 (Free)
System check identified some issues:

WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
    HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/2.0/ref/databases/#mysql-sql-mode
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, ddcz, sessions
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
heroku run python manage.py migrate -a dracidoupe  0.36s user 0.11s system 2% cpu 20.023 total
(gvenv) almad@hyuga graveyard % time heroku run python manage.py makemigrations -a dracidoupe
Running python manage.py makemigrations on ⬢ dracidoupe... up, run.2263 (Free)
Migrations for 'ddcz':
  ddcz/migrations/0095_remove_taverntablenoticeboard_id.py
    - Remove field id from taverntablenoticeboard
heroku run python manage.py makemigrations -a dracidoupe  0.37s user 0.08s system 3% cpu 14.685 total
(gvenv) almad@hyuga graveyard % 
Almad commented 3 years ago
(gvenv) almad@hyuga graveyard % time heroku run python manage.py migrate -a dracidoupe
Running python manage.py migrate on ⬢ dracidoupe... up, run.9304 (Free)
System check identified some issues:

WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
    HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/2.0/ref/databases/#mysql-sql-mode
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, ddcz, sessions
Running migrations:
  Applying ddcz.0101_remove_taverntablenoticeboard_id...Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/app/.heroku/python/lib/python3.7/site-packages/MySQLdb/cursors.py", line 255, in execute
    self.errorhandler(self, exc, value)
  File "/app/.heroku/python/lib/python3.7/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/app/.heroku/python/lib/python3.7/site-packages/MySQLdb/cursors.py", line 252, in execute
    res = self._query(query)
  File "/app/.heroku/python/lib/python3.7/site-packages/MySQLdb/cursors.py", line 378, in _query
    db.query(q)
  File "/app/.heroku/python/lib/python3.7/site-packages/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1091, "Can't DROP 'id'; check that column/key exists")

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

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 200, in handle
    fake_initial=fake_initial,
  File "/app/.heroku/python/lib/python3.7/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 "/app/.heroku/python/lib/python3.7/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 "/app/.heroku/python/lib/python3.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/migrations/migration.py", line 122, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/migrations/operations/fields.py", line 150, in database_forwards
    schema_editor.remove_field(from_model, from_model._meta.get_field(self.name))
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/base/schema.py", line 477, in remove_field
    self.execute(sql)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/base/schema.py", line 133, in execute
    cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.7/site-packages/sentry_sdk/integrations/django/__init__.py", line 500, in execute
    return real_execute(self, sql, params)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/app/.heroku/python/lib/python3.7/site-packages/MySQLdb/cursors.py", line 255, in execute
    self.errorhandler(self, exc, value)
  File "/app/.heroku/python/lib/python3.7/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/app/.heroku/python/lib/python3.7/site-packages/MySQLdb/cursors.py", line 252, in execute
    res = self._query(query)
  File "/app/.heroku/python/lib/python3.7/site-packages/MySQLdb/cursors.py", line 378, in _query
    db.query(q)
  File "/app/.heroku/python/lib/python3.7/site-packages/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (1091, "Can't DROP 'id'; check that column/key exists")
Sentry is attempting to send 1 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit
heroku run python manage.py migrate -a dracidoupe  0.44s user 0.15s system 3% cpu 15.565 total
(gvenv) almad@hyuga graveyard % time heroku run python manage.py migrate --fake -a dracidoupe
Running python manage.py migrate --fake on ⬢ dracidoupe... up, run.3713 (Free)
System check identified some issues:

WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
    HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/2.0/ref/databases/#mysql-sql-mode
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, ddcz, sessions
Running migrations:
  Applying ddcz.0101_remove_taverntablenoticeboard_id... FAKED
heroku run python manage.py migrate --fake -a dracidoupe  0.46s user 0.12s system 2% cpu 20.723 total
(gvenv) almad@hyuga graveyard % time heroku run python manage.py migrate -a dracidoupe       
Running python manage.py migrate on ⬢ dracidoupe... up, run.6740 (Free)
System check identified some issues:

WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
    HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/2.0/ref/databases/#mysql-sql-mode
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, ddcz, sessions
Running migrations:
  No migrations to apply.
heroku run python manage.py migrate -a dracidoupe  0.38s user 0.09s system 2% cpu 20.221 total
(gvenv) almad@hyuga graveyard %