Closed pewi81 closed 6 years ago
What version were you upgrading from?
Sorry, my mistake, it was v5.4.15
Okay. you're probably experiencing an issue related to a database upgrade problem I resolved recently. If you care about your stored sensor data and want to continue using your current database, you'll have to manually update it, which can be pretty involved. Otherwise you can attempt to have alembic upgrade the database to see what the specific error is (or it may actually upgrade it properly). The last option is to delete your database and have Mycodo generate a new one and start over.
Try these commands to see if the database can be upgraded:
cd ~/Mycodo/databases
~/Mycodo/env/bin/alembic upgrade head
Okay, so I got this when I tried to upgrade the database manually:
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade 234283cc67f4 -> b9712d4ec64e, Add Math controller
Traceback (most recent call last):
File "/home/pi/Mycodo/env/bin/alembic", line 11, in <module>
sys.exit(main())
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/config.py", line 479, in main
CommandLine(prog=prog).main(argv=argv)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/config.py", line 473, in main
self.run_cmd(cfg, options)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/config.py", line 456, in run_cmd
**dict((k, getattr(options, k, None)) for k in kwarg)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/command.py", line 254, in upgrade
script.run_env()
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/script/base.py", line 425, in run_env
util.load_python_file(self.dir, 'env.py')
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 81, in load_python_file
module = load_module_py(module_id, path)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/util/compat.py", line 141, in load_module_py
mod = imp.load_source(module_id, path, fp)
File "alembic/env.py", line 70, in <module>
run_migrations_online()
File "alembic/env.py", line 65, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/runtime/environment.py", line 836, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/runtime/migration.py", line 330, in run_migrations
step.migration_fn(**kw)
File "/home/pi/Mycodo/databases/alembic/versions/b9712d4ec64e_add_math_controller.py", line 21, in upgrade
batch_op.add_column(sa.Column('math', sa.Text))
File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/operations/base.py", line 300, in batch_alter_table
impl.flush()
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/operations/batch.py", line 57, in flush
fn(*arg, **kw)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/ddl/impl.py", line 172, in add_column
self._exec(base.AddColumn(table_name, column, schema=schema))
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/ddl/impl.py", line 118, in _exec
return conn.execute(construct, *multiparams, **params)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 948, in execute
return meth(self, multiparams, params)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1009, in _execute_ddl
compiled
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
context)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
exc_info
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) duplicate column name: math [SQL: u'ALTER TABLE displayorder ADD COLUMN math TEXT']
Please paste the output of:
cd ~/Mycodo/databases
~/Mycodo/env/bin/alembic history
I think I just came up with an easy solution. You'll just have to give me some info about where your database currently is.
8b36095c6cf9 -> d36de7e4e477, Add math_id option to conditionals
b9712d4ec64e -> 8b36095c6cf9, Add Math type: Input Verification
234283cc67f4 -> b9712d4ec64e, Add Math controller
8828a0074a44 -> 234283cc67f4, Add device option for camera
3dcf34dd7caf -> 8828a0074a44, Add Max Age option to LCD lines
321038f2e101 -> 3dcf34dd7caf, Add upgrade check to daemon
d0757b2ecd33 -> 321038f2e101, Add more Graph options
3c7c2b12389d -> d0757b2ecd33, Add unique_id for remote table
70b7016e107f -> 3c7c2b12389d, Add options to cycle multiple displays on one LCD
589ab40606d3 -> 70b7016e107f, Add user language option and delete misc language option
214c6bb4603a -> 589ab40606d3, Remove camera type, only use library instead
f4c0693f12a4 -> 214c6bb4603a, Add method_id as option for new PWM Timer
56ec4ceb9dfd -> f4c0693f12a4, Add sample time option for PWM and RPM Inputs
a0c55d19384c -> 56ec4ceb9dfd, Add PWM and RPM Input options
08a36ebf1a82 -> a0c55d19384c, Remove PID type option
ca975c26965c -> 08a36ebf1a82, Add Sensor option to inverse ADC unit scale
66db29288333 -> ca975c26965c, Add LCD I2C bus option
25676b9d5856 -> 66db29288333, Add new sensor type command
ed7e979852fa -> 25676b9d5856, Add option to end duration PID method with repeats after duration
c7b4a120a7bb -> ed7e979852fa, Add graph type
b604cf735be5 -> c7b4a120a7bb, add MH-Z19 CO2 sensor
9d7631079ac1 -> b604cf735be5, add options for PWM output
a1fcd7a4adf2 -> 9d7631079ac1, Add options for wireless relay control
a9a330ea0ccb -> a1fcd7a4adf2, Add calibration_sensor_measure option for Atlas Scientific pH sensors
f1c6b2901d45 -> a9a330ea0ccb, Add UART options: baud rate and device location
059a47f950b8 -> f1c6b2901d45, Add resolution and sensitivity to sensor table (for BH1750 sensor)
<base> -> 059a47f950b8, add option to show/hide tooltips```
Try this and let me know the output:
cd ~/Mycodo/databases
~/Mycodo/env/bin/alembic stamp b9712d4ec64e
~/Mycodo/env/bin/alembic upgrade head
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade b9712d4ec64e -> 8b36095c6cf9, Add Math type: Input Verification
Traceback (most recent call last):
File "/home/pi/Mycodo/env/bin/alembic", line 11, in <module>
sys.exit(main())
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/config.py", line 479, in main
CommandLine(prog=prog).main(argv=argv)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/config.py", line 473, in main
self.run_cmd(cfg, options)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/config.py", line 456, in run_cmd
**dict((k, getattr(options, k, None)) for k in kwarg)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/command.py", line 254, in upgrade
script.run_env()
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/script/base.py", line 425, in run_env
util.load_python_file(self.dir, 'env.py')
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 81, in load_python_file
module = load_module_py(module_id, path)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/util/compat.py", line 141, in load_module_py
mod = imp.load_source(module_id, path, fp)
File "alembic/env.py", line 70, in <module>
run_migrations_online()
File "alembic/env.py", line 65, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/runtime/environment.py", line 836, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/runtime/migration.py", line 330, in run_migrations
step.migration_fn(**kw)
File "/home/pi/Mycodo/databases/alembic/versions/8b36095c6cf9_add_math_type_input_verification.py", line 27, in upgrade
batch_op.add_column(sa.Column('pressure_pa_measure', sa.FLOAT))
File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/operations/base.py", line 300, in batch_alter_table
impl.flush()
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/operations/batch.py", line 57, in flush
fn(*arg, **kw)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/ddl/impl.py", line 172, in add_column
self._exec(base.AddColumn(table_name, column, schema=schema))
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/alembic/ddl/impl.py", line 118, in _exec
return conn.execute(construct, *multiparams, **params)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 948, in execute
return meth(self, multiparams, params)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1009, in _execute_ddl
compiled
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
context)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
exc_info
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/home/pi/Mycodo/env/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) duplicate column name: max_difference [SQL: u'ALTER TABLE math ADD COLUMN max_difference FLOAT']
We have to go through each one until we get it right. Only a few more to try:
cd ~/Mycodo/databases
~/Mycodo/env/bin/alembic stamp 8b36095c6cf9
~/Mycodo/env/bin/alembic upgrade head
It worked, I can access all pages now, thank!
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running stamp_revision b9712d4ec64e -> 8b36095c6cf9
pi@raspberrypi:~/Mycodo/databases $ ~/Mycodo/env/bin/alembic upgrade head
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade 8b36095c6cf9 -> d36de7e4e477, Add math_id option to conditionals
INFO [alembic.runtime.migration] Running upgrade d36de7e4e477 -> 41fbe7fcc8b0, Add decimal places option to LCD lines
pi@raspberrypi:~/Mycodo/databases $
Nice. It should now be working.
It worked, I can access all pages now, thank!
Ah, I must have missed this when I made my reply. Good to hear. This is a rather bad bug in the database upgrade system (alembic). I'm still scratching my head as to whether I've fixed it.
Mycodo Issue Report:
Problem Description
Please list: Error 1: During update there was an error, the command suggested didn't work (command unknown). See error code 1 below. However, the daemon works and I can access the UI.
Error 2: After update, when I try to access certain pages such as Input, Output and Math I get the 500 internal server error, see error code 2 below.
Errors
Error 1 (during update):