@systemfsoftware/timescale-drizzle 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +286 -228
- package/dist/cli.js +35 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +90 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +85 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -40,6 +40,34 @@ type GrantSnapshot = {
|
|
|
40
40
|
export declare function pgGrant(config: RelationGrantConfig): PgGrant;
|
|
41
41
|
export declare function pgGrant(config: FunctionGrantConfig): PgGrant;
|
|
42
42
|
export declare function pgGrant(config: SchemaGrantConfig): PgGrant;
|
|
43
|
+
type TimescaleServer = {
|
|
44
|
+
readonly [KIND]: 'timescaleServer';
|
|
45
|
+
readonly databasesWithExtension: number;
|
|
46
|
+
readonly concurrentJobs: number;
|
|
47
|
+
readonly parallelWorkers: number;
|
|
48
|
+
readonly reservedPostgresWorkers: number;
|
|
49
|
+
readonly preloadLibraries: readonly string[];
|
|
50
|
+
readonly settings: Readonly<Record<string, string>>;
|
|
51
|
+
readonly postgresArgs: readonly string[];
|
|
52
|
+
};
|
|
53
|
+
type TimescaleServerConfig = {
|
|
54
|
+
databasesWithExtension: number;
|
|
55
|
+
concurrentJobs: number;
|
|
56
|
+
parallelWorkers?: number;
|
|
57
|
+
reservedPostgresWorkers?: number;
|
|
58
|
+
preloadLibraries?: readonly string[];
|
|
59
|
+
};
|
|
60
|
+
export declare function timescaleServer(config: TimescaleServerConfig): TimescaleServer;
|
|
61
|
+
export declare function declaredJobCount(extras: PgExtras): number;
|
|
62
|
+
export declare function assertTimescaleServer(extras: PgExtras): void;
|
|
63
|
+
export declare function timescaleServerProblems(extras: PgExtras): string[];
|
|
64
|
+
export declare const TIMESCALE_SERVER_SETTINGS_QUERY = "SELECT name, setting, pending_restart FROM pg_settings WHERE name = ANY($1::text[])";
|
|
65
|
+
type LiveSetting = {
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly setting: string;
|
|
68
|
+
readonly pending_restart: boolean;
|
|
69
|
+
};
|
|
70
|
+
export declare function timescaleServerDrift(server: TimescaleServer, rows: readonly LiveSetting[]): string[];
|
|
43
71
|
type ViewCheckOption = 'local' | 'cascaded';
|
|
44
72
|
type PgViewDefinitionConfig = {
|
|
45
73
|
query: string | SQL;
|
|
@@ -406,6 +434,7 @@ type PgExtras = {
|
|
|
406
434
|
continuousAggregates: ContinuousAggregate[];
|
|
407
435
|
viewDefinitions: PgViewDefinition[];
|
|
408
436
|
grants: PgGrant[];
|
|
437
|
+
servers: TimescaleServer[];
|
|
409
438
|
};
|
|
410
439
|
/**
|
|
411
440
|
* Attach a Postgres comment and return the same object.
|
|
@@ -723,6 +752,7 @@ export declare function defineExtras(input: {
|
|
|
723
752
|
continuousAggregates?: readonly ContinuousAggregate[];
|
|
724
753
|
viewDefinitions?: readonly PgViewDefinition[];
|
|
725
754
|
grants?: readonly PgGrant[];
|
|
755
|
+
servers?: readonly TimescaleServer[];
|
|
726
756
|
}): PgExtras;
|
|
727
757
|
type FunctionArgSnapshot = {
|
|
728
758
|
mode: 'in' | 'inout' | 'variadic' | 'out';
|
|
@@ -1030,4 +1060,4 @@ export declare function leaveHypertableDimensionSql(ht: HypertableSnapshot): str
|
|
|
1030
1060
|
export declare function leaveChunkIntervalSql(ht: HypertableSnapshot): string;
|
|
1031
1061
|
export declare function leaveHypertableSql(ht: Pick<HypertableSnapshot, 'schema' | 'name'>): string;
|
|
1032
1062
|
export declare const VERSION: string;
|
|
1033
|
-
export type { AnyPgEnum, CommentSnapshot, ContinuousAggregate, ContinuousAggregateConfig, ContinuousAggregateRefreshPolicy, ContinuousAggregateRefreshPolicyConfig, ContinuousAggregateRefreshPolicySnapshot, ContinuousAggregateSnapshot, ContinuousAggregateSource, ContinuousAggregateSourceSnapshot, DetachSnapshot, ExtensionSnapshot, FunctionCall, FunctionGrantConfig, FunctionPrivilege, FunctionSnapshot, GenerateOptions, GenerateResult, GrantSnapshot, Hypertable, HypertableColumnstore, HypertableColumnstorePolicy, HypertableColumnstorePolicySnapshot, HypertableColumnstoreSnapshot, HypertableOrderSnapshot, HypertableOrderSpec, HypertableRetention, HypertableRetentionSnapshot, HypertableSnapshot, HypertableSparseIndex, HypertableSparseIndexSnapshot, PartitionBound, PartitionBoundSpec, PartitionMethod, PartitionParent, PartitionSnapshot, PartitionedTable, PartitionedTableSnapshot, PgComment, PgCommentTarget, PgDetach, PgExtension, PgExtras, PgFunction, PgFunctionArg, PgFunctionColumn, PgFunctionConfig, PgFunctionReturns, PgGrant, PgLanguage, PgPartition, PgSecurity, PgTrigger, PgViewDefinition, PgViewDefinitionConfig, PgViewLike, PgVolatility, RelationGrantConfig, RelationPrivilege, RowRefs, SchemaGrantConfig, SchemaInput, SchemaPrivilege, Snapshot, SqlDiff, TriggerArg, TriggerConstraint, TriggerEvent, TriggerForEach, TriggerInitially, TriggerReferencing, TriggerRelation, TriggerSnapshot, TriggerTiming, ViewCheckOption, ViewSnapshot };
|
|
1063
|
+
export type { AnyPgEnum, CommentSnapshot, ContinuousAggregate, ContinuousAggregateConfig, ContinuousAggregateRefreshPolicy, ContinuousAggregateRefreshPolicyConfig, ContinuousAggregateRefreshPolicySnapshot, ContinuousAggregateSnapshot, ContinuousAggregateSource, ContinuousAggregateSourceSnapshot, DetachSnapshot, ExtensionSnapshot, FunctionCall, FunctionGrantConfig, FunctionPrivilege, FunctionSnapshot, GenerateOptions, GenerateResult, GrantSnapshot, Hypertable, HypertableColumnstore, HypertableColumnstorePolicy, HypertableColumnstorePolicySnapshot, HypertableColumnstoreSnapshot, HypertableOrderSnapshot, HypertableOrderSpec, HypertableRetention, HypertableRetentionSnapshot, HypertableSnapshot, HypertableSparseIndex, HypertableSparseIndexSnapshot, LiveSetting, PartitionBound, PartitionBoundSpec, PartitionMethod, PartitionParent, PartitionSnapshot, PartitionedTable, PartitionedTableSnapshot, PgComment, PgCommentTarget, PgDetach, PgExtension, PgExtras, PgFunction, PgFunctionArg, PgFunctionColumn, PgFunctionConfig, PgFunctionReturns, PgGrant, PgLanguage, PgPartition, PgSecurity, PgTrigger, PgViewDefinition, PgViewDefinitionConfig, PgViewLike, PgVolatility, RelationGrantConfig, RelationPrivilege, RowRefs, SchemaGrantConfig, SchemaInput, SchemaPrivilege, Snapshot, SqlDiff, TimescaleServer, TimescaleServerConfig, TriggerArg, TriggerConstraint, TriggerEvent, TriggerForEach, TriggerInitially, TriggerReferencing, TriggerRelation, TriggerSnapshot, TriggerTiming, ViewCheckOption, ViewSnapshot };
|
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,34 @@ type GrantSnapshot = {
|
|
|
40
40
|
export declare function pgGrant(config: RelationGrantConfig): PgGrant;
|
|
41
41
|
export declare function pgGrant(config: FunctionGrantConfig): PgGrant;
|
|
42
42
|
export declare function pgGrant(config: SchemaGrantConfig): PgGrant;
|
|
43
|
+
type TimescaleServer = {
|
|
44
|
+
readonly [KIND]: 'timescaleServer';
|
|
45
|
+
readonly databasesWithExtension: number;
|
|
46
|
+
readonly concurrentJobs: number;
|
|
47
|
+
readonly parallelWorkers: number;
|
|
48
|
+
readonly reservedPostgresWorkers: number;
|
|
49
|
+
readonly preloadLibraries: readonly string[];
|
|
50
|
+
readonly settings: Readonly<Record<string, string>>;
|
|
51
|
+
readonly postgresArgs: readonly string[];
|
|
52
|
+
};
|
|
53
|
+
type TimescaleServerConfig = {
|
|
54
|
+
databasesWithExtension: number;
|
|
55
|
+
concurrentJobs: number;
|
|
56
|
+
parallelWorkers?: number;
|
|
57
|
+
reservedPostgresWorkers?: number;
|
|
58
|
+
preloadLibraries?: readonly string[];
|
|
59
|
+
};
|
|
60
|
+
export declare function timescaleServer(config: TimescaleServerConfig): TimescaleServer;
|
|
61
|
+
export declare function declaredJobCount(extras: PgExtras): number;
|
|
62
|
+
export declare function assertTimescaleServer(extras: PgExtras): void;
|
|
63
|
+
export declare function timescaleServerProblems(extras: PgExtras): string[];
|
|
64
|
+
export declare const TIMESCALE_SERVER_SETTINGS_QUERY = "SELECT name, setting, pending_restart FROM pg_settings WHERE name = ANY($1::text[])";
|
|
65
|
+
type LiveSetting = {
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly setting: string;
|
|
68
|
+
readonly pending_restart: boolean;
|
|
69
|
+
};
|
|
70
|
+
export declare function timescaleServerDrift(server: TimescaleServer, rows: readonly LiveSetting[]): string[];
|
|
43
71
|
type ViewCheckOption = 'local' | 'cascaded';
|
|
44
72
|
type PgViewDefinitionConfig = {
|
|
45
73
|
query: string | SQL;
|
|
@@ -406,6 +434,7 @@ type PgExtras = {
|
|
|
406
434
|
continuousAggregates: ContinuousAggregate[];
|
|
407
435
|
viewDefinitions: PgViewDefinition[];
|
|
408
436
|
grants: PgGrant[];
|
|
437
|
+
servers: TimescaleServer[];
|
|
409
438
|
};
|
|
410
439
|
/**
|
|
411
440
|
* Attach a Postgres comment and return the same object.
|
|
@@ -723,6 +752,7 @@ export declare function defineExtras(input: {
|
|
|
723
752
|
continuousAggregates?: readonly ContinuousAggregate[];
|
|
724
753
|
viewDefinitions?: readonly PgViewDefinition[];
|
|
725
754
|
grants?: readonly PgGrant[];
|
|
755
|
+
servers?: readonly TimescaleServer[];
|
|
726
756
|
}): PgExtras;
|
|
727
757
|
type FunctionArgSnapshot = {
|
|
728
758
|
mode: 'in' | 'inout' | 'variadic' | 'out';
|
|
@@ -1030,4 +1060,4 @@ export declare function leaveHypertableDimensionSql(ht: HypertableSnapshot): str
|
|
|
1030
1060
|
export declare function leaveChunkIntervalSql(ht: HypertableSnapshot): string;
|
|
1031
1061
|
export declare function leaveHypertableSql(ht: Pick<HypertableSnapshot, 'schema' | 'name'>): string;
|
|
1032
1062
|
export declare const VERSION: string;
|
|
1033
|
-
export type { AnyPgEnum, CommentSnapshot, ContinuousAggregate, ContinuousAggregateConfig, ContinuousAggregateRefreshPolicy, ContinuousAggregateRefreshPolicyConfig, ContinuousAggregateRefreshPolicySnapshot, ContinuousAggregateSnapshot, ContinuousAggregateSource, ContinuousAggregateSourceSnapshot, DetachSnapshot, ExtensionSnapshot, FunctionCall, FunctionGrantConfig, FunctionPrivilege, FunctionSnapshot, GenerateOptions, GenerateResult, GrantSnapshot, Hypertable, HypertableColumnstore, HypertableColumnstorePolicy, HypertableColumnstorePolicySnapshot, HypertableColumnstoreSnapshot, HypertableOrderSnapshot, HypertableOrderSpec, HypertableRetention, HypertableRetentionSnapshot, HypertableSnapshot, HypertableSparseIndex, HypertableSparseIndexSnapshot, PartitionBound, PartitionBoundSpec, PartitionMethod, PartitionParent, PartitionSnapshot, PartitionedTable, PartitionedTableSnapshot, PgComment, PgCommentTarget, PgDetach, PgExtension, PgExtras, PgFunction, PgFunctionArg, PgFunctionColumn, PgFunctionConfig, PgFunctionReturns, PgGrant, PgLanguage, PgPartition, PgSecurity, PgTrigger, PgViewDefinition, PgViewDefinitionConfig, PgViewLike, PgVolatility, RelationGrantConfig, RelationPrivilege, RowRefs, SchemaGrantConfig, SchemaInput, SchemaPrivilege, Snapshot, SqlDiff, TriggerArg, TriggerConstraint, TriggerEvent, TriggerForEach, TriggerInitially, TriggerReferencing, TriggerRelation, TriggerSnapshot, TriggerTiming, ViewCheckOption, ViewSnapshot };
|
|
1063
|
+
export type { AnyPgEnum, CommentSnapshot, ContinuousAggregate, ContinuousAggregateConfig, ContinuousAggregateRefreshPolicy, ContinuousAggregateRefreshPolicyConfig, ContinuousAggregateRefreshPolicySnapshot, ContinuousAggregateSnapshot, ContinuousAggregateSource, ContinuousAggregateSourceSnapshot, DetachSnapshot, ExtensionSnapshot, FunctionCall, FunctionGrantConfig, FunctionPrivilege, FunctionSnapshot, GenerateOptions, GenerateResult, GrantSnapshot, Hypertable, HypertableColumnstore, HypertableColumnstorePolicy, HypertableColumnstorePolicySnapshot, HypertableColumnstoreSnapshot, HypertableOrderSnapshot, HypertableOrderSpec, HypertableRetention, HypertableRetentionSnapshot, HypertableSnapshot, HypertableSparseIndex, HypertableSparseIndexSnapshot, LiveSetting, PartitionBound, PartitionBoundSpec, PartitionMethod, PartitionParent, PartitionSnapshot, PartitionedTable, PartitionedTableSnapshot, PgComment, PgCommentTarget, PgDetach, PgExtension, PgExtras, PgFunction, PgFunctionArg, PgFunctionColumn, PgFunctionConfig, PgFunctionReturns, PgGrant, PgLanguage, PgPartition, PgSecurity, PgTrigger, PgViewDefinition, PgViewDefinitionConfig, PgViewLike, PgVolatility, RelationGrantConfig, RelationPrivilege, RowRefs, SchemaGrantConfig, SchemaInput, SchemaPrivilege, Snapshot, SqlDiff, TimescaleServer, TimescaleServerConfig, TriggerArg, TriggerConstraint, TriggerEvent, TriggerForEach, TriggerInitially, TriggerReferencing, TriggerRelation, TriggerSnapshot, TriggerTiming, ViewCheckOption, ViewSnapshot };
|
package/dist/index.js
CHANGED
|
@@ -105,7 +105,7 @@ function brand(value, kind) {
|
|
|
105
105
|
function extrasKind(value) {
|
|
106
106
|
if (typeof value !== "object" || value === null) return null;
|
|
107
107
|
const kind = value[KIND];
|
|
108
|
-
if (kind === "function" || kind === "trigger" || kind === "extension" || kind === "comment" || kind === "partitionedTable" || kind === "partition" || kind === "detach" || kind === "hypertable" || kind === "continuousAggregate" || kind === "viewDefinition" || kind === "grant") return kind;
|
|
108
|
+
if (kind === "function" || kind === "trigger" || kind === "extension" || kind === "comment" || kind === "partitionedTable" || kind === "partition" || kind === "detach" || kind === "hypertable" || kind === "continuousAggregate" || kind === "viewDefinition" || kind === "grant" || kind === "timescaleServer") return kind;
|
|
109
109
|
return null;
|
|
110
110
|
}
|
|
111
111
|
function requireComment(comment, where) {
|
|
@@ -1072,7 +1072,8 @@ function collectExtras(modules) {
|
|
|
1072
1072
|
hypertables: [],
|
|
1073
1073
|
continuousAggregates: [],
|
|
1074
1074
|
viewDefinitions: [],
|
|
1075
|
-
grants: []
|
|
1075
|
+
grants: [],
|
|
1076
|
+
servers: []
|
|
1076
1077
|
};
|
|
1077
1078
|
const seen = /* @__PURE__ */ new Set();
|
|
1078
1079
|
const list = Array.isArray(modules) ? modules : [modules];
|
|
@@ -1098,7 +1099,8 @@ function defineExtras(input) {
|
|
|
1098
1099
|
hypertables: input.hypertables ?? [],
|
|
1099
1100
|
continuousAggregates: input.continuousAggregates ?? [],
|
|
1100
1101
|
viewDefinitions: input.viewDefinitions ?? [],
|
|
1101
|
-
grants: input.grants ?? []
|
|
1102
|
+
grants: input.grants ?? [],
|
|
1103
|
+
servers: input.servers ?? []
|
|
1102
1104
|
});
|
|
1103
1105
|
}
|
|
1104
1106
|
function walk(value, extras, seen) {
|
|
@@ -1161,6 +1163,10 @@ function walk(value, extras, seen) {
|
|
|
1161
1163
|
for (const dependency of definition.dependsOn) walk(dependency, extras, seen);
|
|
1162
1164
|
return;
|
|
1163
1165
|
}
|
|
1166
|
+
if (kind === "timescaleServer") {
|
|
1167
|
+
extras.servers.push(value);
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1164
1170
|
if (kind === "grant") {
|
|
1165
1171
|
const grant = value;
|
|
1166
1172
|
extras.grants.push(grant);
|
|
@@ -4173,8 +4179,80 @@ function bumpStamp(stamp) {
|
|
|
4173
4179
|
const at = Date.UTC(Number(stamp.slice(0, 4)), Number(stamp.slice(4, 6)) - 1, Number(stamp.slice(6, 8)), Number(stamp.slice(8, 10)), Number(stamp.slice(10, 12)), Number(stamp.slice(12, 14)));
|
|
4174
4180
|
return utcStamp(new Date(at + 1e3));
|
|
4175
4181
|
}
|
|
4182
|
+
// src/server.ts
|
|
4183
|
+
const TIMESCALE_LAUNCHER = 1;
|
|
4184
|
+
const POSTGRES_PARALLEL_PER_GATHER_DEFAULT = 2;
|
|
4185
|
+
function count(where, name, value, minimum) {
|
|
4186
|
+
if (!Number.isInteger(value) || value < minimum) throw new PgExtrasError(`${where}: ${name} must be an integer of at least ${minimum}; got ${value}`);
|
|
4187
|
+
return value;
|
|
4188
|
+
}
|
|
4189
|
+
function timescaleServer(config) {
|
|
4190
|
+
const where = "timescaleServer";
|
|
4191
|
+
const databasesWithExtension = count(where, "databasesWithExtension", config.databasesWithExtension, 1);
|
|
4192
|
+
const concurrentJobs = count(where, "concurrentJobs", config.concurrentJobs, 0);
|
|
4193
|
+
const parallelWorkers = count(where, "parallelWorkers", config.parallelWorkers ?? 0, 0);
|
|
4194
|
+
const reservedPostgresWorkers = count(where, "reservedPostgresWorkers", config.reservedPostgresWorkers ?? 4, 0);
|
|
4195
|
+
const preloadLibraries = [...config.preloadLibraries ?? ["timescaledb"]];
|
|
4196
|
+
if (!preloadLibraries.includes("timescaledb")) throw new PgExtrasError(`${where}: preloadLibraries must include timescaledb, or its jobs never start`);
|
|
4197
|
+
for (const library of preloadLibraries) if (!/^[A-Za-z0-9_]+$/.test(library)) throw new PgExtrasError(`${where}: preload library "${library}" is not a plain library name`);
|
|
4198
|
+
const backgroundWorkers = databasesWithExtension + concurrentJobs;
|
|
4199
|
+
const perGather = Math.min(parallelWorkers, POSTGRES_PARALLEL_PER_GATHER_DEFAULT);
|
|
4200
|
+
const settings = {
|
|
4201
|
+
shared_preload_libraries: preloadLibraries.join(","),
|
|
4202
|
+
"timescaledb.max_background_workers": String(backgroundWorkers),
|
|
4203
|
+
max_parallel_workers: String(parallelWorkers),
|
|
4204
|
+
max_parallel_workers_per_gather: String(perGather),
|
|
4205
|
+
max_parallel_maintenance_workers: String(perGather),
|
|
4206
|
+
max_worker_processes: String(TIMESCALE_LAUNCHER + backgroundWorkers + parallelWorkers + reservedPostgresWorkers)
|
|
4207
|
+
};
|
|
4208
|
+
return brand({
|
|
4209
|
+
databasesWithExtension,
|
|
4210
|
+
concurrentJobs,
|
|
4211
|
+
parallelWorkers,
|
|
4212
|
+
reservedPostgresWorkers,
|
|
4213
|
+
preloadLibraries,
|
|
4214
|
+
settings,
|
|
4215
|
+
postgresArgs: Object.entries(settings).flatMap(([name, value]) => ["-c", `${name}=${value}`])
|
|
4216
|
+
}, "timescaleServer");
|
|
4217
|
+
}
|
|
4218
|
+
function hypertableJobs(hypertable) {
|
|
4219
|
+
return [
|
|
4220
|
+
hypertable.columnstorePolicy,
|
|
4221
|
+
hypertable.retention,
|
|
4222
|
+
hypertable.reorder
|
|
4223
|
+
].filter((job) => job !== null).length;
|
|
4224
|
+
}
|
|
4225
|
+
function aggregateJobs(aggregate) {
|
|
4226
|
+
return aggregate.refreshPolicies.length + [aggregate.columnstorePolicy, aggregate.retention].filter((job) => job !== null).length;
|
|
4227
|
+
}
|
|
4228
|
+
function declaredJobCount(extras) {
|
|
4229
|
+
return extras.hypertables.reduce((sum, hypertable) => sum + hypertableJobs(hypertable), 0) + extras.continuousAggregates.reduce((sum, aggregate) => sum + aggregateJobs(aggregate), 0);
|
|
4230
|
+
}
|
|
4231
|
+
function assertTimescaleServer(extras) {
|
|
4232
|
+
const problems = timescaleServerProblems(extras);
|
|
4233
|
+
if (problems.length > 0) throw new PgExtrasError(`timescaleServer: ${problems.join("; ")}`);
|
|
4234
|
+
}
|
|
4235
|
+
function timescaleServerProblems(extras) {
|
|
4236
|
+
if (extras.servers.length === 0) return [];
|
|
4237
|
+
if (extras.servers.length > 1) return [`the schema declares ${extras.servers.length} timescaleServer values; declare one`];
|
|
4238
|
+
const server = extras.servers[0];
|
|
4239
|
+
const jobs = declaredJobCount(extras);
|
|
4240
|
+
if (jobs > 0 && server.concurrentJobs === 0) return [`the schema declares ${jobs} TimescaleDB jobs and its timescaleServer allows 0 concurrent jobs`];
|
|
4241
|
+
return [];
|
|
4242
|
+
}
|
|
4243
|
+
const TIMESCALE_SERVER_SETTINGS_QUERY = "SELECT name, setting, pending_restart FROM pg_settings WHERE name = ANY($1::text[])";
|
|
4244
|
+
const comparable = (name, value) => name === "shared_preload_libraries" ? value.split(",").map((library) => library.trim()).filter((library) => library !== "").join(",") : value;
|
|
4245
|
+
function timescaleServerDrift(server, rows) {
|
|
4246
|
+
return Object.entries(server.settings).flatMap(([name, declared]) => {
|
|
4247
|
+
const live = rows.find((row) => row.name === name);
|
|
4248
|
+
if (!live) return [`${name}: the server does not report it; declared ${declared}`];
|
|
4249
|
+
if (live.pending_restart) return [`${name}: changed but waiting on a restart; declared ${declared}`];
|
|
4250
|
+
if (comparable(name, live.setting) !== comparable(name, declared)) return [`${name}: the server runs ${live.setting}; declared ${declared}`];
|
|
4251
|
+
return [];
|
|
4252
|
+
});
|
|
4253
|
+
}
|
|
4176
4254
|
// src/version.ts
|
|
4177
|
-
const VERSION = "0.
|
|
4255
|
+
const VERSION = "0.10.0";
|
|
4178
4256
|
// src/generate.ts
|
|
4179
4257
|
const UP_HEADER = `-- Generated by timescale-drizzle ${VERSION}. Review before applying.`;
|
|
4180
4258
|
const DOWN_HEADER = `-- Down SQL for timescale-drizzle ${VERSION}. drizzle-kit migrate does not run this file.`;
|
|
@@ -4188,6 +4266,7 @@ function loadStoredSnapshot(out) {
|
|
|
4188
4266
|
}
|
|
4189
4267
|
}
|
|
4190
4268
|
function planExtras(extras, previous, casing) {
|
|
4269
|
+
assertTimescaleServer(extras);
|
|
4191
4270
|
const next = snapshotExtras(extras, casing ? { casing } : void 0);
|
|
4192
4271
|
return {
|
|
4193
4272
|
next,
|
|
@@ -4222,8 +4301,9 @@ function pendingStatements(extras, out, casing) {
|
|
|
4222
4301
|
return planExtras(extras, loadStoredSnapshot(out), casing).up;
|
|
4223
4302
|
}
|
|
4224
4303
|
function renderIdempotent(extras, options) {
|
|
4304
|
+
assertTimescaleServer(extras);
|
|
4225
4305
|
return joinStatements(idempotentStatements(snapshotExtras(extras, options?.casing ? { casing: options.casing } : void 0)), options?.breakpoints ?? true, UP_HEADER);
|
|
4226
4306
|
}
|
|
4227
|
-
export { BREAKPOINT, PgExtrasError, VERSION, addColumnstorePolicySql, addContinuousAggregateColumnstorePolicySql, addContinuousAggregateRefreshPoliciesSql, addContinuousAggregateRetentionPolicySql, addHypertableDimensionSql, addReorderPolicySql, addRetentionPolicySql, alterContinuousAggregateChunkIntervalSql, alterContinuousAggregateRealTimeSql, alterTriggerEnabledSql, attachPartitionSql, collectExtras, commentOn, commentSql, continuousAggregate, convertPartitionedTableSql, createContinuousAggregateSql, createContinuousAggregateStatements, createExtensionSql, createFunctionSql, createHypertableSql, createHypertableStatements, createPartitionSql, createTriggerSql, defineExtras, detachPartitionSql, diffSnapshots, disableHypertableColumnstoreSql, dropContinuousAggregateSql, dropExtensionSql, dropFunctionSql, dropPartitionSql, dropTriggerSql, emptySnapshot, enableContinuousAggregateColumnstoreSql, enableHypertableColumnstoreSql, generate, hypertable, idempotentStatements, joinStatements, leaveChunkIntervalSql, leaveHypertableDimensionSql, leaveHypertableSql, loadStoredSnapshot, parseSnapshot, partitionedTable, pendingStatements, pgAttachPartition, pgDetachPartition, pgExtension, pgFunction, pgGrant, pgPartition, pgTrigger, planExtras, readComment, removeColumnstorePolicySql, removeContinuousAggregateColumnstorePolicySql, removeContinuousAggregatePolicies, removeContinuousAggregateRefreshPolicySql, removeContinuousAggregateRetentionPolicySql, removeReorderPolicySql, removeRetentionPolicySql, renderIdempotent, setChunkTimeIntervalSql, snapshotExtras, splitMigrationSql, updatedAtTrigger, viewDefinition, withComment };
|
|
4307
|
+
export { BREAKPOINT, PgExtrasError, TIMESCALE_SERVER_SETTINGS_QUERY, VERSION, addColumnstorePolicySql, addContinuousAggregateColumnstorePolicySql, addContinuousAggregateRefreshPoliciesSql, addContinuousAggregateRetentionPolicySql, addHypertableDimensionSql, addReorderPolicySql, addRetentionPolicySql, alterContinuousAggregateChunkIntervalSql, alterContinuousAggregateRealTimeSql, alterTriggerEnabledSql, assertTimescaleServer, attachPartitionSql, collectExtras, commentOn, commentSql, continuousAggregate, convertPartitionedTableSql, createContinuousAggregateSql, createContinuousAggregateStatements, createExtensionSql, createFunctionSql, createHypertableSql, createHypertableStatements, createPartitionSql, createTriggerSql, declaredJobCount, defineExtras, detachPartitionSql, diffSnapshots, disableHypertableColumnstoreSql, dropContinuousAggregateSql, dropExtensionSql, dropFunctionSql, dropPartitionSql, dropTriggerSql, emptySnapshot, enableContinuousAggregateColumnstoreSql, enableHypertableColumnstoreSql, generate, hypertable, idempotentStatements, joinStatements, leaveChunkIntervalSql, leaveHypertableDimensionSql, leaveHypertableSql, loadStoredSnapshot, parseSnapshot, partitionedTable, pendingStatements, pgAttachPartition, pgDetachPartition, pgExtension, pgFunction, pgGrant, pgPartition, pgTrigger, planExtras, readComment, removeColumnstorePolicySql, removeContinuousAggregateColumnstorePolicySql, removeContinuousAggregatePolicies, removeContinuousAggregateRefreshPolicySql, removeContinuousAggregateRetentionPolicySql, removeReorderPolicySql, removeRetentionPolicySql, renderIdempotent, setChunkTimeIntervalSql, snapshotExtras, splitMigrationSql, timescaleServer, timescaleServerDrift, timescaleServerProblems, updatedAtTrigger, viewDefinition, withComment };
|
|
4228
4308
|
|
|
4229
4309
|
//# sourceMappingURL=index.js.map
|