Overview
Once you’ve created your schema files, you need to import them into Infrahub. This guide covers multiple methods for loading schemas and managing schema updates.Prerequisites
Before importing:
- Infrahub server must be running
- Schema files must be valid YAML
- You need appropriate access credentials
Import Methods
Using the Python SDK
Using the REST API
Using infrahubctl CLI
Loading Multiple Schemas
You can load multiple related schemas in a single operation:Branch-Specific Schema Loading
Schemas can be loaded into specific branches for testing before merging to main:Schema Update Behavior
Idempotent Loading
Loading the same schema multiple times is idempotent - no changes occur if the schema hasn’t changed:Schema Migration
When you update an existing schema, Infrahub automatically:- Validates the changes against existing data
- Migrates existing objects to match the new schema
- Updates node metadata (timestamps, etc.)
- Applies default values to new attributes
Verifying Schema Import
Handling Schema Conflicts
When schema changes conflict with existing data:Adding mandatory attributes
Adding mandatory attributes
If you add a non-optional attribute to an existing schema:
Changing attribute types
Changing attribute types
Changing attribute kinds may fail if existing data is incompatible:You may need to:
- Export existing data
- Delete the attribute
- Re-create with new type
- Import converted data
Removing attributes
Removing attributes
Removing attributes from schema:
- Data is not immediately deleted
- Attribute becomes inaccessible via API
- Use data migration tools to clean up if needed
Schema Load Response
The schema load operation returns detailed information:Environment-Specific Loading
Best Practices
Version Control
Keep schema files in Git to track changes and enable rollbacks
Test in Branches
Test schema changes in feature branches before merging to main
Validate Before Loading
Use YAML validators and schema linters before importing
Document Changes
Maintain a changelog for schema modifications
Troubleshooting
Schema validation errors
Schema validation errors
Problem: Schema fails to load with validation errorsSolution:
- Check YAML syntax is valid
- Ensure all required fields are present
- Verify referenced schemas exist
- Check for circular dependencies
Connection errors
Connection errors
Problem: Cannot connect to Infrahub serverSolution:
- Verify server is running
- Check network connectivity
- Confirm credentials are correct
- Verify API endpoint URL
Permission denied
Permission denied
Problem: Authentication or authorization failuresSolution:
- Verify user has schema management permissions
- Check API token is valid
- Ensure user account is not locked
Next Steps
Create Schema
Learn how to define schemas in YAML
Schema Validation
Understand validation rules and constraints
Working with Branches
Manage schemas across branches
Python SDK
Explore the full SDK capabilities