Init#
The init command connects to an existing database, inspects its schema, and prints a complete config to stdout. The output includes globals, up, seed, deseed, and down sections ready to use with the other commands.
Flags#
| Flag | Required | Description |
|---|---|---|
--schema | --database) | Schema or database name to introspect (e.g. public, defaultdb, dbo, SYSTEM) |
--database | --schema) | Alias for --schema |
--driver | Yes | Database driver (pgx, mysql, mssql, oracle, dsql, spanner) |
--url | Yes | Connection URL for the source database |
edg init \
--driver pgx \
--url "postgres://root@localhost:26257/defaultdb?sslmode=disable" \
--schema public > workload.yamlGenerated Config#
The generated config includes:
upCREATE TABLEstatements derived from the database’s own DDL (CockroachDB’sSHOW CREATE TABLE, MySQL’sSHOW CREATE TABLE, Oracle’sDBMS_METADATA.GET_DDL, reconstructed fromsyscatalog views for MSSQL, or reconstructed fromINFORMATION_SCHEMAfor Spanner).seedOneINSERTper table with an expression for each non-generated column. Columns with auto-increment, identity, or default functions likegen_random_uuid()andnow()are skipped. Expressions are chosen by data type (e.g.uuid_v4()for UUID,uniform(1, 1000)for INT,gen('sentence:3')for VARCHAR).CHECK BETWEENconstraints are detected and used to narrow the range.deseedTRUNCATE(pgx, oracle) orDELETE FROM(mysql, mssql, spanner) in reverse dependency order.downDROP TABLEin reverse dependency order.- Tables are topologically sorted so parent tables are created before children.
The output is a starting point. You’ll typically want to refine the seed expressions to produce more realistic data, add a
runsection, and adjustglobals.rows.
Examples by driver#
CockroachDB / PostgreSQL (pgx)
edg init \
--driver pgx \
--url "postgres://root@localhost:26257/dbname?sslmode=disable" \
--schema public > workload.yamlAurora DSQL
edg init \
--driver dsql \
--url "clusterid.dsql.us-east-1.on.aws" \
--schema public > workload.yamlMySQL
edg init \
--driver mysql \
--url "root:password@tcp(localhost:3306)/dbname?parseTime=true" \
--database dbname > workload.yamlMSSQL
edg init \
--driver mssql \
--url "sqlserver://sa:P4ssw0rd@localhost:1433?database=master&encrypt=disable" \
--schema dbo > workload.yamlOracle
edg init \
--driver oracle \
--url "oracle://system:password@localhost:1521/dbname" \
--schema SYSTEM > workload.yamlGoogle Cloud Spanner (GoogleSQL)
edg init \
--driver spanner \
--url "projects/my-project/instances/my-instance/databases/my-db" \
--license "$EDG_LICENSE" \
--schema "" > workload.yaml