MaxKb更换了conf目录下的maxkb.env文件的数据库名后执行mkctl reload失败

替换的maxkb.env主要是修改了哪些内容呢?
1、可以把maxkb.env内容发出来看一下。
2、可以检查两个容器是否有报错日志。

已经安装了之后再修改数据库名?虽然不知道为什么要这么做,但这样的话逻辑上肯定是有问题的的,起码pgsql中并没有这个修改后的数据库,肯定会报错了。

改了这里

想看看能不能把maxkb数据库的东西备份到另一个数据库里面,能不能用,pgsql里面是有新数据库的

关键是这个新的数据库是否已经有原来库的相同数据了呢?可以用docker logs -f maxkb --tail 200看一下容器的日志。

执行mkctl reload之后日志是这样的

Building prefix dict from the default dictionary …
DEBUG:jieba:Building prefix dict from the default dictionary …
Loading model from cache /tmp/jieba.cache
DEBUG:jieba:Loading model from cache /tmp/jieba.cache
Loading model cost 0.972 seconds.
DEBUG:jieba:Loading model cost 0.972 seconds.
Prefix dict has been built successfully.
DEBUG:jieba:Prefix dict has been built successfully.
Operations to perform:
Apply all migrations: application, contenttypes, dataset, django_apscheduler, django_celery_beat, embedding, function_lib, setting, users
Running migrations:
2024-10-14 11:41:39 [schema DEBUG] CREATE TABLE “embedding” (“id” varchar(128) NOT NULL PRIMARY KEY, “source_id” varchar(128) NOT NULL, “source_type” varchar(5) NOT NULL, “is_active” boolean NOT NULL, “embedding” vector NOT NULL, “meta” jsonb NOT NULL, “dataset_id” uuid NOT NULL, “document_id” uuid NOT NULL, “paragraph_id” uuid NOT NULL); (params None)
ERROR:root:Perform migrate failed, exit
Traceback (most recent call last):
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 87, in _execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors. DuplicateTable: relation “embedding” already exists

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

Traceback (most recent call last):
File “/opt/maxkb/app/main.py”, line 40, in perform_db_migrate
management.call_command(‘migrate’)
File “/opt/py3/lib/python3.11/site-packages/django/core/management/init.py”, line 194, in call_command
return command. execute(*args, **defaults)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/core/management/base.py”, line 458, in execute
output = self. handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/core/management/base.py”, line 106, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/core/management/commands/migrate.py”, line 356, in handle
post_migrate_state = executor.migrate(
^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/migrations/executor.py”, line 135, in migrate
state = self._migrate_all_forwards(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/migrations/executor.py”, line 167, in _migrate_all_forwards
state = self.apply_migration(
^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/migrations/executor.py”, line 252, in apply_migration
state = migration. apply(state, schema_editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/migrations/migration.py”, line 132, in apply
operation.database_forwards(
File “/opt/py3/lib/python3.11/site-packages/django/db/migrations/operations/models.py”, line 96, in database_forwards
schema_editor.create_model(model)
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/base/schema.py”, line 451, in create_model
self. execute(sql, params or None)
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/postgresql/schema.py”, line 45, in execute
return super(). execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/base/schema.py”, line 201, in execute
cursor. execute(sql, params)
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 67, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 84, in _execute
with self.db.wrap_database_errors:
File “/opt/py3/lib/python3.11/site-packages/django/db/utils.py”, line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File “/opt/py3/lib/python3.11/site-packages/django/db/backends/utils.py”, line 87, in _execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.ProgrammingError: relation “embedding” already exists

你应该只是新建了一个库,但是这个库里还没有任何表数据吧?