11-- Migration Runner: DID Schema Migration Script
22-- Description: Complete DID database schema setup for the AgentField platform
33-- Created: 2025-01-08
4- --
4+ --
55-- This script creates all necessary tables for the DID (Decentralized Identity) implementation
66-- in the AgentField platform, enabling the transition from file-based to database-backed storage.
77
@@ -13,7 +13,7 @@ CREATE TABLE IF NOT EXISTS schema_migrations (
1313);
1414
1515-- Insert migration records
16- INSERT OR IGNORE INTO schema_migrations (version, description) VALUES
16+ INSERT OR IGNORE INTO schema_migrations (version, description) VALUES
1717 (' 001' , ' Create DID Registry table' ),
1818 (' 002' , ' Create Agent DIDs table' ),
1919 (' 003' , ' Create Component DIDs table' ),
@@ -27,28 +27,28 @@ CREATE INDEX IF NOT EXISTS idx_component_dids_type_exposure ON component_dids(co
2727CREATE INDEX IF NOT EXISTS idx_agent_dids_org_status ON agent_dids(organization_id, status);
2828
2929-- Create triggers for automatic timestamp updates
30- CREATE TRIGGER IF NOT EXISTS update_agent_dids_timestamp
30+ CREATE TRIGGER IF NOT EXISTS update_agent_dids_timestamp
3131 AFTER UPDATE ON agent_dids
3232 FOR EACH ROW
3333 BEGIN
3434 UPDATE agent_dids SET updated_at = CURRENT_TIMESTAMP WHERE did = NEW .did ;
3535 END;
3636
37- CREATE TRIGGER IF NOT EXISTS update_component_dids_timestamp
37+ CREATE TRIGGER IF NOT EXISTS update_component_dids_timestamp
3838 AFTER UPDATE ON component_dids
3939 FOR EACH ROW
4040 BEGIN
4141 UPDATE component_dids SET updated_at = CURRENT_TIMESTAMP WHERE did = NEW .did ;
4242 END;
4343
44- CREATE TRIGGER IF NOT EXISTS update_execution_vcs_timestamp
44+ CREATE TRIGGER IF NOT EXISTS update_execution_vcs_timestamp
4545 AFTER UPDATE ON execution_vcs
4646 FOR EACH ROW
4747 BEGIN
4848 UPDATE execution_vcs SET updated_at = CURRENT_TIMESTAMP WHERE vc_id = NEW .vc_id ;
4949 END;
5050
51- CREATE TRIGGER IF NOT EXISTS update_workflow_vcs_timestamp
51+ CREATE TRIGGER IF NOT EXISTS update_workflow_vcs_timestamp
5252 AFTER UPDATE ON workflow_vcs
5353 FOR EACH ROW
5454 BEGIN
@@ -57,7 +57,7 @@ CREATE TRIGGER IF NOT EXISTS update_workflow_vcs_timestamp
5757
5858-- Create helpful views for DID management
5959CREATE VIEW IF NOT EXISTS did_hierarchy_view AS
60- SELECT
60+ SELECT
6161 dr .organization_id ,
6262 dr .root_did ,
6363 ad .did as agent_did,
@@ -74,7 +74,7 @@ ORDER BY dr.organization_id, ad.agent_node_id, cd.component_type, cd.function_na
7474
7575-- Create view for VC audit trail
7676CREATE VIEW IF NOT EXISTS vc_audit_trail AS
77- SELECT
77+ SELECT
7878 evc .vc_id ,
7979 evc .execution_id ,
8080 evc .workflow_id ,
@@ -91,4 +91,4 @@ LEFT JOIN component_dids issuer ON evc.issuer_did = issuer.did
9191LEFT JOIN component_dids target ON evc .target_did = target .did
9292LEFT JOIN component_dids caller ON evc .caller_did = caller .did
9393LEFT JOIN workflow_vcs wvc ON evc .workflow_id = wvc .workflow_id AND evc .session_id = wvc .session_id
94- ORDER BY evc .created_at DESC ;
94+ ORDER BY evc .created_at DESC ;
0 commit comments