Back to Drizzle Orm

drizzle-orm-pg 0.15.0

changelogs/drizzle-orm-pg/0.15.0.md

0.45.21.3 KB
Original Source

drizzle-orm-pg 0.15.0

  • Set notNull to true in runtime, when .primaryKey() function was used in ColumnBuilder
  • Set no action for OnDelete and OnUpdate in runtime by default
  • Add internal version for ORM api
  • Index name now becomes optional. You can write either index('usersNameIdx') or index(). In last case, drizzle will generate index name automatically based on table and column index was created on

Breaking changes

foreignKey() function api changes. Previosuly you need to pass callback function with table columns for FK. Right now no need for callback, just object with data for FK

Before

typescript
export const usersTable = pgTable(
	'users_table',
	{
		id: serial('id').primaryKey(),
		uuid: uuid('uuid').defaultRandom().notNull(),
		homeCity: integer('home_city').notNull()
	},
	(users) => ({
		// foreignKey had a callback as param
		usersCityFK: foreignKey(() => ({ columns: [users.homeCity], foreignColumns: [cities.id] })),
	}),
);

Now

typescript
export const usersTable = pgTable(
	'users_table',
	{
		id: serial('id').primaryKey(),
		uuid: uuid('uuid').defaultRandom().notNull(),
		homeCity: integer('home_city').notNull()
	},
	(users) => ({
		// foreignKey doesn't have a callback as param
		usersCityFK: foreignKey({ columns: [users.homeCity], foreignColumns: [cities.id] }),
	}),
);