Skip to content

Meta Table

ArchForge provides a low-code meta table capability that lets administrators define tables, columns, indexes, and constraints from the admin UI, and then automatically create the physical PostgreSQL table, perform schema evolution, manage row data, and generate full-stack boilerplate code.

Features

Visual Table Design

Define a table through the admin UI with the following metadata:

PropertyDescription
Table codeUnique machine-readable identifier, used as the physical table name suffix
Table nameHuman-readable display name
Table prefixPhysical table prefix, defaults to meta_
StatusEnabled (1) or disabled (0)
DescriptionOptional notes

Column Types

Meta tables support the following column types:

TypePostgreSQL mappingNotes
STRINGVARCHAR(length)Default length 255
TEXTTEXTLong text
INTEGERBIGINTWhole numbers
DECIMALNUMERIC(precision, scale)Defaults to NUMERIC(18,2)
BOOLEANBOOLEANTrue/false
DATEDATECalendar date
DATETIMETIMESTAMPWithout timezone
TIMESTAMPTZTIMESTAMPTZWith timezone
ENUMVARCHAR(length)Options stored as JSON list
JSONJSONBJSON documents
GEOJSONBGeographic/JSON data
FILEVARCHAR(512)File reference
UUIDUUIDUUID values
ARRAYelement_type[]Arrays of STRING, INTEGER, DECIMAL, or BOOLEAN

Column Properties

Each column can be configured with:

  • Length / precision / scale — for string, decimal, and array element sizing
  • Nullable / required — controls NOT NULL
  • Default value — stored as a typed default
  • Unique — enforces unique values
  • Index / index type / index group — single or composite indexes (BTREE, GIN, GIST, FULLTEXT)
  • Searchable — exposed in the data list search form
  • List visible — shown in the data grid by default
  • Tenant / owner column — flags for multi-tenant or row-owner semantics
  • Options — for ENUM type value lists
  • Reference table / column — for future foreign-key documentation

Schema Evolution

When a table definition is updated, the SchemaDiffEngine compares the old and new column lists and produces an ordered migration plan:

  1. RENAME_COLUMN
  2. DROP_COLUMN
  3. ADD_COLUMN
  4. ALTER_TYPE
  5. ALTER_DEFAULT
  6. ALTER_NULL
  7. ALTER_INDEX

The AlterTableDdlGenerator converts each change into safe PostgreSQL ALTER TABLE DDL. The migration history is persisted in sys_meta_table_migration and can be exported as a Flyway SQL file.

Data CRUD

Once a table is defined and the physical table exists, you can:

  • List paginated rows with dynamic filters
  • Insert new rows
  • Update existing rows
  • Soft-delete rows
  • Import data from CSV or JSON
  • Export data to EXCEL, CSV, or JSON

Code Generation

Each meta table can generate a full module scaffold using FreeMarker templates:

Backend (example/<tableCode> by default)

  • build.gradle.kts
  • domain/{Entity}.java
  • dao/{Entity}Dao.java
  • dto/{Entity}CreateRequest.java
  • dto/{Entity}UpdateRequest.java
  • dto/{Entity}ListRequest.java
  • dto/{Entity}Response.java
  • dto/{Entity}PageResult.java
  • service/{Entity}Service.java
  • rest/{Entity}Controller.java
  • Error code / exception / project module classes
  • Integration test skeleton

Frontend (src/views/<tableCode> by default)

  • src/api/<tableCode>.ts
  • src/router/modules/<tableCode>.ts
  • src/views/<tableCode>/utils/types.ts
  • src/views/<tableCode>/utils/hook.tsx
  • src/views/<tableCode>/index.vue
  • src/views/<tableCode>/form/index.vue

The generated controller delegates list/export/import to MetaTableCrudService and reuses the dynamic table runtime.

Data Model

sys_meta_table

FieldTypeDescription
idBIGINTPrimary key
table_codeVARCHAR(64)Unique table code
table_nameVARCHAR(128)Display name
descriptionVARCHAR(512)Notes
table_prefixVARCHAR(32)Physical prefix, default meta_
statusINTEnabled 1 / disabled 0
creator_idBIGINTCreated by
create_timeTIMESTAMPCreation time
updater_idBIGINTUpdated by
update_timeTIMESTAMPUpdate time
deletedINTSoft-delete flag

sys_meta_table_column

FieldTypeDescription
idBIGINTPrimary key
table_idBIGINTForeign key to sys_meta_table
column_codeVARCHAR(64)Column code
column_nameVARCHAR(128)Display name
data_typeVARCHAR(32)One of the supported column types
lengthINTLength or max size
precisionINTNumeric precision
scaleINTNumeric scale
nullableINT1 = nullable, 0 = not null
default_valueVARCHAR(255)Default value
is_uniqueINTUnique flag
is_requiredINTRequired flag
is_searchableINTSearchable flag
is_list_visibleINTVisible in list flag
is_indexINTIndexed flag
sortINTDisplay order
optionsTEXTJSON option list
reference_tableVARCHARReference table
reference_columnVARCHARReference column
tenant_columnBOOLEANTenant flag
owner_columnBOOLEANOwner flag
index_typeVARCHARIndex type
index_groupVARCHARIndex group name
array_element_typeVARCHARArray element type

sys_meta_table_migration

FieldTypeDescription
idBIGINTPrimary key
table_idBIGINTRelated meta table
versionINTSchema version
change_typeVARCHAR(32)RENAME/DROP/ADD/ALTER_*
column_codeVARCHAR(64)Affected column
old_column_codeVARCHAR(64)Old column name on rename
old_type / new_typeVARCHAR(64)Type before/after
old_default / new_defaultVARCHAR(255)Default before/after
ddl_sqlTEXTGenerated DDL
statusVARCHAR(16)PENDING / EXECUTED
executed_atTIMESTAMPExecution time

API Endpoints

All endpoints require the ADMIN role.

MethodEndpointDescription
POST/meta-tablePaginated list of meta tables
GET/meta-table/{id}Meta table detail with columns
POST/meta-table/createCreate a new meta table
PUT/meta-table/{id}Update table and columns
POST/meta-table/{id}/copyDuplicate a meta table
POST/meta-table/{id}/generateGenerate frontend/backend code
GET/meta-table/{id}/delete-checkCheck if table can be deleted
DELETE/meta-table/{id}?force={false|true}Delete meta table
GET/meta-table/{id}/migrationsList schema migration history
GET/meta-table/{id}/export-migrationExport migrations as Flyway SQL
POST/meta-table/{id}/dataList rows of the dynamic table
POST/meta-table/{id}/data/createInsert a row
PUT/meta-table/{id}/data/{dataId}Update a row
POST/meta-table/{id}/data/{dataId}/deleteSoft-delete a row
GET/meta-table/{id}/export?format=EXCELExport table data
POST/meta-table/{id}/import?format=CSVImport table data

Admin UI

The admin UI for meta tables is located at /src/views/meta-table/:

  • Meta table list — search by code/name, paginated table, create/edit/copy/delete/generate actions
  • Table designer — dialog form for editing table metadata and columns
  • Data management — open a meta table’s data grid to perform CRUD, search, import, and export
  • All buttons are controlled by meta:table:* permissions

Permissions

PermissionDescription
meta:table:listView meta tables
meta:table:queryQuery meta table data
meta:table:addCreate a meta table
meta:table:editUpdate a meta table
meta:table:removeDelete a meta table
meta:table:exportExport meta table data
meta:table:designDesign columns
meta:table:dataManage row data
meta:table:generateGenerate code scaffold

Typical Workflow

  1. Create a meta table with a unique code, name, and prefix.
  2. Add columns with types, constraints, and index settings.
  3. Save the design; the backend creates the physical table ({prefix}{table_code}).
  4. Switch to the Data view to insert, edit, delete, import, or export rows.
  5. (Optional) Click Generate to produce a full-stack module scaffold.
  6. When requirements change, edit the table; the system computes and applies schema migration DDL.

Released under the MIT License.