uniqueKeyName (sqlite-core/unique-constraint.ts)

drizzle-orm · drizzle-orm/src/sqlite-core/unique-constraint.ts · typescript · Apache-2.0
database, Database / ORM

Provides builders for SQLite unique constraints in Drizzle ORM.

// Source: https://github.com/drizzle-team/drizzle-orm | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { entityKind } from '~/entity.ts';
import { TableName } from '~/table.utils.ts';
import type { SQLiteColumn } from './columns/common.ts';
import type { SQLiteTable } from './table.ts';

export function uniqueKeyName(table: SQLiteTable, columns: string[]) {
	return `${table[TableName]}_${columns.join('_')}_unique`;
}

export function unique(name?: string): UniqueOnConstraintBuilder {
	return new UniqueOnConstraintBuilder(name);
}

export class UniqueConstraintBuilder {
	static readonly [entityKind]: string = 'SQLiteUniqueConstraintBuilder';

	/** @internal */
	columns: SQLi

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key