Content-Type Builder automation / programmatically

Is it possible to automate or programmatically create content-types without using the UI Builder?

Two options that come to mind

  1. Through the API
  2. Manually place the code files and run CREATE TABLES it would have anyway

This topic has been created from a Discord post (1225454237119418408) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Maybe by just placing the files that would have been generated, the database side can sync on its own?

yup! apparently just placing the content-type files in place, Strapi sync all the things!

#!/bin/bash

# cleanup from previous runs
rm -rf repro/
docker rm -f repro-mysql

# start mysql
docker run -d \
  -e MYSQL_ROOT_PASSWORD=strapi \
  -e MYSQL_PASSWORD=strapi \
  -e MYSQL_USER=strapi \
  -e MYSQL_DATABASE=strapi \
  -p 3306:3306 \
  --name repro-mysql \
  mysql:8.3.0

# create app at previos version
npx create-strapi-app@5.0.0-beta.2 repro --typescript --quickstart --no-run

# move to new app for doing work
cd repro

# setup strapi for mysql
yarn add mysql2
export DATABASE_CLIENT=mysql

# copy existing types into place
cp -r my-content-types/* src/api/

# start app first time
yarn develop

Is this a runtime requirement

Or it’s compile time?

You can kinda replace schema.json files with js or ts

And feed some kind of config in there

But it doesn’t sounds like it’s going to fit your case

more of an experimentation / declarative as code → reproducibility thing. I generally dislike designing data structures in a UI with clicking, far easier to look at a single file(s) with the whole definition there

It’s the devops in me :]

Well you can edit schema.jsons directly