Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions docs/src/migrations/columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ The `createTable` and `addColumns` methods both take a `columns` argument that s
It is an object (key/value) where each key is the name of the column,
and the value is another object that defines the options for the column.

| Option | Type | Description |
| ----------------------------- | ------------------------------------- | -------------------------------------------------------------------------------------------- |
| `type` | `string` | Data type (use normal postgres types) |
| `collation` | `string` | Collation of data type |
| `unique` | `boolean` | Set to true to add a unique constraint on this column |
| `primaryKey` | `boolean` | Set to true to make this column the primary key |
| `notNull` | `boolean` | Set to true to make this column not null |
| `default` | `string` | Adds DEFAULT clause for column. Accepts null, a literal value, or a `pgm.func()` expression. |
| `check` | `string` | SQL for a check constraint for this column |
| `references` | [Name](/migrations/#type) or `string` | A table name that this column is a foreign key to |
| `referencesConstraintName` | `string` | Name of the created constraint |
| `referencesConstraintComment` | `string` | Comment on the created constraint |
| `onDelete` | `string` | Adds ON DELETE constraint for a reference column |
| `onUpdate` | `string` | Adds ON UPDATE constraint for a reference column |
| `match` | `string` | `FULL` or `SIMPLE` |
| `deferrable` | `boolean` | Flag for deferrable column constraint |
| `deferred` | `boolean` | Flag for initially deferred deferrable column constraint |
| `comment` | `string` | Adds comment on column |
| `expressionGenerated` | `string` | Expression to compute column value |
| `sequenceGenerated` | `object` | Creates identity column see [sequence options section](sequences.md#sequence-options) |
| `precedence` | `string` | `ALWAYS` or `BY DEFAULT` |
| Option | Type | Description |
| ----------------------------- | -------------------------------------- | -------------------------------------------------------------------------------------------- |
| `type` | `string` | Data type (use normal postgres types) |
| `collation` | `string` | Collation of data type |
| `unique` | `boolean` | Set to true to add a unique constraint on this column |
| `primaryKey` | `boolean` | Set to true to make this column the primary key |
| `notNull` | `boolean` | Set to true to make this column not null |
| `default` | `string` | Adds DEFAULT clause for column. Accepts null, a literal value, or a `pgm.func()` expression. |
| `check` | `string` | SQL for a check constraint for this column |
| `references` | [Name](/migrations/#types) or `string` | A table name that this column is a foreign key to |
| `referencesConstraintName` | `string` | Name of the created constraint |
| `referencesConstraintComment` | `string` | Comment on the created constraint |
| `onDelete` | `string` | Adds ON DELETE constraint for a reference column |
| `onUpdate` | `string` | Adds ON UPDATE constraint for a reference column |
| `match` | `string` | `FULL` or `SIMPLE` |
| `deferrable` | `boolean` | Flag for deferrable column constraint |
| `deferred` | `boolean` | Flag for initially deferred deferrable column constraint |
| `comment` | `string` | Adds comment on column |
| `expressionGenerated` | `string` | Expression to compute column value |
| `sequenceGenerated` | `object` | Creates identity column see [sequence options section](sequences.md#sequence-options) |
| `precedence` | `string` | `ALWAYS` or `BY DEFAULT` |

## Data types & Convenience Shorthand

Expand Down Expand Up @@ -72,11 +72,11 @@ pgm.addColumns('myTable', { id: { type: 'serial', primaryKey: true } });

#### Arguments

| Name | Type | Description |
| ------------- | ------------------------- | ------------------------------------------------------------------------------- |
| `tablename` | [Name](/migrations/#type) | Name of the table to alter |
| `new_columns` | `object` | Column names / options -- see [column definitions section](#column-definitions) |
| `options` | `object` | Check below for available options |
| Name | Type | Description |
| ------------- | -------------------------- | ------------------------------------------------------------------------------- |
| `tablename` | [Name](/migrations/#types) | Name of the table to alter |
| `new_columns` | `object` | Column names / options -- see [column definitions section](#column-definitions) |
| `options` | `object` | Check below for available options |

##### Options

Expand All @@ -97,7 +97,7 @@ pgm.addColumns('myTable', { id: { type: 'serial', primaryKey: true } });

| Name | Type | Description |
| ----------- | ------------------------------ | ---------------------------------------- |
| `tablename` | [Name](/migrations/#type) | Name of the table to alter |
| `tablename` | [Name](/migrations/#types) | Name of the table to alter |
| `columns` | `array of strings` or `object` | Columns to drop (if objected, uses keys) |
| `options` | `object` | Check below for available options |

Expand All @@ -119,11 +119,11 @@ pgm.addColumns('myTable', { id: { type: 'serial', primaryKey: true } });

#### Arguments

| Name | Type | Description |
| ----------------- | ------------------------- | ------------------- |
| `tablename` | [Name](/migrations/#type) | Name of the table |
| `old_column_name` | `string` | Current column name |
| `new_column_name` | `string` | New column name |
| Name | Type | Description |
| ----------------- | -------------------------- | ------------------- |
| `tablename` | [Name](/migrations/#types) | Name of the table |
| `old_column_name` | `string` | Current column name |
| `new_column_name` | `string` | New column name |

### Operation: `alterColumn`

Expand All @@ -135,11 +135,11 @@ pgm.addColumns('myTable', { id: { type: 'serial', primaryKey: true } });

#### Arguments

| Name | Type | Description |
| ---------------- | ------------------------- | --------------------------- |
| `tablename` | [Name](/migrations/#type) | Name of the table |
| `column_name` | `string` | Column to alter |
| `column_options` | `object` | Optional new column options |
| Name | Type | Description |
| ---------------- | -------------------------- | --------------------------- |
| `tablename` | [Name](/migrations/#types) | Name of the table |
| `column_name` | `string` | Column to alter |
| `column_options` | `object` | Optional new column options |

##### Column Options

Expand Down
48 changes: 24 additions & 24 deletions docs/src/migrations/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

### Arguments

| Name | Type | Description |
| ----------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `tablename` | [Name](/migrations/#type) | Name of the table to alter |
| `constraint_name` | `string` | Name for the constraint |
| `expression` | `string` or `object` | Constraint expression (raw sql) or definition -- see [constraint definition section](#constraint-definition) |
| Name | Type | Description |
| ----------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `tablename` | [Name](/migrations/#types) | Name of the table to alter |
| `constraint_name` | `string` | Name for the constraint |
| `expression` | `string` or `object` | Constraint expression (raw sql) or definition -- see [constraint definition section](#constraint-definition) |

#### Constraint Definition

Expand All @@ -32,15 +32,15 @@

#### Foreign Keys

| Option | Type | Description |
| ----------------------------- | -------------------------- | ---------------------------------------------------------------------------------- |
| `columns` | `Name` or `array of Names` | Names of columns |
| `references` | `Name` | Names of foreign table and column names |
| `referencesConstraintName` | `string` | Name of the created constraint (only necessary when creating multiple constraints) |
| `referencesConstraintComment` | `string` | Comment on the individual foreign key constraint |
| `onDelete` | `string` | Action to perform on delete |
| `onUpdate` | `string` | Action to perform on update |
| `match` | `string` | `FULL` or `SIMPLE` |
| Option | Type | Description |
| ----------------------------- | --------------------------------- | ---------------------------------------------------------------------------------- |
| `columns` | `Name` or `array of Names` | Names of columns |
| `references` | [`Reference`](/migrations/#types) | Names of foreign table and column names |
| `referencesConstraintName` | `string` | Name of the created constraint (only necessary when creating multiple constraints) |
| `referencesConstraintComment` | `string` | Comment on the individual foreign key constraint |
| `onDelete` | `string` | Action to perform on delete |
| `onUpdate` | `string` | Action to perform on update |
| `match` | `string` | `FULL` or `SIMPLE` |

## Reverse Operation: `dropConstraint`

Expand All @@ -51,11 +51,11 @@

### Arguments

| Name | Type | Description |
| ----------------- | ------------------------- | --------------------------------- |
| `tablename` | [Name](/migrations/#type) | Name of the table to alter |
| `constraint_name` | `string` | Name of the constraint |
| `options` | `object` | Check below for available options |
| Name | Type | Description |
| ----------------- | -------------------------- | --------------------------------- |
| `tablename` | [Name](/migrations/#types) | Name of the table to alter |
| `constraint_name` | `string` | Name of the constraint |
| `options` | `object` | Check below for available options |

#### Options

Expand All @@ -75,8 +75,8 @@

### Arguments

| Name | Type | Description |
| --------------------- | ------------------------- | -------------------------- |
| `tablename` | [Name](/migrations/#type) | Name of the table to alter |
| `old_constraint_name` | `string` | Current constraint name |
| `new_constraint_name` | `string` | New constraint name |
| Name | Type | Description |
| --------------------- | -------------------------- | -------------------------- |
| `tablename` | [Name](/migrations/#types) | Name of the table to alter |
| `old_constraint_name` | `string` | Current constraint name |
| `new_constraint_name` | `string` | New constraint name |
Loading
Loading