This project allows you to quickly scaffold a Common Data Model (CDM) folder using SQL DDL and custom annotations in form of SQL comments:
CREATE TABLE Customer
(
CUSTOMER_ID INT IDENTITY(1,1) PRIMARY KEY,
CUSTOMER_NAME VARCHAR(50) NOT NULL /* {trait:means.fullname} */
);
CREATE TABLE CustomerAddresses
(
CUSTOMER_ADDRESS_ID INT IDENTITY(1,1) PRIMARY KEY /* {trait:means.identity; trait:is.dataFormat.integer} */,
CUSTOMER_ID INT NOT NULL,
ADDRESS VARCHAR(100) NOT NULL /* {trait:means.address.main} */,
FOREIGN KEY(CUSTOMER_ID) REFERENCES Customer(CUSTOMER_ID)
);
CREATE TABLE VipCustomer /* {extends:Customer} */(
SPECIAL_CARD_NUMBER CHAR(10) NOT NULL
);
sql2cdm -i /sql/customer.sql -o ./cdm-generated
-
Clone this repository on your machine.
-
Build and publish the project:
dotnet restore --interactive
dotnet publish --no-restore ./src/Sql2Cdm.CLI -o ./cli
If you have problems with NuGet authentication, please check this document.
- Run the CLI using
customer.sql
sample:
dotnet ./cli/Sql2Cdm.CLI.dll -i ./sql/customer.sql -o ./cdm-generated