{"id":"4f3c4733c59808c9","repo":"drizzle-team/drizzle-orm","slug":"you-can-t-use-company-name-generator-with-a-db-col","errorCode":null,"errorMessage":"You can't use company name generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxCompanyNameLength}.","messagePattern":"You can't use company name generator with a db column length restriction of (.+?)\\. Set the maximum string length to at least (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"drizzle-seed/src/services/Generators.ts","lineNumber":2617,"sourceCode":"\n\toverride init({ count, seed }: { count: number; seed: number }) {\n\t\tsuper.init({ count, seed });\n\n\t\tconst rng = prand.xoroshiro128plus(seed);\n\t\tconst templates = [\n\t\t\t{ template: '#', placeholdersCount: 1 },\n\t\t\t{ template: '# - #', placeholdersCount: 2 },\n\t\t\t{ template: '# and #', placeholdersCount: 2 },\n\t\t\t{ template: '#, # and #', placeholdersCount: 3 },\n\t\t];\n\n\t\t// max( { template: '#', placeholdersCount: 1 }, { template: '#, # and #', placeholdersCount: 3 } )\n\t\tconst maxCompanyNameLength = Math.max(\n\t\t\tmaxLastNameLength + maxCompanyNameSuffixLength + 1,\n\t\t\t3 * maxLastNameLength + 7,\n\t\t);\n\t\tif (this.stringLength !== undefined && this.stringLength < maxCompanyNameLength) {\n\t\t\tthrow new Error(\n\t\t\t\t`You can't use company name generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxCompanyNameLength}.`,\n\t\t\t);\n\t\t}\n\n\t\tthis.state = { rng, templates };\n\t}\n\n\tgenerate() {\n\t\tif (this.state === undefined) {\n\t\t\tthrow new Error('state is not defined.');\n\t\t}\n\n\t\tlet templateIdx, idx, lastName, companyNameSuffix, companyName;\n\t\t[templateIdx, this.state.rng] = prand.uniformIntDistribution(0, this.state.templates.length - 1, this.state.rng);\n\t\tconst templateObj = this.state.templates[templateIdx]!;\n\n\t\tif (templateObj.template === '#') {\n\t\t\t[idx, this.state.rng] = prand.uniformIntDistribution(0, lastNames.length - 1, this.state.rng);","sourceCodeStart":2599,"sourceCodeEnd":2635,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-seed/src/services/Generators.ts#L2599-L2635","documentation":"The GenerateCompanyName generator builds names from templates that combine last names and company-name suffixes (e.g. 'Smith Inc', 'Smith and Jones LLC'). It computes a minimum viable column width, maxCompanyNameLength = max(maxLastNameLength + maxCompanyNameSuffixLength + 1, 3*maxLastNameLength + 7), based on the longest entries in its built-in datasets. When the target DB column's varchar length is smaller than this minimum, the generator cannot guarantee its output will fit, so it refuses to initialize.","triggerScenarios":"A varchar column with a short explicit length (e.g. varchar(10)) that drizzle-seed auto-assigns the company name generator to, or explicitly wiring GenerateCompanyName to a column whose { length } is below the computed minimum. The check runs in GenerateCompanyName.init() when this.stringLength (from col.typeParams.length) is defined and below the threshold.","commonSituations":"Legacy or compact schema with a narrow company_name column; column name pattern-matches the company-name heuristic but the length was chosen for abbreviations rather than full generated names.","solutions":["Widen the column's varchar length to at least the maxCompanyNameLength value printed in the error message.","If the column cannot be widened, override the generator in refinements with one that fits, e.g. GenerateString or GenerateCompanyName with a shorter custom source.","Remove the explicit { length } from the column definition so the generator's stringLength is undefined and the check is skipped."],"exampleFix":"// before\ncompanyName: varchar('company_name', { length: 10 })\n// after\ncompanyName: varchar('company_name', { length: 50 })","handlingStrategy":"validation","validationCode":"// Before assigning GenerateCompanyName, check the column width against the dataset-derived minimum.\n// The exact floor depends on the bundled lastNames/companyNameSuffixes datasets.\n// Safest approach: ensure the column length is comfortably large (>= 50).\nconst MIN_COMPANY_NAME_LENGTH = 50; // conservative lower bound; error message gives exact value\nfunction columnFitsCompanyName(colLength: number | undefined): boolean {\n  return colLength === undefined || colLength >= MIN_COMPANY_NAME_LENGTH;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use varchar lengths >= 50 for any column that may receive the company name generator.","Review auto-assigned generators for short varchar columns before running seed in CI.","When in doubt, omit the explicit length so the width check is skipped."],"tags":["company-name","string-length","varchar","generator-config"],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}