Skip to content

egon-orm-workspace / egon-orm/migration / ColumnBuilder

Interface: ColumnBuilder ​

Defined in: core/src/migration/builder.ts:364

One column being defined: t.text("email").notNull().unique(). Each method changes the column and returns the builder, so calls chain.

Columns allow NULL unless .notNull() is called, as in SQL.

Example ​

ts
m.createTable("users", (t) => {
  t.id();
  t.text("email").notNull().unique();
  t.integer("login_count").notNull().default(0);
});

Methods ​

default() ​

ts
default(value): this;

Defined in: core/src/migration/builder.ts:398

The column's database default: a constant, or an expression as a fragment.

Parameters ​

value ​

DefaultValue

Returns ​

this

Throws ​

TypeError for a value that cannot be written as a SQL constant.


notNull() ​

ts
notNull(): this;

Defined in: core/src/migration/builder.ts:382

NOT NULL.

Returns ​

this


nullable() ​

ts
nullable(): this;

Defined in: core/src/migration/builder.ts:388

Allows NULL (the default); written for clarity.

Returns ​

this


primaryKey() ​

ts
primaryKey(): this;

Defined in: core/src/migration/builder.ts:408

Makes the column (part of) the primary key.

Returns ​

this


unique() ​

ts
unique(options?): this;

Defined in: core/src/migration/builder.ts:418

A unique constraint on this column, named <table>_<column>_key unless name is given.

Parameters ​

options? ​
name? ​

string

Returns ​

this

Throws ​

TypeError when an option is unknown or has the wrong type.