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
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
Output file path (auto-prefixed with Result:
schemas/)schemas/myschema.chamForce 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
| PostgreSQL | ChameleonDB |
|---|---|
UUID | uuid |
VARCHAR, TEXT | string |
INTEGER, BIGINT | int |
BOOLEAN | bool |
TIMESTAMP, TIMESTAMPTZ | timestamp |
NUMERIC, DECIMAL | decimal |
JSONB, JSON | json |
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