Synopsis
Description
Theintrospect command:
- Connects to existing database - Uses provided connection string
- Scans all tables - Detects user tables, columns, types
- Generates schema - Creates ChameleonDB
.chamschema file - Respects paranoid mode - Blocked in readonly mode
- Handles overwrites safely - Prompts before replacing existing schemas
- ✅ PostgreSQL
- 🚧 MySQL (coming soon)
- 🚧 SQLite (coming soon)
Arguments
string
required
Database connection string or environment variable referenceFormats:
- Direct URL:
postgresql://user:pass@localhost/db - Env variable:
$DATABASE_URL - Env variable:
${DATABASE_URL} - Env variable:
env:DATABASE_URL
Flags
string
default:"schema.cham"
Output file path (auto-prefixed with Result:
schemas/)schemas/myschema.chamboolean
default:"false"
Force overwrite without confirmationWarning: Use with caution. Overwrites existing schema without backup.
Examples
Basic Introspection
Custom Output File
Using Environment Variable
Force Overwrite
Before Introspection
Existing Database
PostgreSQL tables:After Introspection
Generated Schema
schemas/schema.cham:Manual Adjustments
You may need to add relationships manually:Paranoid Mode Behavior
Readonly Mode (Default)
Standard Mode
Overwrite Protection
Default Schema Detected
Ifschemas/schema.cham contains the default schema from chameleon init:
Modified Schema Detected
Ifschemas/schema.cham has custom entities:
Using Different Output File
Connection String Formats
PostgreSQL
Environment Variable References
Error Handling
Connection Failed
Database Not Detected
No Tables Found
Permission Denied
Type Mapping
PostgreSQL to ChameleonDB
Limitations
Not Detected
- Relationships - Foreign keys detected but not converted to relations
- Indexes - Not included in schema
- Triggers - Not supported
- Views - Only tables are introspected
- Constraints - Only PRIMARY and UNIQUE detected
Manual Post-Processing
After introspection, you may need to:-
Add relationships:
-
Add indexes:
-
Refine types:
Best Practices
1. Introspect to New File
2. Review Before Committing
3. Use in CI/CD
See Also
chameleon init- Initialize new projectchameleon validate- Validate generated schemachameleon migrate- Apply schema to database- Schema Reference - Learn schema syntax
- Integrity Modes - Understand paranoid modes