Skip to content

generate model/crud writes a migration missing the model's declared fields (500 on first write) #101

Description

@andrevanzuydam

Found while validating the llms.txt AI-bootstrap flow end to end (CLI 3.8.58, tina4-python 3.13.87, Python 3.14.5). Reproduced independently twice, with both generate model and generate crud.

Repro

tina4 init python todoapi && cd todoapi
tina4 generate crud Todo

Expected

The generated migration creates every column the generated model declares.

Actual

Model (src/orm/Todo.py):

id         = IntegerField(primary_key=True, auto_increment=True)
name       = StringField()
created_at = DateTimeField()

Migration (migrations/<ts>_create_todo.sql):

CREATE TABLE IF NOT EXISTS todo (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    created_at TEXT DEFAULT CURRENT_TIMESTAMP
);

name is absent. After tina4 migrate, the first authenticated write fails:

POST /api/todos  ->  HTTP 500
[ERROR] Todo.save() failed for table "todo": table todo has no column named name
[ERROR] Route error: "bool" object has no attribute "to_dict"

Two defects stacked

  1. The generator drops the model's declared fields from its DDL. generate auth does NOT have this bug (the users table is complete), so it looks specific to model/crud generation.
  2. The generated route does item = Todo.create(...) then item.to_dict() with no check that create() succeeded, so a clean DB error surfaces as an unrelated AttributeError. The 500 hides the real cause.

Why this is high priority

https://tina4.com/llms.txt tells AI assistants to build REST APIs via generate auth + generate crud <Name>. That documented path currently 500s on the first write. I have added a temporary warning to llms.txt; it should be removed once this is fixed.

Per the parity rule this needs checking on php/ruby/nodejs generators too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions