SQL DDL to ODCS Data Contract
Turn a Postgres CREATE TABLE statement into an ODCS v3 data contract from your AI assistant.
You have a Postgres table. You need a data contract in the Open Data Contract Standard (ODCS) v3 format. Use this when the people who read a table ask for a contract. The output keeps the column names, the descriptions, the primary key, the decimal precision, the NOT NULL rules and the timestamp type. The page shows the recorded output and lists what did not carry over.
What you get
An ODCS v3.1.0 contract with seven properties. Six are required and order_id is the primary key. This is the answer CoreModels gave on 3 December 2026 for the file below.
order.odcs.yaml
apiVersion: v3.1.0
kind: DataContract
id: sql-schema
version: 1.0.0
status: active
schema:
- name: orders
description: A purchase order placed by a customer.
properties:
- name: order_id
logicalType: string
required: true
primaryKey: true
description: Order number printed on the receipt.
- name: customer_id
logicalType: string
required: true
description: The customer who placed the order.
- name: status
logicalType: string
required: true
description: Where the order is now.
- name: total_amount
logicalType: number
physicalType: decimal(12,2)
required: true
description: Order total, tax included.
- name: currency
logicalType: string
required: true
description: ISO 4217 currency code.
- name: placed_at
logicalType: timestamp
required: true
description: When the customer placed the order.
- name: discount_code
logicalType: string
description: Code used at checkout, if any.
What you need
- A CoreModels account with one project. Every plan starts with a 14-day free trial; a card is required to start.
- The tool uses the project only to check your access. It writes nothing.
- An assistant that speaks MCP, such as Claude Code, Claude Desktop or Cursor.
- A PostgreSQL DDL file.
Run it
1. Connect your assistant
In Claude Code, run this command. Then sign in when it asks.
claude mcp add --transport http coremodels https://go.coremodels.io/mcp
Cursor, Claude Desktop and other clients: connect guide.
2. Save the file as order.sql
Use your own file, or start with this one.
order.sql
-- Flat shop order (PostgreSQL)
CREATE TABLE orders (
order_id text NOT NULL,
customer_id text NOT NULL,
status text NOT NULL,
total_amount numeric(12, 2) NOT NULL,
currency text NOT NULL,
placed_at timestamptz NOT NULL,
discount_code text,
CONSTRAINT orders_pkey PRIMARY KEY (order_id),
CONSTRAINT orders_status_chk
CHECK (status IN ('placed', 'shipped', 'delivered', 'returned'))
);
COMMENT ON TABLE orders IS 'A purchase order placed by a customer.';
COMMENT ON COLUMN orders.order_id IS 'Order number printed on the receipt.';
COMMENT ON COLUMN orders.customer_id IS 'The customer who placed the order.';
COMMENT ON COLUMN orders.status IS 'Where the order is now.';
COMMENT ON COLUMN orders.total_amount IS 'Order total, tax included.';
COMMENT ON COLUMN orders.currency IS 'ISO 4217 currency code.';
COMMENT ON COLUMN orders.placed_at IS 'When the customer placed the order.';
COMMENT ON COLUMN orders.discount_code IS 'Code used at checkout, if any.';
3. Ask for the conversion
Use the CoreModels transform_schema tool to convert order.sql from sql to odcs. Pass the whole file as sourceSchema. Use any project from list_projects. Save the result as order.odcs.yaml, then list every entry in lossiness.
Your assistant calls transform_schema with these arguments.
transform_schema
{
"graphProjectId": "<your project id>",
"sourceFormat": "sql",
"sourceSchema": "<contents of order.sql>",
"targetFormat": "odcs"
}
What did not carry over
- We tested one table. Several tables with foreign keys are not tested on this page.
CoreModels reported these changes with the answer:
Taxonomy[ordersStatusEnum]: ODCS has no enum/controlled-list construct; the taxonomy is not represented.Element[ordersStatus]: ODCS has no enum constraint; the reference to taxonomy 'ordersStatusEnum' was approximated as string.
We compared the two files ourselves and also found:
- The contract id. The tool sets
sql-schema. Change it to your own id.
Compare your own files too. A different file can lose other things.
Check it yourself
Validate the contract against the official ODCS v3.1.0 schema.
pip install check-jsonschema
check-jsonschema --schemafile https://raw.githubusercontent.com/bitol-io/open-data-contract-standard/main/schema/odcs-json-schema-v3.1.0.json order.odcs.yaml
Same file, other formats
14-day free trial. Builder $49/mo after the trial. Cancel any time.