Error: PG::UndefinedColumn. Custom field not creating column

There is a TopicCustomField model. You want that. Maybe have a look at Topic List Previews or some other plugin that mucks with topics. Or maybe see HasCustomFields somewhere in discourse core.