Creating the database by code in the community edition - possible?

I have a ready database model with like 40 tables with relations and hundreds of fields.
Im hoping for a quick way to set up a Nocobase database based on the script.
Now I have struggled a while trying different ways to programatically create a collection.

With js like this (just an dummy example):

const { defineCollection } = require(‘@nocobase/database’);

module.exports = defineCollection({
name: ‘orderItems’,
fields: [
{ type: ‘belongsTo’, name: ‘order’, target: ‘orders’, required: true, foreignKey: { onDelete: ‘CASCADE’ } },
{ type: ‘belongsTo’, name: ‘product’, target: ‘products’, required: true, foreignKey: { onDelete: ‘RESTRICT’ } },
{ type: ‘integer’, name: ‘quantity’, required: true, defaultValue: 1, uiSchema: { title: ‘Antal’ } },
],
indexes: [{ unique: true, fields: [‘orderId’, ‘productId’] }],
});

I realise that different editions of Nocobase have different capabilities.
Now I just want to ask if there are any hard obstacles for doing this with the community Docker edition - version 1.8.14?

It seemd like a smart way to go to just let AI generate the js needed based on the dbml, and have it set up in nocobase in no time. But I have now spent too many hours on this.
It was done in minutes to set up the database direcly in postgres, and I had probably been ready if I spent the time, trying to migrate the db model, on having AI to code the entire app…

Anyway I think there may be a bright future for lowcode apps if they easily can take advantage of AI capabilities. We need handy easy flows in how to quickly set up and try things out. My db model is generated by help of AI, and I want to test it out and create a quick prototype.

My time is running out for this and I need to decide the path to go. Manually or programmatically.
I’m very grateful for any advice here

I manged partly to solve it by creating a plugin that reads a json file with the defined db schema.
Collections, fields and relations are created.
The json file was created by AI based on a DBML model

Some work is still required in order to have the ui-design work fully for foreign key fields. Other NocoBase specials are also left to be covered.
This was indeed more complex than expected…
What I created could be the base for a generic tool - but isn’t there already tools for this?