diff --git a/src/wuttaweb/code-templates/new-table.mako b/src/wuttaweb/code-templates/new-table.mako index 046862f..15eead9 100644 --- a/src/wuttaweb/code-templates/new-table.mako +++ b/src/wuttaweb/code-templates/new-table.mako @@ -15,16 +15,6 @@ class ${model_name}(model.Base): ${description} """ __tablename__ = "${table_name}" - % if any([c["data_type"]["type"] == "_fk_uuid_" for c in columns]): - __table_args__ = ( - % for column in columns: - % if column["data_type"]["type"] == "_fk_uuid_": - sa.ForeignKeyConstraint(["${column['name']}"], ["${column['data_type']['reference']}.uuid"], - name="${table_name}_fk_${column['data_type']['reference']}"), - % endif - % endfor - ) - % endif % if versioned: % if all([c["versioned"] for c in columns]): __versioned__ = {} @@ -48,17 +38,23 @@ class ${model_name}(model.Base): % if column["name"] == "uuid": uuid = model.uuid_column() - % else: - ${column["name"]} = sa.Column(${column["formatted_data_type"]}, nullable=${column["nullable"]}, doc=""" - ${column["description"] or ""} - """) - % if column["data_type"]["type"] == "_fk_uuid_" and column["relationship"]: + % elif column["data_type"]["type"] == "_fk_uuid_": + ${column["name"]} = model.uuid_fk_column("${column['data_type']['reference']}.uuid", + nullable=${column["nullable"]}) + % if column["relationship"]: ${column["relationship"]["name"]} = orm.relationship( "${column['relationship']['reference_model']}", doc=""" ${column["description"] or ""} """) % endif + % else: + ${column["name"]} = sa.Column( + ${column["formatted_data_type"]}, + nullable=${column["nullable"]}, + doc=""" + ${column["description"] or ""} + """) % endif % endfor diff --git a/src/wuttaweb/templates/tables/app/create.mako b/src/wuttaweb/templates/tables/app/create.mako index 94cd372..f8f8a57 100644 --- a/src/wuttaweb/templates/tables/app/create.mako +++ b/src/wuttaweb/templates/tables/app/create.mako @@ -947,7 +947,7 @@ } else { this.modelImportProblem = false this.modelImported = this.modelImportName - this.revisionMessage = `add table for ${"$"}{this.tableModelTitlePlural}` + this.revisionMessage = `add ${"$"}{this.tableModelTitlePlural}` } }, 200) })