sindri/readme.md

95 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2025-09-22 21:41:31 +02:00
# sindri
2023-02-20 14:46:28 +01:00
2025-09-22 21:41:31 +02:00
erstellt Datenmodell-Skripte in verschiedenen Ausgabe-Sprachen (MySQL, SQLite, …) auf Basis einer abstrakten Beschreibung
2023-02-20 14:46:28 +01:00
## Erstellung
### Voraussetzungen
- Typescript-Compiler
- GNU Make
2025-09-22 20:44:57 +02:00
### Anweisungen
2023-02-20 14:46:28 +01:00
- `tools/build` ausführen
2025-09-22 20:44:57 +02:00
## Dokumentation
Beispiel-Nutzung:
```sh
tools/build
cd build
2025-09-22 21:41:31 +02:00
2025-09-22 20:44:57 +02:00
cat ../doc/examples/contacts.sindri.json | ./sindri -f database:sqlite
```
… erzeugt:
```sql
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
)
;
```
2023-02-20 14:46:28 +01:00
2025-09-22 21:41:31 +02:00
Der Befehl muss nur minimal gewändert werden um die PostgreSQL-Ausgabe zu erhalten:
```sh
cat ../doc/examples/contacts.sindri.json | ./sindri -f database:postgresql
```
… erzeugt:
```sql
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';
```