What is SQL to Hasura Metadata Generator?
This tool converts SQL CREATE TABLE statements into Hasura metadata configuration. It parses your SQL schema, generates table definitions with proper column type mappings, creates object and array relationships from foreign keys, and sets up basic CRUD permissions for user and anonymous roles.
How to Use
- Paste your SQL CREATE TABLE statements with foreign key references into the input area
- Click "Generate" to create the Hasura metadata JSON configuration
- Review the generated table definitions, relationships, and permissions
- Apply the metadata to your Hasura instance using the Hasura CLI or API
Why Use This Tool?
Tips & Best Practices
- Review the generated permissions and adjust them for your security requirements
- The anonymous role excludes sensitive columns like email and password by default
- Add custom check constraints to permissions for row-level security
- Use hasura metadata apply to apply the generated configuration
Frequently Asked Questions
What SQL data types are supported?
The tool supports common PostgreSQL types including SERIAL, INTEGER, VARCHAR, TEXT, BOOLEAN, TIMESTAMP, UUID, JSON/JSONB, NUMERIC, and more. Unsupported types default to text mapping.
How are foreign key relationships handled?
Foreign key references (REFERENCES) are automatically detected and converted into Hasura object relationships (for the referencing table) and array relationships (for the referenced table).
What permissions are generated?
The tool generates basic permissions for "user" role (full CRUD access) and "anonymous" role (select only, with sensitive columns excluded). You should customize these for your application.
Can I use this with MySQL or other databases?
The tool is designed for PostgreSQL syntax, which is the primary database supported by Hasura. MySQL syntax may work for basic CREATE TABLE statements but some features like SERIAL may not be recognized.
Is my SQL data sent to a server?
No, all processing happens entirely in your browser. Your SQL schema never leaves your device.