drizzle-team/drizzle-orm · error · Error

specifying non unique generator to unique column.

Error message

specifying non unique generator to unique column.

What it means

Error "specifying non unique generator to unique column." thrown in drizzle-team/drizzle-orm.

Source

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

	public params: T;

	constructor(params?: T) {
		this.params = params === undefined ? {} as T : params as T;
	}

	init(params: { count: number | { weight: number; count: number | number[] }[]; seed: number }): void;
	init() {
		this.updateParams();
	}

	updateParams() {
		if ((this.params as any).arraySize !== undefined) {
			this.arraySize = (this.params as any).arraySize;
		}

		if ((this.params as any).isUnique !== undefined) {
			if ((this.params as any).isUnique === false && this.isUnique === true) {
				throw new Error('specifying non unique generator to unique column.');
			}

			this.isUnique = (this.params as any).isUnique;
		}
	}

	abstract generate(params: { i: number }): number | string | boolean | unknown | undefined | void;

	getEntityKind(): string {
		const constructor = this.constructor as typeof AbstractGenerator;
		return constructor.entityKind;
	}

	replaceIfUnique() {
		this.updateParams();
		if (
			this.uniqueVersionOfGen !== undefined
			&& this.isUnique === true

View on GitHub (pinned to b7862528fd)

Solutions

  1. Use a unique generator (e.g. the unique variant of the generator) for columns marked unique, or remove the unique constraint from the column.

When it happens

Trigger: Assigning a non-unique generator (e.g. default string/number generator) to a column marked unique in drizzle-seed refinements.

Common situations: Forgetting to use a unique* generator variant for unique columns in the seed refinements map.


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