checkout commit 2e2e536414779dd665150b05ae3907f5344c454c from Nov 28 2023
rm -rf auth/ and rm instance/db.sqlite
make env and source env.sh
make run (build db.sqlite from older version)
checkout commit ca529bf1271ce72f315bf728ad9c9aed03b89d02 from Feb 15 2024
rm -rf auth/, keep the instance/db.sqlite from before (as if were a long running db with important data)
make env and source env.sh
make run produces the following error:
make run
running any new database migrations
flask db upgrade
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> aecd1aa869db, blank start
Traceback (most recent call last):
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context
self.dialect.do_execute(
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: table device already exists
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/pavan/Desktop/TeslaCore/auth/bin/flask", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/flask/cli.py", line 1063, in main
cli.main()
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/flask/cli.py", line 357, in decorator
return __ctx.invoke(f, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/flask_migrate/cli.py", line 154, in upgrade
_upgrade(directory, revision, sql, tag, x_arg)
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/flask_migrate/__init__.py", line 111, in wrapped
f(*args, **kwargs)
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/flask_migrate/__init__.py", line 200, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/command.py", line 403, in upgrade
script.run_env()
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/script/base.py", line 583, in run_env
util.load_python_file(self.dir, "env.py")
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
module = load_module_py(module_id, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
spec.loader.exec_module(module) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/pavan/Desktop/TeslaCore/migrations/env.py", line 113, in <module>
run_migrations_online()
File "/home/pavan/Desktop/TeslaCore/migrations/env.py", line 107, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/runtime/environment.py", line 948, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/runtime/migration.py", line 627, in run_migrations
step.migration_fn(**kw)
File "/home/pavan/Desktop/TeslaCore/migrations/versions/aecd1aa869db_blank_start.py", line 21, in upgrade
op.create_table('device',
File "<string>", line 8, in create_table
File "<string>", line 3, in create_table
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/operations/ops.py", line 1311, in create_table
return operations.invoke(op)
^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/operations/base.py", line 445, in invoke
return fn(self, operation)
^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/operations/toimpl.py", line 131, in create_table
operations.impl.create_table(table)
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/ddl/impl.py", line 366, in create_table
self._exec(schema.CreateTable(table))
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/alembic/ddl/impl.py", line 207, in _exec
return conn.execute(construct, multiparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1422, in execute
return meth(
^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/sqlalchemy/sql/ddl.py", line 180, in _execute_on_connection
return connection._execute_ddl(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1533, in _execute_ddl
ret = self._execute_context(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1850, in _execute_context
return self._exec_single_context(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1990, in _exec_single_context
self._handle_dbapi_exception(
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2357, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context
self.dialect.do_execute(
File "/home/pavan/Desktop/TeslaCore/auth/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table device already exists
[SQL:
CREATE TABLE device (
id VARCHAR(36) NOT NULL,
type VARCHAR(7) NOT NULL,
status VARCHAR(12) NOT NULL,
name VARCHAR(100),
created_at DATETIME DEFAULT (CURRENT_TIMESTAMP) NOT NULL,
PRIMARY KEY (id),
UNIQUE (name)
)
]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
make: *** [Makefile:32: run] Error 1
reproduce:
rm -rf auth/
andrm instance/db.sqlite
make env
andsource env.sh
make run
(build db.sqlite from older version)rm -rf auth/
, keep the instance/db.sqlite from before (as if were a long running db with important data)make env
andsource env.sh
make run
produces the following error: