1.9 KiB
1.9 KiB
sindri
erstellt Datenmodell-Skripte in verschiedenen Ausgabe-Sprachen (MySQL, SQLite, …) auf Basis einer abstrakten Beschreibung
Erstellung
Voraussetzungen
- Typescript-Compiler
- GNU Make
Anweisungen
tools/buildausführen
Dokumentation
Beispiel-Nutzung:
tools/build
cd build
cat ../doc/examples/contacts.sindri.json | ./sindri -f database:sqlite
… erzeugt:
CREATE TABLE
`address`(
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`city` VARCHAR(255) NOT NULL,
`zip` VARCHAR(255) NOT NULL,
`street` VARCHAR(255) NOT NULL
)
;
CREATE TABLE
`person`(
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`prename` VARCHAR(255) NOT NULL,
`surname` VARCHAR(255) NOT NULL,
`address_id` INTEGER NOT NULL,
`email_address` VARCHAR(255) DEFAULT NULL
)
;
Der Befehl muss nur minimal gewändert werden um die PostgreSQL-Ausgabe zu erhalten:
cat ../doc/examples/contacts.sindri.json | ./sindri -f database:postgresql
… erzeugt:
CREATE TABLE
address(
"id" SERIAL,
"city" VARCHAR(255) NOT NULL,
"zip" VARCHAR(255) NOT NULL,
"street" VARCHAR(255) NOT NULL,
UNIQUE ("id")
)
;
COMMENT ON TABLE address IS 'collection of addresses';
COMMENT ON COLUMN address.city IS 'the name of the city';
COMMENT ON COLUMN address.zip IS 'the postal code';
COMMENT ON COLUMN address.street IS 'the name of the street and the house number';
CREATE TABLE
person(
"id" SERIAL,
"prename" VARCHAR(255) NOT NULL,
"surname" VARCHAR(255) NOT NULL,
"address_id" INTEGER NOT NULL,
"email_address" VARCHAR(255) DEFAULT NULL,
UNIQUE ("id")
)
;
COMMENT ON TABLE person IS 'collection of contacts';
COMMENT ON COLUMN person.prename IS 'first name of the person';
COMMENT ON COLUMN person.surname IS 'last name of the person';
COMMENT ON COLUMN person.address_id IS 'reference to the associated address dataset';
COMMENT ON COLUMN person.email_address IS 'optional eMail address';