drizzle-team/drizzle-orm · error · Error

You can't use email generator with a db column length restri

Error message

You can't use email generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxEmailLength}.

What it means

Error "You can't use email generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxEmailLength}." thrown in drizzle-team/drizzle-orm.

Source

Thrown at drizzle-seed/src/services/Generators.ts:1851

	public override isUnique = true;

	override init({ count, seed }: { count: number; seed: number }) {
		super.init({ count, seed });

		const domainsArray = emailDomains;
		const adjectivesArray = adjectives;
		const namesArray = firstNames;

		const maxUniqueEmailsNumber = adjectivesArray.length * namesArray.length * domainsArray.length;
		if (count > maxUniqueEmailsNumber) {
			throw new RangeError(
				`count exceeds max number of unique emails(${maxUniqueEmailsNumber}).`,
			);
		}

		const maxEmailLength = maxAdjectiveLength + maxFirstNameLength + maxEmailDomainLength + 2;
		if (this.stringLength !== undefined && this.stringLength < maxEmailLength) {
			throw new Error(
				`You can't use email generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxEmailLength}.`,
			);
		}

		const arraysToGenerateFrom = [adjectivesArray, namesArray, domainsArray];
		const genIndicesObj = new GenerateUniqueInt({
			minValue: 0,
			maxValue: maxUniqueEmailsNumber - 1,
		});
		genIndicesObj.init({ count, seed });

		this.state = { genIndicesObj, arraysToGenerateFrom };
	}

	generate() {
		if (this.state === undefined) {
			throw new Error('state is not defined.');
		}

View on GitHub (pinned to b7862528fd)

Solutions

  1. Increase the column's maximum string length to at least the required email length, or use a different generator.

When it happens

Trigger: Using the email generator on a varchar column shorter than the maximum generated email length.

Common situations: varchar(n) too small for emails; increase to at least maxEmailLength.


AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03). Data as JSON: /data/errors/ad0d11577f4ada33.json. Report an issue: GitHub.