Getting started
Installing
Generating the schema
Relational-schema generates code from your database schema.
It does this by running queries against your database to work out the table schema as well as the relations between tables.
important
We never recommend running the code gen against your production database. Instead you should run it against a local database with the same schema.
Configuring code gen
Define a config file introspect-config.json
in the root directory of your project.
Change the contents of the file to connect to your database.
For the client
option you can choose between mysql
and pg
.
Options
outdir
- where the Javascript schema files will be output.format
-json
,es6
,ts
,cjs
- the file output formatprettierConfig
- specifies a path to a validprettierrc
file. This will be used to format the output files rather than the default formatting.transitiveRelations
- whether to include transitive (many-to-many) relations in the output. This can increase the file size by an order of magnitude so it is optional.
Run:
The above commands will generate the schema for users
database.
The resulting files are stored in ./src/generated
.