diff --git a/backend/database/db_models.py b/backend/database/db_models.py index a3ecb7120..efb401d64 100644 --- a/backend/database/db_models.py +++ b/backend/database/db_models.py @@ -236,7 +236,12 @@ class ToolInstance(TableBase): __table_args__ = {"schema": SCHEMA} tool_instance_id = Column( - Integer, primary_key=True, nullable=False, doc="ID") + Integer, + Sequence("ag_tool_instance_t_tool_instance_id_seq", schema=SCHEMA), + primary_key=True, + nullable=False, + doc="ID" + ) tool_id = Column(Integer, doc="Tenant tool ID") agent_id = Column(Integer, doc="Agent ID") params = Column(JSON, doc="Parameter configuration") @@ -351,7 +356,7 @@ class AgentRelation(TableBase): __tablename__ = "ag_agent_relation_t" __table_args__ = {"schema": SCHEMA} - relation_id = Column(Integer, primary_key=True, autoincrement=True, nullable=False, doc="Relationship ID, primary key") + relation_id = Column(Integer, Sequence("ag_agent_relation_t_relation_id_seq", schema=SCHEMA), primary_key=True, nullable=False, doc="Relationship ID, primary key") selected_agent_id = Column(Integer, primary_key=True, doc="Selected agent ID") parent_agent_id = Column(Integer, doc="Parent agent ID") tenant_id = Column(String(100), doc="Tenant ID") diff --git a/docker/init.sql b/docker/init.sql index 9c3fac948..2462dc63b 100644 --- a/docker/init.sql +++ b/docker/init.sql @@ -380,7 +380,7 @@ WHERE delete_flag = 'N'; -- Create the ag_tool_instance_t table in the nexent schema CREATE TABLE IF NOT EXISTS nexent.ag_tool_instance_t ( - tool_instance_id INTEGER NOT NULL, + tool_instance_id SERIAL NOT NULL, tool_id INTEGER, agent_id INTEGER, params JSON, @@ -564,7 +564,7 @@ COMMENT ON COLUMN nexent.user_tenant_t.delete_flag IS 'Delete flag, Y/N'; -- Create the ag_agent_relation_t table in the nexent schema CREATE TABLE IF NOT EXISTS nexent.ag_agent_relation_t ( - relation_id INTEGER NOT NULL, + relation_id SERIAL NOT NULL, selected_agent_id INTEGER, parent_agent_id INTEGER, tenant_id VARCHAR(100), diff --git a/docker/sql/v1.8.0.2_0302_add_tool_instance_id_seq_and_agent_relation_id_seq.sql b/docker/sql/v1.8.0.2_0302_add_tool_instance_id_seq_and_agent_relation_id_seq.sql new file mode 100644 index 000000000..06fde6435 --- /dev/null +++ b/docker/sql/v1.8.0.2_0302_add_tool_instance_id_seq_and_agent_relation_id_seq.sql @@ -0,0 +1,14 @@ +-- Step 1: Create sequence for auto-increment +CREATE SEQUENCE IF NOT EXISTS "nexent"."ag_tool_instance_t_tool_instance_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +CREATE SEQUENCE IF NOT EXISTS "nexent"."ag_agent_relation_t_relation_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1;