Trying to update my database. idm field is not being added in the aime_card table #156

Closed
opened 2024-06-22 13:02:55 +00:00 by Kayori · 20 comments
Contributor

So i tried running python dbutils.py upgrade and yet the new idm field in aime_card is not being added. Is there another way to upgrade the database?

So i tried running python dbutils.py upgrade and yet the new idm field in aime_card is not being added. Is there another way to upgrade the database?
Owner

what do you mean by not being added? Is the chip_id column also not being added?

what do you mean by not being added? Is the chip_id column also not being added?
Author
Contributor

Yes. Both not being added to my existing database.

Yes. Both not being added to my existing database.
Owner

Sounds like the upgrade script isn't running. Does the file 48f4acc43a7e_card_add_idm_chip_id.py exist in core/data/alembic/versions?

Sounds like the upgrade script isn't running. Does the file `48f4acc43a7e_card_add_idm_chip_id.py` exist in `core/data/alembic/versions`?
Author
Contributor

just checked inside the docker container and yes the file does exist

just checked inside the docker container and yes the file does exist
Owner

what's the output if you run python dbutils.py upgrade?

what's the output if you run `python dbutils.py upgrade`?
Author
Contributor

INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.

INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Owner

and you're certain you have core.yaml configured correctly? I can't reproduce this issue at all.

and you're certain you have core.yaml configured correctly? I can't reproduce this issue at all.
Author
Contributor

i think. Games connected fine and could login before the idm commit. Now when trying to login it complains about those 2 fields not being found. So maybe something went wrong trying to migratie to the idm migration

i think. Games connected fine and could login before the idm commit. Now when trying to login it complains about those 2 fields not being found. So maybe something went wrong trying to migratie to the idm migration
Owner

hmmmm, what is the value of the version_num column in the alembic_version table?

hmmmm, what is the value of the `version_num` column in the `alembic_version` table?
Author
Contributor

it says 48f4acc43a7e

it says 48f4acc43a7e
Owner

Try downgrading with python dbutils.py downgrade -v 1e150d16ab6b and then upgrading again.

Try downgrading with `python dbutils.py downgrade -v 1e150d16ab6b` and then upgrading again.
Author
Contributor

That gives :

INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade 48f4acc43a7e -> 1e150d16ab6b, card_add_idm_chip_id
Traceback (most recent call last):
  File "/app/dbutils.py", line 55, in <module>
    data.schema_downgrade(args.version)
  File "/app/core/data/database.py", line 125, in schema_downgrade
    self.__alembic_cmd(
  File "/app/core/data/database.py", line 94, in __alembic_cmd
    alembic.config.main(argv=alembicArgs)
  File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 641, in main
    CommandLine(prog=prog).main(argv=argv)
  File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 631, in main
    self.run_cmd(cfg, options)
  File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 608, in run_cmd
    fn(
  File "/usr/local/lib/python3.9/site-packages/alembic/command.py", line 449, in downgrade
    script.run_env()
  File "/usr/local/lib/python3.9/site-packages/alembic/script/base.py", line 583, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/usr/local/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
  File "/usr/local/lib/python3.9/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 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "./env.py", line 81, in <module>
    run_migrations_online()
  File "./env.py", line 76, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/usr/local/lib/python3.9/site-packages/alembic/runtime/environment.py", line 948, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/usr/local/lib/python3.9/site-packages/alembic/runtime/migration.py", line 627, in run_migrations
    step.migration_fn(**kw)
  File "/app/core/data/alembic/versions/48f4acc43a7e_card_add_idm_chip_id.py", line 38, in downgrade
    op.drop_constraint(None, 'aime_card', type_='unique')
  File "<string>", line 8, in drop_constraint
  File "<string>", line 3, in drop_constraint
  File "/usr/local/lib/python3.9/site-packages/alembic/operations/ops.py", line 222, in drop_constraint
    return operations.invoke(op)
  File "/usr/local/lib/python3.9/site-packages/alembic/operations/base.py", line 445, in invoke
    return fn(self, operation)
  File "/usr/local/lib/python3.9/site-packages/alembic/operations/toimpl.py", line 201, in drop_constraint
    operations.impl.drop_constraint(
  File "/usr/local/lib/python3.9/site-packages/alembic/ddl/mysql.py", line 157, in drop_constraint
    super().drop_constraint(const)
  File "/usr/local/lib/python3.9/site-packages/alembic/ddl/impl.py", line 350, in drop_constraint
    self._exec(schema.DropConstraint(const))
  File "/usr/local/lib/python3.9/site-packages/alembic/ddl/impl.py", line 207, in _exec
    return conn.execute(construct, multiparams)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1380, in execute
    return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection
    return connection._execute_ddl(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1469, in _execute_ddl
    compiled = ddl.compile(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/elements.py", line 503, in compile
    return self._compiler(dialect, **kw)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 32, in _compiler
    return dialect.ddl_compiler(dialect, self, **kw)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/compiler.py", line 464, in __init__
    self.string = self.process(self.statement, **compile_kwargs)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/compiler.py", line 499, in process
    return obj._compiler_dispatch(self, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/ext/compiler.py", line 548, in <lambda>
    lambda *arg, **kw: existing(*arg, **kw),
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/ext/compiler.py", line 604, in __call__
    expr = fn(element, compiler, **kw)
  File "/usr/local/lib/python3.9/site-packages/alembic/ddl/mysql.py", line 455, in _mysql_drop_constraint
    return compiler.visit_drop_constraint(element)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/base.py", line 1953, in visit_drop_constraint
    const = self.preparer.format_constraint(constraint)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/compiler.py", line 5521, in format_constraint
    return self.truncate_and_render_constraint_name(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/compiler.py", line 5545, in truncate_and_render_constraint_name
    return self._truncate_and_render_maxlen_name(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/compiler.py", line 5554, in _truncate_and_render_maxlen_name
    self.dialect.validate_identifier(name)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 590, in validate_identifier
    if len(ident) > self.max_identifier_length:
TypeError: object of type 'NoneType' has no len()```
That gives : ```INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Running downgrade 48f4acc43a7e -> 1e150d16ab6b, card_add_idm_chip_id Traceback (most recent call last): File "/app/dbutils.py", line 55, in <module> data.schema_downgrade(args.version) File "/app/core/data/database.py", line 125, in schema_downgrade self.__alembic_cmd( File "/app/core/data/database.py", line 94, in __alembic_cmd alembic.config.main(argv=alembicArgs) File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 641, in main CommandLine(prog=prog).main(argv=argv) File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 631, in main self.run_cmd(cfg, options) File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 608, in run_cmd fn( File "/usr/local/lib/python3.9/site-packages/alembic/command.py", line 449, in downgrade script.run_env() File "/usr/local/lib/python3.9/site-packages/alembic/script/base.py", line 583, in run_env util.load_python_file(self.dir, "env.py") File "/usr/local/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file module = load_module_py(module_id, path) File "/usr/local/lib/python3.9/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 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "./env.py", line 81, in <module> run_migrations_online() File "./env.py", line 76, in run_migrations_online context.run_migrations() File "<string>", line 8, in run_migrations File "/usr/local/lib/python3.9/site-packages/alembic/runtime/environment.py", line 948, in run_migrations self.get_context().run_migrations(**kw) File "/usr/local/lib/python3.9/site-packages/alembic/runtime/migration.py", line 627, in run_migrations step.migration_fn(**kw) File "/app/core/data/alembic/versions/48f4acc43a7e_card_add_idm_chip_id.py", line 38, in downgrade op.drop_constraint(None, 'aime_card', type_='unique') File "<string>", line 8, in drop_constraint File "<string>", line 3, in drop_constraint File "/usr/local/lib/python3.9/site-packages/alembic/operations/ops.py", line 222, in drop_constraint return operations.invoke(op) File "/usr/local/lib/python3.9/site-packages/alembic/operations/base.py", line 445, in invoke return fn(self, operation) File "/usr/local/lib/python3.9/site-packages/alembic/operations/toimpl.py", line 201, in drop_constraint operations.impl.drop_constraint( File "/usr/local/lib/python3.9/site-packages/alembic/ddl/mysql.py", line 157, in drop_constraint super().drop_constraint(const) File "/usr/local/lib/python3.9/site-packages/alembic/ddl/impl.py", line 350, in drop_constraint self._exec(schema.DropConstraint(const)) File "/usr/local/lib/python3.9/site-packages/alembic/ddl/impl.py", line 207, in _exec return conn.execute(construct, multiparams) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1380, in execute return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection return connection._execute_ddl( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1469, in _execute_ddl compiled = ddl.compile( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/elements.py", line 503, in compile return self._compiler(dialect, **kw) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 32, in _compiler return dialect.ddl_compiler(dialect, self, **kw) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/compiler.py", line 464, in __init__ self.string = self.process(self.statement, **compile_kwargs) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/compiler.py", line 499, in process return obj._compiler_dispatch(self, **kwargs) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/ext/compiler.py", line 548, in <lambda> lambda *arg, **kw: existing(*arg, **kw), File "/usr/local/lib/python3.9/site-packages/sqlalchemy/ext/compiler.py", line 604, in __call__ expr = fn(element, compiler, **kw) File "/usr/local/lib/python3.9/site-packages/alembic/ddl/mysql.py", line 455, in _mysql_drop_constraint return compiler.visit_drop_constraint(element) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/base.py", line 1953, in visit_drop_constraint const = self.preparer.format_constraint(constraint) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/compiler.py", line 5521, in format_constraint return self.truncate_and_render_constraint_name( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/compiler.py", line 5545, in truncate_and_render_constraint_name return self._truncate_and_render_maxlen_name( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/compiler.py", line 5554, in _truncate_and_render_maxlen_name self.dialect.validate_identifier(name) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 590, in validate_identifier if len(ident) > self.max_identifier_length: TypeError: object of type 'NoneType' has no len()```
Owner

Whoops, this was a bug on my part, please pull latest develop and try running the downgrade again.

Whoops, this was a bug on my part, please pull latest develop and try running the downgrade again.
Author
Contributor

Can't drop index

/app# python dbutils.py downgrade -v 1e150d16ab6b
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running downgrade 48f4acc43a7e -> 1e150d16ab6b, card_add_idm_chip_id
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 179, in execute
res = self._query(mogrified_query)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 330, in _query
db.query(q)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 261, in query
_mysql.connection.query(self, query)
MySQLdb.OperationalError: (1091, "Can't DROP INDEX chip_id; check that it exists")

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

Traceback (most recent call last):
File "/app/dbutils.py", line 55, in
data.schema_downgrade(args.version)
File "/app/core/data/database.py", line 125, in schema_downgrade
self.__alembic_cmd(
File "/app/core/data/database.py", line 94, in __alembic_cmd
alembic.config.main(argv=alembicArgs)
File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 641, in main
CommandLine(prog=prog).main(argv=argv)
File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 631, in main
self.run_cmd(cfg, options)
File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 608, in run_cmd
fn(
File "/usr/local/lib/python3.9/site-packages/alembic/command.py", line 449, in downgrade
script.run_env()
File "/usr/local/lib/python3.9/site-packages/alembic/script/base.py", line 583, in run_env
util.load_python_file(self.dir, "env.py")
File "/usr/local/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
module = load_module_py(module_id, path)
File "/usr/local/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "", line 850, in exec_module
File "", line 228, in call_with_frames_removed
File "./env.py", line 81, in
run_migrations_online()
File "./env.py", line 76, in run_migrations_online
context.run_migrations()
File "", line 8, in run_migrations
File "/usr/local/lib/python3.9/site-packages/alembic/runtime/environment.py", line 948, in run_migrations
self.get_context().run_migrations(**kw)
File "/usr/local/lib/python3.9/site-packages/alembic/runtime/migration.py", line 627, in run_migrations
step.migration_fn(**kw)
File "/app/core/data/alembic/versions/48f4acc43a7e_card_add_idm_chip_id.py", line 38, in downgrade
op.drop_constraint("chip_id", 'aime_card', type
='unique')
File "", line 8, in drop_constraint
File "", line 3, in drop_constraint
File "/usr/local/lib/python3.9/site-packages/alembic/operations/ops.py", line 222, in drop_constraint
return operations.invoke(op)
File "/usr/local/lib/python3.9/site-packages/alembic/operations/base.py", line 445, in invoke
return fn(self, operation)
File "/usr/local/lib/python3.9/site-packages/alembic/operations/toimpl.py", line 201, in drop_constraint
operations.impl.drop_constraint(
File "/usr/local/lib/python3.9/site-packages/alembic/ddl/mysql.py", line 157, in drop_constraint
super().drop_constraint(const)
File "/usr/local/lib/python3.9/site-packages/alembic/ddl/impl.py", line 350, in drop_constraint
self._exec(schema.DropConstraint(const))
File "/usr/local/lib/python3.9/site-packages/alembic/ddl/impl.py", line 207, in _exec
return conn.execute(construct, multiparams)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1380, in execute
return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection
return connection._execute_ddl(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1472, in _execute_ddl
ret = self._execute_context(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context
self.handle_dbapi_exception(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2124, in handle_dbapi_exception
util.raise
(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 211, in raise

raise exception
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 179, in execute
res = self._query(mogrified_query)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 330, in _query
db.query(q)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 261, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1091, "Can't DROP INDEX chip_id; check that it exists")
[SQL: ALTER TABLE aime_card DROP INDEX chip_id]
(Background on this error at: https://sqlalche.me/e/14/e3q8)

Can't drop index /app# python dbutils.py downgrade -v 1e150d16ab6b INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Running downgrade 48f4acc43a7e -> 1e150d16ab6b, card_add_idm_chip_id Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context self.dialect.do_execute( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 179, in execute res = self._query(mogrified_query) File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 330, in _query db.query(q) File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 261, in query _mysql.connection.query(self, query) MySQLdb.OperationalError: (1091, "Can't DROP INDEX `chip_id`; check that it exists") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/dbutils.py", line 55, in <module> data.schema_downgrade(args.version) File "/app/core/data/database.py", line 125, in schema_downgrade self.__alembic_cmd( File "/app/core/data/database.py", line 94, in __alembic_cmd alembic.config.main(argv=alembicArgs) File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 641, in main CommandLine(prog=prog).main(argv=argv) File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 631, in main self.run_cmd(cfg, options) File "/usr/local/lib/python3.9/site-packages/alembic/config.py", line 608, in run_cmd fn( File "/usr/local/lib/python3.9/site-packages/alembic/command.py", line 449, in downgrade script.run_env() File "/usr/local/lib/python3.9/site-packages/alembic/script/base.py", line 583, in run_env util.load_python_file(self.dir, "env.py") File "/usr/local/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file module = load_module_py(module_id, path) File "/usr/local/lib/python3.9/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 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "./env.py", line 81, in <module> run_migrations_online() File "./env.py", line 76, in run_migrations_online context.run_migrations() File "<string>", line 8, in run_migrations File "/usr/local/lib/python3.9/site-packages/alembic/runtime/environment.py", line 948, in run_migrations self.get_context().run_migrations(**kw) File "/usr/local/lib/python3.9/site-packages/alembic/runtime/migration.py", line 627, in run_migrations step.migration_fn(**kw) File "/app/core/data/alembic/versions/48f4acc43a7e_card_add_idm_chip_id.py", line 38, in downgrade op.drop_constraint("chip_id", 'aime_card', type_='unique') File "<string>", line 8, in drop_constraint File "<string>", line 3, in drop_constraint File "/usr/local/lib/python3.9/site-packages/alembic/operations/ops.py", line 222, in drop_constraint return operations.invoke(op) File "/usr/local/lib/python3.9/site-packages/alembic/operations/base.py", line 445, in invoke return fn(self, operation) File "/usr/local/lib/python3.9/site-packages/alembic/operations/toimpl.py", line 201, in drop_constraint operations.impl.drop_constraint( File "/usr/local/lib/python3.9/site-packages/alembic/ddl/mysql.py", line 157, in drop_constraint super().drop_constraint(const) File "/usr/local/lib/python3.9/site-packages/alembic/ddl/impl.py", line 350, in drop_constraint self._exec(schema.DropConstraint(const)) File "/usr/local/lib/python3.9/site-packages/alembic/ddl/impl.py", line 207, in _exec return conn.execute(construct, multiparams) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1380, in execute return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection return connection._execute_ddl( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1472, in _execute_ddl ret = self._execute_context( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context self._handle_dbapi_exception( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2124, in _handle_dbapi_exception util.raise_( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ raise exception File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context self.dialect.do_execute( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 179, in execute res = self._query(mogrified_query) File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 330, in _query db.query(q) File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 261, in query _mysql.connection.query(self, query) sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1091, "Can't DROP INDEX `chip_id`; check that it exists") [SQL: ALTER TABLE aime_card DROP INDEX chip_id] (Background on this error at: https://sqlalche.me/e/14/e3q8)
Author
Contributor

i put version_num in alembic_version to 1e150d16ab6b now upgrading to idm and chip_id are added now stuck on the next migration with sao one.

i put version_num in alembic_version to 1e150d16ab6b now upgrading to idm and chip_id are added now stuck on the next migration with sao one.
Author
Contributor

so what im going to do is create a new database and insert all my data into it but now with a fresh db i get

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 261, in query
    _mysql.connection.query(self, query)
MySQLdb.OperationalError: (1005, 'Can\'t create table `aime`.`sao_hero_log_data` (errno: 150 "Foreign key constraint is incorrectly formed")')

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

Traceback (most recent call last):
  File "/app/dbutils.py", line 46, in <module>
    data.create_database()
  File "/app/core/data/database.py", line 99, in create_database
    metadata.create_all(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 4930, in create_all
    bind._run_ddl_visitor(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3228, in _run_ddl_visitor
    conn._run_ddl_visitor(visitorcallable, element, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2211, in _run_ddl_visitor
    visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single
    return meth(obj, **kw)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 851, in visit_metadata
    self.traverse_single(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single
    return meth(obj, **kw)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 895, in visit_table
    self.connection.execute(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1380, in execute
    return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection
    return connection._execute_ddl(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1472, in _execute_ddl
    ret = self._execute_context(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context
    self._handle_dbapi_exception(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2124, in _handle_dbapi_exception
    util.raise_(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
  File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 261, in query
    _mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1005, 'Can\'t create table `aime`.`sao_hero_log_data` (errno: 150 "Foreign key constraint is incorrectly formed")')
[SQL:
CREATE TABLE sao_hero_log_data (
        id INTEGER NOT NULL AUTO_INCREMENT,
        user INTEGER NOT NULL,
        hero_log_id BIGINT NOT NULL,
        log_level INTEGER NOT NULL,
        log_exp INTEGER NOT NULL,
        main_weapon BIGINT,
        sub_equipment BIGINT,
        skill_slot1_skill_id BIGINT,
        skill_slot2_skill_id BIGINT,
        skill_slot3_skill_id BIGINT,
        skill_slot4_skill_id BIGINT,
        skill_slot5_skill_id BIGINT,
        max_level_extend_num INTEGER NOT NULL DEFAULT '0',
        is_awakenable BOOL NOT NULL DEFAULT '0',
        awakening_stage INTEGER NOT NULL DEFAULT '0',
        awakening_exp INTEGER NOT NULL DEFAULT '0',
        is_shop_purchase BOOL NOT NULL DEFAULT '0',
        is_protect BOOL NOT NULL DEFAULT '0',
        property1_property_id BIGINT NOT NULL DEFAULT '2',
        property1_value1 INTEGER NOT NULL DEFAULT '0',
        property1_value2 INTEGER NOT NULL DEFAULT '0',
        property2_property_id BIGINT NOT NULL DEFAULT '2',
        property2_value1 INTEGER NOT NULL DEFAULT '0',
        property2_value2 INTEGER NOT NULL DEFAULT '0',
        property3_property_id BIGINT NOT NULL DEFAULT '2',
        property3_value1 INTEGER NOT NULL DEFAULT '0',
        property3_value2 INTEGER NOT NULL DEFAULT '0',
        property4_property_id BIGINT NOT NULL DEFAULT '2',
        property4_value1 INTEGER NOT NULL DEFAULT '0',
        property4_value2 INTEGER NOT NULL DEFAULT '0',
        converted_card_num INTEGER NOT NULL DEFAULT '0',
        get_date TIMESTAMP NOT NULL DEFAULT now(),
        PRIMARY KEY (id),
        CONSTRAINT sao_hero_log_data_uk UNIQUE (user, hero_log_id),
        FOREIGN KEY(user) REFERENCES aime_user (id) ON DELETE cascade ON UPDATE cascade,
        FOREIGN KEY(hero_log_id) REFERENCES sao_static_hero_list (`HeroLogId`) ON DELETE cascade ON UPDATE cascade,
        FOREIGN KEY(main_weapon) REFERENCES sao_equipment_data (id) ON DELETE set null ON UPDATE set null,
        FOREIGN KEY(sub_equipment) REFERENCES sao_equipment_data (id) ON DELETE set null ON UPDATE set null,
        FOREIGN KEY(skill_slot1_skill_id) REFERENCES sao_static_skill (`SkillId`) ON DELETE set null ON UPDATE set null,

        FOREIGN KEY(skill_slot2_skill_id) REFERENCES sao_static_skill (`SkillId`) ON DELETE set null ON UPDATE set null,

        FOREIGN KEY(skill_slot3_skill_id) REFERENCES sao_static_skill (`SkillId`) ON DELETE set null ON UPDATE set null,

        FOREIGN KEY(skill_slot4_skill_id) REFERENCES sao_static_skill (`SkillId`) ON DELETE set null ON UPDATE set null,

        FOREIGN KEY(skill_slot5_skill_id) REFERENCES sao_static_skill (`SkillId`) ON DELETE set null ON UPDATE set null,

        FOREIGN KEY(property1_property_id) REFERENCES sao_static_property (`PropertyId`) ON DELETE cascade ON UPDATE cascade,
        FOREIGN KEY(property2_property_id) REFERENCES sao_static_property (`PropertyId`) ON DELETE cascade ON UPDATE cascade,
        FOREIGN KEY(property3_property_id) REFERENCES sao_static_property (`PropertyId`) ON DELETE cascade ON UPDATE cascade,
        FOREIGN KEY(property4_property_id) REFERENCES sao_static_property (`PropertyId`) ON DELETE cascade ON UPDATE cascade
)CHARSET=utf8mb4

]
(Background on this error at: https://sqlalche.me/e/14/e3q8)``
so what im going to do is create a new database and insert all my data into it but now with a fresh db i get ````[2024-06-25 17:29:58] INFO | Database | Creating databases... Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context self.dialect.do_execute( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 179, in execute res = self._query(mogrified_query) File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 330, in _query db.query(q) File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 261, in query _mysql.connection.query(self, query) MySQLdb.OperationalError: (1005, 'Can\'t create table `aime`.`sao_hero_log_data` (errno: 150 "Foreign key constraint is incorrectly formed")') The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/dbutils.py", line 46, in <module> data.create_database() File "/app/core/data/database.py", line 99, in create_database metadata.create_all( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 4930, in create_all bind._run_ddl_visitor( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3228, in _run_ddl_visitor conn._run_ddl_visitor(visitorcallable, element, **kwargs) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2211, in _run_ddl_visitor visitorcallable(self.dialect, self, **kwargs).traverse_single(element) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single return meth(obj, **kw) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 851, in visit_metadata self.traverse_single( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single return meth(obj, **kw) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 895, in visit_table self.connection.execute( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1380, in execute return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection return connection._execute_ddl( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1472, in _execute_ddl ret = self._execute_context( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context self._handle_dbapi_exception( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2124, in _handle_dbapi_exception util.raise_( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ raise exception File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context self.dialect.do_execute( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 179, in execute res = self._query(mogrified_query) File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 330, in _query db.query(q) File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 261, in query _mysql.connection.query(self, query) sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1005, 'Can\'t create table `aime`.`sao_hero_log_data` (errno: 150 "Foreign key constraint is incorrectly formed")') [SQL: CREATE TABLE sao_hero_log_data ( id INTEGER NOT NULL AUTO_INCREMENT, user INTEGER NOT NULL, hero_log_id BIGINT NOT NULL, log_level INTEGER NOT NULL, log_exp INTEGER NOT NULL, main_weapon BIGINT, sub_equipment BIGINT, skill_slot1_skill_id BIGINT, skill_slot2_skill_id BIGINT, skill_slot3_skill_id BIGINT, skill_slot4_skill_id BIGINT, skill_slot5_skill_id BIGINT, max_level_extend_num INTEGER NOT NULL DEFAULT '0', is_awakenable BOOL NOT NULL DEFAULT '0', awakening_stage INTEGER NOT NULL DEFAULT '0', awakening_exp INTEGER NOT NULL DEFAULT '0', is_shop_purchase BOOL NOT NULL DEFAULT '0', is_protect BOOL NOT NULL DEFAULT '0', property1_property_id BIGINT NOT NULL DEFAULT '2', property1_value1 INTEGER NOT NULL DEFAULT '0', property1_value2 INTEGER NOT NULL DEFAULT '0', property2_property_id BIGINT NOT NULL DEFAULT '2', property2_value1 INTEGER NOT NULL DEFAULT '0', property2_value2 INTEGER NOT NULL DEFAULT '0', property3_property_id BIGINT NOT NULL DEFAULT '2', property3_value1 INTEGER NOT NULL DEFAULT '0', property3_value2 INTEGER NOT NULL DEFAULT '0', property4_property_id BIGINT NOT NULL DEFAULT '2', property4_value1 INTEGER NOT NULL DEFAULT '0', property4_value2 INTEGER NOT NULL DEFAULT '0', converted_card_num INTEGER NOT NULL DEFAULT '0', get_date TIMESTAMP NOT NULL DEFAULT now(), PRIMARY KEY (id), CONSTRAINT sao_hero_log_data_uk UNIQUE (user, hero_log_id), FOREIGN KEY(user) REFERENCES aime_user (id) ON DELETE cascade ON UPDATE cascade, FOREIGN KEY(hero_log_id) REFERENCES sao_static_hero_list (`HeroLogId`) ON DELETE cascade ON UPDATE cascade, FOREIGN KEY(main_weapon) REFERENCES sao_equipment_data (id) ON DELETE set null ON UPDATE set null, FOREIGN KEY(sub_equipment) REFERENCES sao_equipment_data (id) ON DELETE set null ON UPDATE set null, FOREIGN KEY(skill_slot1_skill_id) REFERENCES sao_static_skill (`SkillId`) ON DELETE set null ON UPDATE set null, FOREIGN KEY(skill_slot2_skill_id) REFERENCES sao_static_skill (`SkillId`) ON DELETE set null ON UPDATE set null, FOREIGN KEY(skill_slot3_skill_id) REFERENCES sao_static_skill (`SkillId`) ON DELETE set null ON UPDATE set null, FOREIGN KEY(skill_slot4_skill_id) REFERENCES sao_static_skill (`SkillId`) ON DELETE set null ON UPDATE set null, FOREIGN KEY(skill_slot5_skill_id) REFERENCES sao_static_skill (`SkillId`) ON DELETE set null ON UPDATE set null, FOREIGN KEY(property1_property_id) REFERENCES sao_static_property (`PropertyId`) ON DELETE cascade ON UPDATE cascade, FOREIGN KEY(property2_property_id) REFERENCES sao_static_property (`PropertyId`) ON DELETE cascade ON UPDATE cascade, FOREIGN KEY(property3_property_id) REFERENCES sao_static_property (`PropertyId`) ON DELETE cascade ON UPDATE cascade, FOREIGN KEY(property4_property_id) REFERENCES sao_static_property (`PropertyId`) ON DELETE cascade ON UPDATE cascade )CHARSET=utf8mb4 ] (Background on this error at: https://sqlalche.me/e/14/e3q8)``
Owner

Fixing that now, apologies

Fixing that now, apologies
Owner

This has been fixed by c13b096190
Please try again.

This has been fixed by c13b096190093e2d56f5dc2060293c8f91fec239 Please try again.
Author
Contributor

Tested again with new db. Works now thanks. Time to reimport my data

Tested again with new db. Works now thanks. Time to reimport my data
Owner

sounds good. Since it seems that you're good to go on this specific issue, Ill close this

sounds good. Since it seems that you're good to go on this specific issue, Ill close this
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Hay1tsme/artemis#156
No description provided.