@@ -1896,3 +1896,210 @@ COMMENT ON TABLE nexent.user_cas_session_t IS 'Server-side session records for C
18961896COMMENT ON COLUMN nexent.user_cas_session_t.session_id IS ' JWT sid claim for revocation checks' ;
18971897COMMENT ON COLUMN nexent.user_cas_session_t.cas_user_id IS ' User identifier returned by CAS' ;
18981898COMMENT ON COLUMN nexent.user_cas_session_t.cas_session_index IS ' CAS SessionIndex or service ticket' ;
1899+
1900+ -- Rename params -> config_values, add config_schemas to ag_skill_info_t
1901+ -- Add tenant_id column for multi-tenancy support
1902+ ALTER TABLE nexent .ag_skill_info_t ADD COLUMN IF NOT EXISTS tenant_id VARCHAR (100 );
1903+
1904+ -- Add config_values and config_schemas to ag_skill_info_t
1905+ DO $$
1906+ BEGIN
1907+ IF EXISTS (
1908+ SELECT 1 FROM information_schema .columns
1909+ WHERE table_schema = ' nexent'
1910+ AND table_name = ' ag_skill_info_t'
1911+ AND column_name = ' params'
1912+ ) THEN
1913+ ALTER TABLE nexent .ag_skill_info_t RENAME COLUMN params TO config_values;
1914+ END IF;
1915+ END $$;
1916+ ALTER TABLE nexent .ag_skill_info_t ADD COLUMN IF NOT EXISTS config_schemas JSON;
1917+
1918+ -- Comments for ag_skill_info_t columns
1919+ COMMENT ON COLUMN nexent.ag_skill_info_t.tenant_id IS ' Tenant ID for multi-tenancy. NULL for pre-existing skills.' ;
1920+ COMMENT ON COLUMN nexent.ag_skill_info_t.config_values IS ' Runtime parameter values from config/config.yaml' ;
1921+ COMMENT ON COLUMN nexent.ag_skill_info_t.config_schemas IS ' Parameter metadata list from config/schema.yaml' ;
1922+
1923+ -- Add config_values and config_schemas to ag_skill_instance_t
1924+ ALTER TABLE nexent .ag_skill_instance_t ADD COLUMN IF NOT EXISTS config_values JSON;
1925+ ALTER TABLE nexent .ag_skill_instance_t ADD COLUMN IF NOT EXISTS config_schemas JSON;
1926+
1927+ -- Comments for ag_skill_instance_t columns
1928+ COMMENT ON COLUMN nexent.ag_skill_instance_t.config_values IS ' Per-agent runtime parameter values from config/config.yaml' ;
1929+ COMMENT ON COLUMN nexent.ag_skill_instance_t.config_schemas IS ' Per-agent parameter schema overrides from config/schema.yaml' ;
1930+
1931+ -- Migration: ASSET_OWNER role permissions and invitation type comment
1932+ -- Date: 2026-05-29
1933+ -- Description: Add ASSET_OWNER role permissions, SU asset-owner invite permissions,
1934+ -- update invitation code_type comment, and ensure ag_skill_info_t.tenant_id exists
1935+ -- Source: commit 15cece97692db2372a978cbdf21b5d5316e79f30 (init.sql)
1936+
1937+ SET search_path TO nexent;
1938+
1939+ BEGIN ;
1940+
1941+ COMMENT ON COLUMN nexent.tenant_invitation_code_t.code_type IS
1942+ ' Invitation code type: ADMIN_INVITE, DEV_INVITE, USER_INVITE, ASSET_OWNER_INVITE' ;
1943+
1944+ INSERT INTO nexent .role_permission_t
1945+ (role_permission_id, user_role, permission_category, permission_type, permission_subtype)
1946+ VALUES
1947+ (188 , ' SU' , ' RESOURCE' , ' INVITE.ASSET_OWNER' , ' CREATE' ),
1948+ (189 , ' SU' , ' RESOURCE' , ' INVITE.ASSET_OWNER' , ' READ' ),
1949+ (190 , ' SU' , ' RESOURCE' , ' INVITE.ASSET_OWNER' , ' UPDATE' ),
1950+ (191 , ' SU' , ' RESOURCE' , ' INVITE.ASSET_OWNER' , ' DELETE' ),
1951+ (192 , ' ASSET_OWNER' , ' VISIBILITY' , ' LEFT_NAV_MENU' , ' /' ),
1952+ (193 , ' ASSET_OWNER' , ' VISIBILITY' , ' LEFT_NAV_MENU' , ' /agents' ),
1953+ (194 , ' ASSET_OWNER' , ' VISIBILITY' , ' LEFT_NAV_MENU' , ' /knowledges' ),
1954+ (195 , ' ASSET_OWNER' , ' VISIBILITY' , ' LEFT_NAV_MENU' , ' /chat' ),
1955+ (196 , ' ASSET_OWNER' , ' VISIBILITY' , ' LEFT_NAV_MENU' , ' /space' ),
1956+ (197 , ' ASSET_OWNER' , ' VISIBILITY' , ' LEFT_NAV_MENU' , ' /market' ),
1957+ (198 , ' ASSET_OWNER' , ' VISIBILITY' , ' LEFT_NAV_MENU' , ' /models' ),
1958+ (199 , ' ASSET_OWNER' , ' RESOURCE' , ' AGENT' , ' CREATE' ),
1959+ (200 , ' ASSET_OWNER' , ' RESOURCE' , ' AGENT' , ' READ' ),
1960+ (201 , ' ASSET_OWNER' , ' RESOURCE' , ' AGENT' , ' UPDATE' ),
1961+ (202 , ' ASSET_OWNER' , ' RESOURCE' , ' AGENT' , ' DELETE' ),
1962+ (203 , ' ASSET_OWNER' , ' RESOURCE' , ' SKILL' , ' CREATE' ),
1963+ (204 , ' ASSET_OWNER' , ' RESOURCE' , ' SKILL' , ' READ' ),
1964+ (205 , ' ASSET_OWNER' , ' RESOURCE' , ' SKILL' , ' UPDATE' ),
1965+ (206 , ' ASSET_OWNER' , ' RESOURCE' , ' SKILL' , ' DELETE' ),
1966+ (207 , ' ASSET_OWNER' , ' RESOURCE' , ' KB' , ' CREATE' ),
1967+ (208 , ' ASSET_OWNER' , ' RESOURCE' , ' KB' , ' READ' ),
1968+ (209 , ' ASSET_OWNER' , ' RESOURCE' , ' KB' , ' UPDATE' ),
1969+ (210 , ' ASSET_OWNER' , ' RESOURCE' , ' KB' , ' DELETE' ),
1970+ (211 , ' ASSET_OWNER' , ' RESOURCE' , ' MCP' , ' CREATE' ),
1971+ (212 , ' ASSET_OWNER' , ' RESOURCE' , ' MCP' , ' READ' ),
1972+ (213 , ' ASSET_OWNER' , ' RESOURCE' , ' MCP' , ' UPDATE' ),
1973+ (214 , ' ASSET_OWNER' , ' RESOURCE' , ' MCP' , ' DELETE' ),
1974+ (215 , ' ASSET_OWNER' , ' RESOURCE' , ' MODEL' , ' CREATE' ),
1975+ (216 , ' ASSET_OWNER' , ' RESOURCE' , ' MODEL' , ' READ' ),
1976+ (217 , ' ASSET_OWNER' , ' RESOURCE' , ' MODEL' , ' UPDATE' ),
1977+ (218 , ' ASSET_OWNER' , ' RESOURCE' , ' MODEL' , ' DELETE' ),
1978+ (219 , ' ASSET_OWNER' , ' RESOURCE' , ' USER.ROLE' , ' READ' ),
1979+ (220 , ' ASSET_OWNER' , ' VISIBILITY' , ' LEFT_NAV_MENU' , ' /users' ),
1980+ (221 , ' SU' , ' VISIBILITY' , ' LEFT_NAV_MENU' , ' /asset-owner-resources' )
1981+ ON CONFLICT (role_permission_id) DO NOTHING;
1982+
1983+ COMMIT ;
1984+
1985+ -- Migration: Add preserve_source_file to knowledge_record_t table
1986+ -- Date: 2026-06-01
1987+ -- Description: Whether to preserve uploaded source documents after vectorization (default: true)
1988+
1989+ ALTER TABLE nexent .knowledge_record_t
1990+ ADD COLUMN IF NOT EXISTS preserve_source_file BOOLEAN NOT NULL DEFAULT true;
1991+
1992+ COMMENT ON COLUMN nexent.knowledge_record_t.preserve_source_file IS ' Whether to preserve uploaded source documents after vectorization' ;
1993+
1994+ -- Migration: Add ag_agent_repository_t table
1995+ -- Date: 2026-06-05
1996+ -- Description: Agent marketplace repository for frozen shareable agent snapshots.
1997+
1998+ SET search_path TO nexent;
1999+
2000+ BEGIN ;
2001+
2002+ CREATE SEQUENCE IF NOT EXISTS nexent .ag_agent_repository_t_agent_repository_id_seq ;
2003+
2004+ CREATE TABLE IF NOT EXISTS nexent .ag_agent_repository_t (
2005+ agent_repository_id BIGINT NOT NULL DEFAULT nextval(' nexent.ag_agent_repository_t_agent_repository_id_seq' ),
2006+ publisher_tenant_id VARCHAR (100 ) NOT NULL ,
2007+ publisher_user_id VARCHAR (100 ) NOT NULL ,
2008+ agent_id INTEGER NOT NULL ,
2009+ source_version_no INTEGER NOT NULL ,
2010+ name VARCHAR (100 ) NOT NULL ,
2011+ display_name VARCHAR (100 ),
2012+ description TEXT ,
2013+ author VARCHAR (100 ),
2014+ category_id INTEGER ,
2015+ tags TEXT [],
2016+ tool_count INTEGER ,
2017+ version_label VARCHAR (100 ),
2018+ agent_info_json JSONB NOT NULL ,
2019+ status VARCHAR (30 ) DEFAULT ' NOT_SHARED' ,
2020+ create_time TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP ,
2021+ update_time TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP ,
2022+ created_by VARCHAR (100 ),
2023+ updated_by VARCHAR (100 ),
2024+ delete_flag VARCHAR (1 ) DEFAULT ' N' ,
2025+ CONSTRAINT ag_agent_repository_t_pkey PRIMARY KEY (agent_repository_id)
2026+ );
2027+
2028+ ALTER SEQUENCE nexent .ag_agent_repository_t_agent_repository_id_seq
2029+ OWNED BY nexent .ag_agent_repository_t .agent_repository_id;
2030+
2031+ ALTER TABLE nexent .ag_agent_repository_t OWNER TO root;
2032+
2033+ COMMENT ON TABLE nexent.ag_agent_repository_t IS ' Agent marketplace repository for frozen shareable agent snapshots' ;
2034+ COMMENT ON COLUMN nexent.ag_agent_repository_t.agent_repository_id IS ' Agent repository listing ID, unique primary key' ;
2035+ COMMENT ON COLUMN nexent.ag_agent_repository_t.publisher_tenant_id IS ' Publisher tenant ID' ;
2036+ COMMENT ON COLUMN nexent.ag_agent_repository_t.publisher_user_id IS ' Publisher user ID' ;
2037+ COMMENT ON COLUMN nexent.ag_agent_repository_t.agent_id IS ' Root agent ID from ag_tenant_agent_t; upsert key with publisher_tenant_id' ;
2038+ COMMENT ON COLUMN nexent.ag_agent_repository_t.source_version_no IS ' Published version number frozen at share time' ;
2039+ COMMENT ON COLUMN nexent.ag_agent_repository_t.name IS ' Root agent programmatic name for display and search' ;
2040+ COMMENT ON COLUMN nexent.ag_agent_repository_t.display_name IS ' Root agent display name' ;
2041+ COMMENT ON COLUMN nexent.ag_agent_repository_t.description IS ' Root agent description' ;
2042+ COMMENT ON COLUMN nexent.ag_agent_repository_t.author IS ' Agent author' ;
2043+ COMMENT ON COLUMN nexent.ag_agent_repository_t.category_id IS ' Optional marketplace category ID' ;
2044+ COMMENT ON COLUMN nexent.ag_agent_repository_t.tags IS ' Marketplace tags' ;
2045+ COMMENT ON COLUMN nexent.ag_agent_repository_t.tool_count IS ' Total tool count across all agents in the bundle (display only)' ;
2046+ COMMENT ON COLUMN nexent.ag_agent_repository_t.version_label IS ' Repository entry version label for display (e.g. v1.0)' ;
2047+ COMMENT ON COLUMN nexent.ag_agent_repository_t.agent_info_json IS ' Frozen ExportAndImportDataFormat snapshot with optional skills' ;
2048+ COMMENT ON COLUMN nexent.ag_agent_repository_t.status IS ' Listing status: NOT_SHARED (未共享) / PENDING_REVIEW (待审核) / REJECTED (审核驳回) / SHARED (已共享)' ;
2049+ COMMENT ON COLUMN nexent.ag_agent_repository_t.create_time IS ' Creation time' ;
2050+ COMMENT ON COLUMN nexent.ag_agent_repository_t.update_time IS ' Update time' ;
2051+ COMMENT ON COLUMN nexent.ag_agent_repository_t.created_by IS ' Creator ID' ;
2052+ COMMENT ON COLUMN nexent.ag_agent_repository_t.updated_by IS ' Updater ID' ;
2053+ COMMENT ON COLUMN nexent.ag_agent_repository_t.delete_flag IS ' Soft delete flag: Y/N' ;
2054+
2055+ CREATE UNIQUE INDEX IF NOT EXISTS uq_agent_repository_tenant_agent_active
2056+ ON nexent .ag_agent_repository_t (publisher_tenant_id, agent_id)
2057+ WHERE delete_flag = ' N' ;
2058+
2059+ CREATE INDEX IF NOT EXISTS idx_agent_repository_publisher_delete
2060+ ON nexent .ag_agent_repository_t (publisher_tenant_id, delete_flag);
2061+
2062+ CREATE INDEX IF NOT EXISTS idx_agent_repository_status_delete
2063+ ON nexent .ag_agent_repository_t (status, delete_flag);
2064+
2065+ CREATE INDEX IF NOT EXISTS idx_agent_repository_name_delete
2066+ ON nexent .ag_agent_repository_t (name, delete_flag);
2067+
2068+ CREATE INDEX IF NOT EXISTS idx_agent_repository_tags_gin
2069+ ON nexent .ag_agent_repository_t USING GIN (tags);
2070+
2071+ CREATE OR REPLACE FUNCTION update_ag_agent_repository_update_time ()
2072+ RETURNS TRIGGER AS $$
2073+ BEGIN
2074+ NEW .update_time = CURRENT_TIMESTAMP ;
2075+ RETURN NEW;
2076+ END;
2077+ $$ LANGUAGE plpgsql;
2078+
2079+ COMMENT ON FUNCTION update_ag_agent_repository_update_time() IS ' Auto-update update_time for ag_agent_repository_t' ;
2080+
2081+ DROP TRIGGER IF EXISTS update_ag_agent_repository_update_time_trigger ON nexent .ag_agent_repository_t ;
2082+ CREATE TRIGGER update_ag_agent_repository_update_time_trigger
2083+ BEFORE UPDATE ON nexent .ag_agent_repository_t
2084+ FOR EACH ROW
2085+ EXECUTE FUNCTION update_ag_agent_repository_update_time();
2086+
2087+ COMMENT ON TRIGGER update_ag_agent_repository_update_time_trigger ON nexent.ag_agent_repository_t IS ' Trigger to maintain update_time' ;
2088+
2089+ COMMIT ;
2090+
2091+ -- Migration: Add selected_agent_version_no to ag_agent_relation_t
2092+ -- Date: 2026-06-09
2093+ -- Description: Pin child agent version on parent-child relations at publish time.
2094+
2095+ SET search_path TO nexent;
2096+
2097+ BEGIN ;
2098+
2099+ ALTER TABLE nexent .ag_agent_relation_t
2100+ ADD COLUMN IF NOT EXISTS selected_agent_version_no INTEGER ;
2101+
2102+ COMMENT ON COLUMN nexent.ag_agent_relation_t.selected_agent_version_no IS
2103+ ' Pinned version of selected_agent_id. NULL = use child current published version at runtime (legacy/draft).' ;
2104+
2105+ COMMIT ;
0 commit comments