egon-orm-workspace / egon-orm/migration / AlterTableBuilder
Interface: AlterTableBuilder ​
Defined in: core/src/migration/builder.ts:791
The t of m.alterTable(name, (t) => …): adds columns with the same methods as createTable, and modifies, removes and renames them.
Example ​
m.alterTable("users", (t) => {
t.text("nickname");
t.modify("age", "bigint");
t.remove("legacy_flag");
t.rename("name", "full_name");
});Extends ​
Methods ​
add() ​
add(name, type): ColumnBuilder;Defined in: core/src/migration/builder.ts:522
A column of any type: t.add("price", { kind: "decimal", precision: 10, scale: 2 }).
Parameters ​
name ​
string
type ​
Returns ​
Throws ​
TypeError when the name or the type is not valid.
Inherited from ​
array() ​
array(name, of): ColumnBuilder;Defined in: core/src/migration/builder.ts:604
An array of of: t.array("tags", "text").
Parameters ​
name ​
string
of ​
Returns ​
Inherited from ​
bigint() ​
bigint(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:533
bigint.
Parameters ​
name ​
string
Returns ​
Inherited from ​
binary() ​
binary(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:569
bytea on Postgres.
Parameters ​
name ​
string
Returns ​
Inherited from ​
boolean() ​
boolean(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:549
boolean.
Parameters ​
name ​
string
Returns ​
Inherited from ​
custom() ​
custom(name, sql): ColumnBuilder;Defined in: core/src/migration/builder.ts:613
A column of a type named by trusted program text: t.custom("email", "citext").
Parameters ​
name ​
string
sql ​
string
Returns ​
Throws ​
TypeError when sql is not a plain type name.
Inherited from ​
date() ​
date(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:574
date.
Parameters ​
name ​
string
Returns ​
Inherited from ​
decimal() ​
decimal(name, options?): ColumnBuilder;Defined in: core/src/migration/builder.ts:543
numeric, with an optional precision and scale.
Parameters ​
name ​
string
options? ​
precision? ​
number
scale? ​
number
Returns ​
Inherited from ​
enumText() ​
enumText(name, values): ColumnBuilder;Defined in: core/src/migration/builder.ts:685
A text column that only takes the given values, enforced by a check constraint named <table>_<column>_check. The values are written into the constraint as SQL literals.
Parameters ​
name ​
string
values ​
readonly string[]
Returns ​
Throws ​
TypeError when values is not a non-empty array of strings without NUL.
Inherited from ​
float() ​
float(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:538
double precision on Postgres.
Parameters ​
name ​
string
Returns ​
Inherited from ​
id() ​
Call Signature ​
id(options?): ColumnBuilder;Defined in: core/src/migration/builder.ts:625
A key the database generates: bigserial primary key named id by default, or serial with { type: "integer" }. The options can come first when the column is named id: t.id({ type: "integer" }) is t.id("id", { type: "integer" }).
Parameters ​
options? ​
Returns ​
Throws ​
TypeError when an option is unknown or has the wrong type, or when options come first and a second argument is given too.
Inherited from ​
Call Signature ​
id(name?, options?): ColumnBuilder;Defined in: core/src/migration/builder.ts:626
A key the database generates: bigserial primary key named id by default, or serial with { type: "integer" }. The options can come first when the column is named id: t.id({ type: "integer" }) is t.id("id", { type: "integer" }).
Parameters ​
name? ​
string
options? ​
Returns ​
Throws ​
TypeError when an option is unknown or has the wrong type, or when options come first and a second argument is given too.
Inherited from ​
integer() ​
integer(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:528
integer.
Parameters ​
name ​
string
Returns ​
Inherited from ​
json() ​
json(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:594
json.
Parameters ​
name ​
string
Returns ​
Inherited from ​
jsonb() ​
jsonb(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:599
jsonb. (The schema field builder t.json() is stored as jsonb.)
Parameters ​
name ​
string
Returns ​
Inherited from ​
modify() ​
modify(
name,
type,
options?
): void;Defined in: core/src/migration/builder.ts:812
Changes a column's type and, optionally, its nullability and default.
Parameters ​
name ​
string
type ​
options? ​
Returns ​
void
Throws ​
TypeError when an argument is not valid.
references() ​
references(
name,
table,
options?
): ColumnBuilder;Defined in: core/src/migration/builder.ts:651
A column that references another table's key, with a foreign key constraint named <table>_<column>_fkey: t.references("author_id", "users").
Parameters ​
name ​
string
table ​
string
options? ​
Returns ​
Throws ​
TypeError when an option is unknown or has the wrong type.
Inherited from ​
remove() ​
remove(name): void;Defined in: core/src/migration/builder.ts:835
Drops a column.
Parameters ​
name ​
string
Returns ​
void
Throws ​
TypeError when the name is not valid.
rename() ​
rename(from, to): void;Defined in: core/src/migration/builder.ts:845
Renames a column.
Parameters ​
from ​
string
to ​
string
Returns ​
void
Throws ​
TypeError when a name is not valid.
string() ​
string(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:559
text (another name for ColumnAdder.text, as the schema field builder calls it).
Parameters ​
name ​
string
Returns ​
Inherited from ​
text() ​
text(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:554
text.
Parameters ​
name ​
string
Returns ​
Inherited from ​
time() ​
time(name, options?): ColumnBuilder;Defined in: core/src/migration/builder.ts:579
time, with an optional fractional-second precision.
Parameters ​
name ​
string
options? ​
precision? ​
number
Returns ​
Inherited from ​
timestamp() ​
timestamp(name, options?): ColumnBuilder;Defined in: core/src/migration/builder.ts:584
A timestamp without a time zone, with an optional fractional-second precision.
Parameters ​
name ​
string
options? ​
precision? ​
number
Returns ​
Inherited from ​
timestamps() ​
timestamps(options?): void;Defined in: core/src/migration/builder.ts:711
created_at and updated_at: timestamptz not null default now().
Parameters ​
options? ​
Returns ​
void
Throws ​
TypeError when an option is unknown or has the wrong type.
Inherited from ​
timestamptz() ​
timestamptz(name, options?): ColumnBuilder;Defined in: core/src/migration/builder.ts:589
A timestamp with a time zone, with an optional fractional-second precision.
Parameters ​
name ​
string
options? ​
precision? ​
number
Returns ​
Inherited from ​
uuid() ​
uuid(name): ColumnBuilder;Defined in: core/src/migration/builder.ts:564
uuid.
Parameters ​
name ​
string

