Zeigren / inventree-docker

Docker Stack For InvenTree A Open Source Inventory Management System
10 stars 5 forks source link

Can't DROP COLUMN 'customer_id' #5

Open dodgen247 opened 4 years ago

dodgen247 commented 4 years ago

Just pulled the latest and received the below error during the inventree container start up. Any help would be appreciated!

MySQLdb._exceptions.OperationalError: (1091, "Can't DROP COLUMN customer_id; check that it exists")

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

Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "/opt/venv/lib/python3.8/site-packages/django/core/management/init.py", line 401, in execute_from_command_line utility.execute() File "/opt/venv/lib/python3.8/site-packages/django/core/management/init.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/venv/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv self.execute(*args, cmd_options) File "/opt/venv/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute output = self.handle(*args, *options) File "/opt/venv/lib/python3.8/site-packages/django/core/management/base.py", line 83, in wrapped res = handle_func(args, kwargs) File "/opt/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 231, in handle post_migrate_state = executor.migrate( File "/opt/venv/lib/python3.8/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 "/opt/venv/lib/python3.8/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 "/opt/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 245, in apply_migration state = migration.apply(state, schema_editor) File "/opt/venv/lib/python3.8/site-packages/django/db/migrations/migration.py", line 124, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/opt/venv/lib/python3.8/site-packages/django/db/migrations/operations/fields.py", line 178, in database_forwards schema_editor.remove_field(from_model, from_model._meta.get_field(self.name)) File "/opt/venv/lib/python3.8/site-packages/django/db/backends/base/schema.py", line 517, in remove_field self.execute(sql) File "/opt/venv/lib/python3.8/site-packages/django/db/backends/base/schema.py", line 142, in execute cursor.execute(sql, params) File "/opt/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 68, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/opt/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers return executor(sql, params, many, context) File "/opt/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute return self.cursor.execute(sql, params) File "/opt/venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in exit raise dj_exc_value.with_traceback(traceback) from exc_value File "/opt/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute return self.cursor.execute(sql, params) File "/opt/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 74, in execute return self.cursor.execute(query, args) File "/opt/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 209, in execute res = self._query(query) File "/opt/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 315, in _query db.query(q) File "/opt/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 239, in query _mysql.connection.query(self, query) django.db.utils.OperationalError: (1091, "Can't DROP COLUMN customer_id; check that it exists") make: *** [Makefile:15: migrate] Error 1

Zeigren commented 4 years ago

Yeah I'm a bit behind on updating it. InvenTree is on version 0.1.0 now and the last version I checked was 0.0.10

Zeigren commented 4 years ago

Did you run a migration by setting MIGRATE_STATIC=True? I made a minor update but it shouldn't make any difference.

dodgen247 commented 4 years ago

Yes the migrate_static was set to True for the version change. Changing it to false does allow the system to boot up though.

Zeigren commented 4 years ago

Hmm when MIGRATE_STATIC is set to true it'll still run once its finished. You technically can leave it on all the time it just slows down the boot process. Do you get any errors when running the migration? Since it can't find the customer_id column you might want to use phpmyadmin or something else to check the database. See if you can connect and whether that column is actually missing or not. You can borrow the bit from the development.yml to get that running.

dodgen247 commented 4 years ago

The migration actually kills the inventree container. I have included the logs to where it dies below. I ran the below query in the mariadb and found that the column does exist in the order_salesorder table.

SELECT table_name,table_schema FROM INFORMATION_SCHEMA.COLUMNS WHERE column_name='customer_id'

Config file already exists (skipping), Test connection to database, Success!, Give the database a few seconds to warm up, make: Entering directory '/usr/src/app', cd InvenTree && python3 manage.py makemigrations, InvenTree: Checking Part image thumbnails, Could not generate Part thumbnails, InvenTree: Checking Company image thumbnails, Loading barcode plugins, Loading barcode plugins, Discovered 2 barcode plugins:,