Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | 135x | /** Partitioning method of a partitioned table. */
export type PartitionStrategy = 'range' | 'list' | 'hash';
/** Marker of a `MINVALUE` / `MAXVALUE` bound inside a range partition bound. */
export type PartitionBoundMarker = Readonly<{
/** Keyword the marker renders as. */
keyword: 'MINVALUE' | 'MAXVALUE';
}>;
/**
* `MINVALUE` and `MAXVALUE` for the `from` / `to` lists of a range partition bound. They are
* markers, not strings, so a string value can never be read as a keyword.
*
* @postgrelize
* @example
* ```ts
* await queryInterface.createPartition('events', 'events_old', {
* from: [PartitionBound.MINVALUE],
* to: ['2020-01-01'],
* });
* ```
*/
export const PartitionBound = {
/** Lowest possible value of a range column. */
MINVALUE: Object.freeze<PartitionBoundMarker>({ keyword: 'MINVALUE' }),
/** Highest possible value of a range column. */
MAXVALUE: Object.freeze<PartitionBoundMarker>({ keyword: 'MAXVALUE' }),
} as const;
/** Element of a partition key: a column, or an expression (trusted SQL) with collation and operator class. */
export type PartitionKeyElement =
| string
| Readonly<{
/** Column name. */
name: string;
/** Collation name. */
collate?: string;
/** Operator class. */
operator?: string;
/** Not used for a column element. */
expression?: undefined;
}>
| Readonly<{
/** Trusted SQL expression, wrapped in parentheses. */
expression: string;
/** Collation name. */
collate?: string;
/** Operator class. */
operator?: string;
/** Not used for an expression element. */
name?: undefined;
}>;
/**
* Partition key of `createTable({ partitionBy })` and of a sub-partitioned partition.
*
* @example
* ```ts
* const key: PartitionKey = { strategy: 'range', columns: ['createdAt'] };
* await queryInterface.createTable('events', { createdAt: DataTypes.DATE }, { partitionBy: key });
* ```
*/
export type PartitionKey = Readonly<{
/** `'range'`, `'list'` or `'hash'`. */
strategy: PartitionStrategy;
/** Key columns or expressions. */
columns: readonly PartitionKeyElement[];
}>;
/**
* Bounds of a partition: `{ in }` (list), `{ from, to }` (range; `PartitionBound.MINVALUE` /
* `MAXVALUE` allowed), `{ modulus, remainder }` (hash) or `{ default: true }`. Values are rendered
* as literals.
*
* @example
* ```ts
* const bound: PartitionBoundSpec = { from: ['2026-01-01'], to: ['2027-01-01'] };
* await queryInterface.createPartition('events', 'events_2026', bound);
* ```
*/
export type PartitionBoundSpec =
| Readonly<{
/** List partition: the values the partition holds. */
in: readonly unknown[];
}>
| Readonly<{
/** Range partition: inclusive lower bound, one value per key column. */
from: readonly unknown[];
/** Range partition: exclusive upper bound, one value per key column. */
to: readonly unknown[];
}>
| Readonly<{
/** Hash partition: modulus. */
modulus: number;
/** Hash partition: remainder, `0 <= remainder < modulus`. */
remainder: number;
}>
| Readonly<{
/** Default partition, receiving rows that match no other partition. */
default: true;
}>;
|