@supabase/pg-delta 1.0.0-alpha.0 → 1.0.0-alpha.1
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/dist/cli/utils/integrations.d.ts +4 -3
- package/dist/cli/utils/integrations.js +25 -16
- package/dist/core/fingerprint.d.ts +0 -8
- package/dist/core/fingerprint.js +2 -2
- package/dist/core/integrations/filter/dsl.d.ts +1 -1
- package/dist/core/integrations/filter/filter.types.d.ts +2 -0
- package/dist/core/integrations/filter/filter.types.js +1 -0
- package/dist/core/integrations/integration.types.d.ts +2 -1
- package/dist/core/integrations/serialize/dsl.d.ts +1 -1
- package/dist/core/integrations/serialize/serialize.types.d.ts +2 -0
- package/dist/core/integrations/serialize/serialize.types.js +1 -0
- package/dist/core/integrations/supabase.d.ts +10 -0
- package/dist/core/integrations/supabase.js +114 -0
- package/dist/core/objects/aggregate/aggregate.model.d.ts +8 -8
- package/dist/core/objects/materialized-view/materialized-view.model.d.ts +3 -3
- package/dist/core/objects/procedure/procedure.model.d.ts +9 -9
- package/dist/core/objects/rls-policy/rls-policy.model.d.ts +2 -2
- package/dist/core/objects/role/role.model.d.ts +3 -3
- package/dist/core/objects/rule/rule.model.d.ts +1 -1
- package/dist/core/objects/table/table.model.d.ts +22 -22
- package/dist/core/objects/type/composite-type/composite-type.model.d.ts +3 -3
- package/dist/core/objects/view/view.model.d.ts +3 -3
- package/dist/core/plan/index.d.ts +1 -2
- package/dist/core/plan/index.js +0 -1
- package/dist/core/plan/types.d.ts +4 -15
- package/dist/index.d.ts +9 -1
- package/dist/index.js +8 -1
- package/package.json +5 -2
- package/dist/core/index.d.ts +0 -15
- package/dist/core/index.js +0 -14
- package/dist/core/main.d.ts +0 -5
- package/dist/core/main.js +0 -44
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { IntegrationDSL } from "../../core/integrations/integration-dsl.ts";
|
|
5
5
|
/**
|
|
6
|
-
* Load an integration DSL from a
|
|
7
|
-
* If the path ends with .json, treats it as a file path directly.
|
|
8
|
-
* Otherwise, tries to load from core
|
|
6
|
+
* Load an integration DSL from a file or core integration.
|
|
7
|
+
* If the path ends with .json, treats it as a JSON file path directly.
|
|
8
|
+
* Otherwise, tries to load from core integrations (TypeScript) first,
|
|
9
|
+
* then falls back to treating as a JSON file path.
|
|
9
10
|
*
|
|
10
11
|
* @param nameOrPath - Integration name (e.g., "supabase") or file path (e.g., "./my-integration.json")
|
|
11
12
|
* @returns The loaded IntegrationDSL
|
|
@@ -1,35 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utilities for loading integrations from files.
|
|
3
3
|
*/
|
|
4
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
5
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
6
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
7
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return path;
|
|
11
|
+
};
|
|
4
12
|
import { readFile } from "node:fs/promises";
|
|
5
|
-
import { dirname, join } from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = dirname(__filename);
|
|
9
13
|
/**
|
|
10
|
-
* Load an integration DSL from a
|
|
11
|
-
* If the path ends with .json, treats it as a file path directly.
|
|
12
|
-
* Otherwise, tries to load from core
|
|
14
|
+
* Load an integration DSL from a file or core integration.
|
|
15
|
+
* If the path ends with .json, treats it as a JSON file path directly.
|
|
16
|
+
* Otherwise, tries to load from core integrations (TypeScript) first,
|
|
17
|
+
* then falls back to treating as a JSON file path.
|
|
13
18
|
*
|
|
14
19
|
* @param nameOrPath - Integration name (e.g., "supabase") or file path (e.g., "./my-integration.json")
|
|
15
20
|
* @returns The loaded IntegrationDSL
|
|
16
21
|
*/
|
|
17
22
|
export async function loadIntegrationDSL(nameOrPath) {
|
|
18
|
-
// If path ends with .json, treat it as a file path directly
|
|
23
|
+
// If path ends with .json, treat it as a JSON file path directly
|
|
19
24
|
if (nameOrPath.endsWith(".json")) {
|
|
20
25
|
const content = await readFile(nameOrPath, "utf-8");
|
|
21
26
|
return JSON.parse(content);
|
|
22
27
|
}
|
|
23
|
-
// Try loading from core
|
|
24
|
-
// __dirname is src/cli/utils, so we go up to src/ then into core/integrations
|
|
25
|
-
const coreIntegrationsPath = join(__dirname, "../../core/integrations", `${nameOrPath}.json`);
|
|
28
|
+
// Try loading from core integrations (TypeScript) first
|
|
26
29
|
try {
|
|
27
|
-
const
|
|
28
|
-
|
|
30
|
+
const module = await import(__rewriteRelativeImportExtension(`../../core/integrations/${nameOrPath}.ts`));
|
|
31
|
+
// Core integrations export using the integration name directly (e.g., "supabase")
|
|
32
|
+
const integrationName = nameOrPath;
|
|
33
|
+
if (integrationName in module) {
|
|
34
|
+
return module[integrationName];
|
|
35
|
+
}
|
|
36
|
+
// If no matching export, fall through to JSON file loading
|
|
29
37
|
}
|
|
30
38
|
catch {
|
|
31
|
-
//
|
|
32
|
-
const content = await readFile(nameOrPath, "utf-8");
|
|
33
|
-
return JSON.parse(content);
|
|
39
|
+
// Module not found or not a core integration, fall through to JSON file loading
|
|
34
40
|
}
|
|
41
|
+
// Fallback to treating as JSON file path
|
|
42
|
+
const content = await readFile(nameOrPath, "utf-8");
|
|
43
|
+
return JSON.parse(content);
|
|
35
44
|
}
|
|
@@ -13,11 +13,3 @@ export declare function buildPlanScopeFingerprint(catalog: Catalog, changes: Cha
|
|
|
13
13
|
* Compute a fingerprint from a catalog and a set of stableIds.
|
|
14
14
|
*/
|
|
15
15
|
export declare function hashStableIds(catalog: Catalog, stableIds: string[]): string;
|
|
16
|
-
/**
|
|
17
|
-
* Hash a string to hex SHA256.
|
|
18
|
-
*/
|
|
19
|
-
export declare function sha256(input: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Collect the union of stableIds referenced by all changes.
|
|
22
|
-
*/
|
|
23
|
-
export declare function collectStableIds(changes: Change[]): string[];
|
package/dist/core/fingerprint.js
CHANGED
|
@@ -31,13 +31,13 @@ export function hashStableIds(catalog, stableIds) {
|
|
|
31
31
|
/**
|
|
32
32
|
* Hash a string to hex SHA256.
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
function sha256(input) {
|
|
35
35
|
return crypto.createHash("sha256").update(input).digest("hex");
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Collect the union of stableIds referenced by all changes.
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
function collectStableIds(changes) {
|
|
41
41
|
const ids = new Set();
|
|
42
42
|
for (const change of changes) {
|
|
43
43
|
for (const id of getChangeStableIds(change)) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Filter DSL - A serializable domain-specific language for change filtering.
|
|
3
3
|
*/
|
|
4
4
|
import type { Change } from "../../change.types.ts";
|
|
5
|
-
import type { ChangeFilter } from "
|
|
5
|
+
import type { ChangeFilter } from "./filter.types.ts";
|
|
6
6
|
/**
|
|
7
7
|
* Core properties that all changes have.
|
|
8
8
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ChangeFilter
|
|
1
|
+
import type { ChangeFilter } from "./filter/filter.types.ts";
|
|
2
|
+
import type { ChangeSerializer } from "./serialize/serialize.types.ts";
|
|
2
3
|
export type Integration = {
|
|
3
4
|
filter?: ChangeFilter;
|
|
4
5
|
serialize?: ChangeSerializer;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Reuses the filter pattern matching logic to determine when to apply serialization options.
|
|
5
5
|
*/
|
|
6
|
-
import type { ChangeSerializer } from "../../main.ts";
|
|
7
6
|
import { type FilterPattern } from "../filter/dsl.ts";
|
|
7
|
+
import type { ChangeSerializer } from "./serialize.types.ts";
|
|
8
8
|
/**
|
|
9
9
|
* Serialization options that can be passed to change.serialize().
|
|
10
10
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase integration - filtering and serialization rules for Supabase databases.
|
|
3
|
+
*
|
|
4
|
+
* This integration:
|
|
5
|
+
* - Filters out Supabase system schemas and roles
|
|
6
|
+
* - Includes user schemas and extensions
|
|
7
|
+
* - Skips authorization for schema creates owned by Supabase system roles
|
|
8
|
+
*/
|
|
9
|
+
import type { IntegrationDSL } from "./integration-dsl.ts";
|
|
10
|
+
export declare const supabase: IntegrationDSL;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase integration - filtering and serialization rules for Supabase databases.
|
|
3
|
+
*
|
|
4
|
+
* This integration:
|
|
5
|
+
* - Filters out Supabase system schemas and roles
|
|
6
|
+
* - Includes user schemas and extensions
|
|
7
|
+
* - Skips authorization for schema creates owned by Supabase system roles
|
|
8
|
+
*/
|
|
9
|
+
// Supabase system schemas that should be excluded
|
|
10
|
+
const SUPABASE_SYSTEM_SCHEMAS = [
|
|
11
|
+
"_analytics",
|
|
12
|
+
"_realtime",
|
|
13
|
+
"_supavisor",
|
|
14
|
+
"auth",
|
|
15
|
+
"cron",
|
|
16
|
+
"extensions",
|
|
17
|
+
"graphql",
|
|
18
|
+
"graphql_public",
|
|
19
|
+
"information_schema",
|
|
20
|
+
"net",
|
|
21
|
+
"pgbouncer",
|
|
22
|
+
"pgmq",
|
|
23
|
+
"pgmq_public",
|
|
24
|
+
"pgsodium",
|
|
25
|
+
"pgsodium_masks",
|
|
26
|
+
"pgtle",
|
|
27
|
+
"realtime",
|
|
28
|
+
"storage",
|
|
29
|
+
"supabase_functions",
|
|
30
|
+
"supabase_migrations",
|
|
31
|
+
"vault",
|
|
32
|
+
];
|
|
33
|
+
// Supabase system roles that should be excluded
|
|
34
|
+
const SUPABASE_SYSTEM_ROLES = [
|
|
35
|
+
"anon",
|
|
36
|
+
"authenticated",
|
|
37
|
+
"authenticator",
|
|
38
|
+
"dashboard_user",
|
|
39
|
+
"pgbouncer",
|
|
40
|
+
"pgsodium_keyholder",
|
|
41
|
+
"pgsodium_keyiduser",
|
|
42
|
+
"pgsodium_keymaker",
|
|
43
|
+
"pgtle_admin",
|
|
44
|
+
"service_role",
|
|
45
|
+
"supabase_admin",
|
|
46
|
+
"supabase_auth_admin",
|
|
47
|
+
"supabase_etl_admin",
|
|
48
|
+
"supabase_functions_admin",
|
|
49
|
+
"supabase_read_only_user",
|
|
50
|
+
"supabase_realtime_admin",
|
|
51
|
+
"supabase_replication_admin",
|
|
52
|
+
"supabase_storage_admin",
|
|
53
|
+
];
|
|
54
|
+
export const supabase = {
|
|
55
|
+
filter: {
|
|
56
|
+
or: [
|
|
57
|
+
{
|
|
58
|
+
and: [
|
|
59
|
+
{
|
|
60
|
+
type: "schema",
|
|
61
|
+
operation: "create",
|
|
62
|
+
scope: "object",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
not: {
|
|
66
|
+
schema: [...SUPABASE_SYSTEM_SCHEMAS],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: "extension",
|
|
73
|
+
operation: "create",
|
|
74
|
+
scope: "object",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
not: {
|
|
78
|
+
or: [
|
|
79
|
+
{
|
|
80
|
+
schema: [...SUPABASE_SYSTEM_SCHEMAS],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
owner: [...SUPABASE_SYSTEM_ROLES],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
and: [
|
|
87
|
+
{
|
|
88
|
+
type: "role",
|
|
89
|
+
scope: "membership",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
member: [...SUPABASE_SYSTEM_ROLES],
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
serialize: [
|
|
102
|
+
{
|
|
103
|
+
when: {
|
|
104
|
+
type: "schema",
|
|
105
|
+
operation: "create",
|
|
106
|
+
scope: "object",
|
|
107
|
+
owner: [...SUPABASE_SYSTEM_ROLES],
|
|
108
|
+
},
|
|
109
|
+
options: {
|
|
110
|
+
skipAuthorization: true,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
};
|
|
@@ -16,9 +16,9 @@ declare const aggregatePropsSchema: z.ZodObject<{
|
|
|
16
16
|
return_type: z.ZodString;
|
|
17
17
|
return_type_schema: z.ZodNullable<z.ZodString>;
|
|
18
18
|
parallel_safety: z.ZodEnum<{
|
|
19
|
+
r: "r";
|
|
19
20
|
u: "u";
|
|
20
21
|
s: "s";
|
|
21
|
-
r: "r";
|
|
22
22
|
}>;
|
|
23
23
|
is_strict: z.ZodBoolean;
|
|
24
24
|
transition_function: z.ZodString;
|
|
@@ -28,8 +28,8 @@ declare const aggregatePropsSchema: z.ZodObject<{
|
|
|
28
28
|
final_function: z.ZodNullable<z.ZodString>;
|
|
29
29
|
final_function_extra_args: z.ZodBoolean;
|
|
30
30
|
final_function_modify: z.ZodNullable<z.ZodEnum<{
|
|
31
|
-
s: "s";
|
|
32
31
|
r: "r";
|
|
32
|
+
s: "s";
|
|
33
33
|
w: "w";
|
|
34
34
|
}>>;
|
|
35
35
|
combine_function: z.ZodNullable<z.ZodString>;
|
|
@@ -44,8 +44,8 @@ declare const aggregatePropsSchema: z.ZodObject<{
|
|
|
44
44
|
moving_final_function: z.ZodNullable<z.ZodString>;
|
|
45
45
|
moving_final_function_extra_args: z.ZodBoolean;
|
|
46
46
|
moving_final_function_modify: z.ZodNullable<z.ZodEnum<{
|
|
47
|
-
s: "s";
|
|
48
47
|
r: "r";
|
|
48
|
+
s: "s";
|
|
49
49
|
w: "w";
|
|
50
50
|
}>>;
|
|
51
51
|
moving_initial_condition: z.ZodNullable<z.ZodString>;
|
|
@@ -56,8 +56,8 @@ declare const aggregatePropsSchema: z.ZodObject<{
|
|
|
56
56
|
argument_types: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
57
57
|
all_argument_types: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
58
58
|
argument_modes: z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
59
|
-
i: "i";
|
|
60
59
|
o: "o";
|
|
60
|
+
i: "i";
|
|
61
61
|
b: "b";
|
|
62
62
|
v: "v";
|
|
63
63
|
t: "t";
|
|
@@ -129,7 +129,7 @@ export declare class Aggregate extends BasePgModel {
|
|
|
129
129
|
num_direct_args: number;
|
|
130
130
|
return_type: string;
|
|
131
131
|
return_type_schema: string | null;
|
|
132
|
-
parallel_safety: "
|
|
132
|
+
parallel_safety: "r" | "u" | "s";
|
|
133
133
|
is_strict: boolean;
|
|
134
134
|
transition_function: string;
|
|
135
135
|
state_data_type: string;
|
|
@@ -137,7 +137,7 @@ export declare class Aggregate extends BasePgModel {
|
|
|
137
137
|
state_data_space: number;
|
|
138
138
|
final_function: string | null;
|
|
139
139
|
final_function_extra_args: boolean;
|
|
140
|
-
final_function_modify: "
|
|
140
|
+
final_function_modify: "r" | "s" | "w" | null;
|
|
141
141
|
combine_function: string | null;
|
|
142
142
|
serial_function: string | null;
|
|
143
143
|
deserial_function: string | null;
|
|
@@ -149,7 +149,7 @@ export declare class Aggregate extends BasePgModel {
|
|
|
149
149
|
moving_state_data_space: number | null;
|
|
150
150
|
moving_final_function: string | null;
|
|
151
151
|
moving_final_function_extra_args: boolean;
|
|
152
|
-
moving_final_function_modify: "
|
|
152
|
+
moving_final_function_modify: "r" | "s" | "w" | null;
|
|
153
153
|
moving_initial_condition: string | null;
|
|
154
154
|
sort_operator: string | null;
|
|
155
155
|
argument_count: number;
|
|
@@ -157,7 +157,7 @@ export declare class Aggregate extends BasePgModel {
|
|
|
157
157
|
argument_names: string[] | null;
|
|
158
158
|
argument_types: string[] | null;
|
|
159
159
|
all_argument_types: string[] | null;
|
|
160
|
-
argument_modes: ("
|
|
160
|
+
argument_modes: ("o" | "i" | "b" | "v" | "t")[] | null;
|
|
161
161
|
argument_defaults: string | null;
|
|
162
162
|
identity_arguments: string;
|
|
163
163
|
owner: string;
|
|
@@ -14,10 +14,10 @@ declare const materializedViewPropsSchema: z.ZodObject<{
|
|
|
14
14
|
has_subclasses: z.ZodBoolean;
|
|
15
15
|
is_populated: z.ZodBoolean;
|
|
16
16
|
replica_identity: z.ZodEnum<{
|
|
17
|
+
f: "f";
|
|
17
18
|
n: "n";
|
|
18
19
|
i: "i";
|
|
19
20
|
d: "d";
|
|
20
|
-
f: "f";
|
|
21
21
|
}>;
|
|
22
22
|
is_partition: z.ZodBoolean;
|
|
23
23
|
options: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
@@ -85,7 +85,7 @@ export declare class MaterializedView extends BasePgModel implements TableLikeOb
|
|
|
85
85
|
has_triggers: boolean;
|
|
86
86
|
has_subclasses: boolean;
|
|
87
87
|
is_populated: boolean;
|
|
88
|
-
replica_identity: "
|
|
88
|
+
replica_identity: "f" | "n" | "i" | "d";
|
|
89
89
|
is_partition: boolean;
|
|
90
90
|
options: string[] | null;
|
|
91
91
|
partition_bound: string | null;
|
|
@@ -133,7 +133,7 @@ export declare class MaterializedView extends BasePgModel implements TableLikeOb
|
|
|
133
133
|
has_triggers: boolean;
|
|
134
134
|
has_subclasses: boolean;
|
|
135
135
|
is_populated: boolean;
|
|
136
|
-
replica_identity: "
|
|
136
|
+
replica_identity: "f" | "n" | "i" | "d";
|
|
137
137
|
is_partition: boolean;
|
|
138
138
|
options: string[] | null;
|
|
139
139
|
partition_bound: string | null;
|
|
@@ -6,24 +6,24 @@ declare const procedurePropsSchema: z.ZodObject<{
|
|
|
6
6
|
schema: z.ZodString;
|
|
7
7
|
name: z.ZodString;
|
|
8
8
|
kind: z.ZodEnum<{
|
|
9
|
-
|
|
9
|
+
f: "f";
|
|
10
10
|
w: "w";
|
|
11
|
+
a: "a";
|
|
11
12
|
p: "p";
|
|
12
|
-
f: "f";
|
|
13
13
|
}>;
|
|
14
14
|
return_type: z.ZodString;
|
|
15
15
|
return_type_schema: z.ZodString;
|
|
16
16
|
language: z.ZodString;
|
|
17
17
|
security_definer: z.ZodBoolean;
|
|
18
18
|
volatility: z.ZodEnum<{
|
|
19
|
-
i: "i";
|
|
20
19
|
s: "s";
|
|
20
|
+
i: "i";
|
|
21
21
|
v: "v";
|
|
22
22
|
}>;
|
|
23
23
|
parallel_safety: z.ZodEnum<{
|
|
24
|
+
r: "r";
|
|
24
25
|
u: "u";
|
|
25
26
|
s: "s";
|
|
26
|
-
r: "r";
|
|
27
27
|
}>;
|
|
28
28
|
execution_cost: z.ZodNumber;
|
|
29
29
|
result_rows: z.ZodNumber;
|
|
@@ -36,8 +36,8 @@ declare const procedurePropsSchema: z.ZodObject<{
|
|
|
36
36
|
argument_types: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
37
37
|
all_argument_types: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
38
38
|
argument_modes: z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
39
|
-
i: "i";
|
|
40
39
|
o: "o";
|
|
40
|
+
i: "i";
|
|
41
41
|
b: "b";
|
|
42
42
|
v: "v";
|
|
43
43
|
t: "t";
|
|
@@ -96,13 +96,13 @@ export declare class Procedure extends BasePgModel {
|
|
|
96
96
|
name: string;
|
|
97
97
|
};
|
|
98
98
|
get dataFields(): {
|
|
99
|
-
kind: "
|
|
99
|
+
kind: "f" | "w" | "a" | "p";
|
|
100
100
|
return_type: string;
|
|
101
101
|
return_type_schema: string;
|
|
102
102
|
language: string;
|
|
103
103
|
security_definer: boolean;
|
|
104
|
-
volatility: "
|
|
105
|
-
parallel_safety: "
|
|
104
|
+
volatility: "s" | "i" | "v";
|
|
105
|
+
parallel_safety: "r" | "u" | "s";
|
|
106
106
|
is_strict: boolean;
|
|
107
107
|
leakproof: boolean;
|
|
108
108
|
returns_set: boolean;
|
|
@@ -111,7 +111,7 @@ export declare class Procedure extends BasePgModel {
|
|
|
111
111
|
argument_names: string[] | null;
|
|
112
112
|
argument_types: string[] | null;
|
|
113
113
|
all_argument_types: string[] | null;
|
|
114
|
-
argument_modes: ("
|
|
114
|
+
argument_modes: ("o" | "i" | "b" | "v" | "t")[] | null;
|
|
115
115
|
argument_defaults: string | null;
|
|
116
116
|
source_code: string | null;
|
|
117
117
|
binary_path: string | null;
|
|
@@ -6,9 +6,9 @@ declare const rlsPolicyPropsSchema: z.ZodObject<{
|
|
|
6
6
|
name: z.ZodString;
|
|
7
7
|
table_name: z.ZodString;
|
|
8
8
|
command: z.ZodEnum<{
|
|
9
|
-
a: "a";
|
|
10
9
|
r: "r";
|
|
11
10
|
w: "w";
|
|
11
|
+
a: "a";
|
|
12
12
|
d: "d";
|
|
13
13
|
"*": "*";
|
|
14
14
|
}>;
|
|
@@ -39,7 +39,7 @@ export declare class RlsPolicy extends BasePgModel {
|
|
|
39
39
|
name: string;
|
|
40
40
|
};
|
|
41
41
|
get dataFields(): {
|
|
42
|
-
command: "
|
|
42
|
+
command: "r" | "w" | "a" | "d" | "*";
|
|
43
43
|
permissive: boolean;
|
|
44
44
|
roles: string[];
|
|
45
45
|
using_expression: string | null;
|
|
@@ -23,11 +23,11 @@ declare const rolePropsSchema: z.ZodObject<{
|
|
|
23
23
|
default_privileges: z.ZodArray<z.ZodObject<{
|
|
24
24
|
in_schema: z.ZodNullable<z.ZodString>;
|
|
25
25
|
objtype: z.ZodEnum<{
|
|
26
|
-
n: "n";
|
|
27
26
|
r: "r";
|
|
28
|
-
f: "f";
|
|
29
27
|
S: "S";
|
|
28
|
+
f: "f";
|
|
30
29
|
T: "T";
|
|
30
|
+
n: "n";
|
|
31
31
|
}>;
|
|
32
32
|
grantee: z.ZodString;
|
|
33
33
|
privileges: z.ZodArray<z.ZodObject<{
|
|
@@ -80,7 +80,7 @@ export declare class Role extends BasePgModel {
|
|
|
80
80
|
grantable: boolean;
|
|
81
81
|
}[];
|
|
82
82
|
in_schema: string | null;
|
|
83
|
-
objtype: "
|
|
83
|
+
objtype: "r" | "S" | "f" | "T" | "n";
|
|
84
84
|
grantee: string;
|
|
85
85
|
}[];
|
|
86
86
|
};
|
|
@@ -3,18 +3,18 @@ import z from "zod";
|
|
|
3
3
|
import { BasePgModel, type TableLikeObject } from "../base.model.ts";
|
|
4
4
|
import { type PrivilegeProps } from "../base.privilege-diff.ts";
|
|
5
5
|
export declare const ReplicaIdentitySchema: z.ZodEnum<{
|
|
6
|
+
f: "f";
|
|
6
7
|
n: "n";
|
|
7
8
|
i: "i";
|
|
8
9
|
d: "d";
|
|
9
|
-
f: "f";
|
|
10
10
|
}>;
|
|
11
11
|
declare const tableConstraintPropsSchema: z.ZodObject<{
|
|
12
12
|
name: z.ZodString;
|
|
13
13
|
constraint_type: z.ZodEnum<{
|
|
14
|
+
f: "f";
|
|
14
15
|
u: "u";
|
|
15
|
-
c: "c";
|
|
16
16
|
p: "p";
|
|
17
|
-
|
|
17
|
+
c: "c";
|
|
18
18
|
x: "x";
|
|
19
19
|
}>;
|
|
20
20
|
deferrable: z.ZodBoolean;
|
|
@@ -37,24 +37,24 @@ declare const tableConstraintPropsSchema: z.ZodObject<{
|
|
|
37
37
|
foreign_key_effective_schema: z.ZodNullable<z.ZodString>;
|
|
38
38
|
foreign_key_effective_table: z.ZodNullable<z.ZodString>;
|
|
39
39
|
on_update: z.ZodNullable<z.ZodEnum<{
|
|
40
|
+
r: "r";
|
|
40
41
|
n: "n";
|
|
41
42
|
a: "a";
|
|
42
|
-
r: "r";
|
|
43
43
|
d: "d";
|
|
44
44
|
c: "c";
|
|
45
45
|
}>>;
|
|
46
46
|
on_delete: z.ZodNullable<z.ZodEnum<{
|
|
47
|
+
r: "r";
|
|
47
48
|
n: "n";
|
|
48
49
|
a: "a";
|
|
49
|
-
r: "r";
|
|
50
50
|
d: "d";
|
|
51
51
|
c: "c";
|
|
52
52
|
}>>;
|
|
53
53
|
match_type: z.ZodNullable<z.ZodEnum<{
|
|
54
|
+
f: "f";
|
|
54
55
|
u: "u";
|
|
55
56
|
s: "s";
|
|
56
57
|
p: "p";
|
|
57
|
-
f: "f";
|
|
58
58
|
}>>;
|
|
59
59
|
check_expression: z.ZodNullable<z.ZodString>;
|
|
60
60
|
owner: z.ZodString;
|
|
@@ -78,10 +78,10 @@ declare const tablePropsSchema: z.ZodObject<{
|
|
|
78
78
|
has_subclasses: z.ZodBoolean;
|
|
79
79
|
is_populated: z.ZodBoolean;
|
|
80
80
|
replica_identity: z.ZodEnum<{
|
|
81
|
+
f: "f";
|
|
81
82
|
n: "n";
|
|
82
83
|
i: "i";
|
|
83
84
|
d: "d";
|
|
84
|
-
f: "f";
|
|
85
85
|
}>;
|
|
86
86
|
is_partition: z.ZodBoolean;
|
|
87
87
|
options: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
@@ -112,10 +112,10 @@ declare const tablePropsSchema: z.ZodObject<{
|
|
|
112
112
|
constraints: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
113
113
|
name: z.ZodString;
|
|
114
114
|
constraint_type: z.ZodEnum<{
|
|
115
|
+
f: "f";
|
|
115
116
|
u: "u";
|
|
116
|
-
c: "c";
|
|
117
117
|
p: "p";
|
|
118
|
-
|
|
118
|
+
c: "c";
|
|
119
119
|
x: "x";
|
|
120
120
|
}>;
|
|
121
121
|
deferrable: z.ZodBoolean;
|
|
@@ -138,24 +138,24 @@ declare const tablePropsSchema: z.ZodObject<{
|
|
|
138
138
|
foreign_key_effective_schema: z.ZodNullable<z.ZodString>;
|
|
139
139
|
foreign_key_effective_table: z.ZodNullable<z.ZodString>;
|
|
140
140
|
on_update: z.ZodNullable<z.ZodEnum<{
|
|
141
|
+
r: "r";
|
|
141
142
|
n: "n";
|
|
142
143
|
a: "a";
|
|
143
|
-
r: "r";
|
|
144
144
|
d: "d";
|
|
145
145
|
c: "c";
|
|
146
146
|
}>>;
|
|
147
147
|
on_delete: z.ZodNullable<z.ZodEnum<{
|
|
148
|
+
r: "r";
|
|
148
149
|
n: "n";
|
|
149
150
|
a: "a";
|
|
150
|
-
r: "r";
|
|
151
151
|
d: "d";
|
|
152
152
|
c: "c";
|
|
153
153
|
}>>;
|
|
154
154
|
match_type: z.ZodNullable<z.ZodEnum<{
|
|
155
|
+
f: "f";
|
|
155
156
|
u: "u";
|
|
156
157
|
s: "s";
|
|
157
158
|
p: "p";
|
|
158
|
-
f: "f";
|
|
159
159
|
}>>;
|
|
160
160
|
check_expression: z.ZodNullable<z.ZodString>;
|
|
161
161
|
owner: z.ZodString;
|
|
@@ -204,7 +204,7 @@ export declare class Table extends BasePgModel implements TableLikeObject {
|
|
|
204
204
|
persistence: "u" | "t" | "p";
|
|
205
205
|
row_security: boolean;
|
|
206
206
|
force_row_security: boolean;
|
|
207
|
-
replica_identity: "
|
|
207
|
+
replica_identity: "f" | "n" | "i" | "d";
|
|
208
208
|
options: string[] | null;
|
|
209
209
|
parent_schema: string | null;
|
|
210
210
|
parent_name: string | null;
|
|
@@ -231,7 +231,7 @@ export declare class Table extends BasePgModel implements TableLikeObject {
|
|
|
231
231
|
}[];
|
|
232
232
|
constraints: {
|
|
233
233
|
name: string;
|
|
234
|
-
constraint_type: "
|
|
234
|
+
constraint_type: "f" | "u" | "p" | "c" | "x";
|
|
235
235
|
deferrable: boolean;
|
|
236
236
|
initially_deferred: boolean;
|
|
237
237
|
validated: boolean;
|
|
@@ -251,9 +251,9 @@ export declare class Table extends BasePgModel implements TableLikeObject {
|
|
|
251
251
|
foreign_key_parent_table: string | null;
|
|
252
252
|
foreign_key_effective_schema: string | null;
|
|
253
253
|
foreign_key_effective_table: string | null;
|
|
254
|
-
on_update: "
|
|
255
|
-
on_delete: "
|
|
256
|
-
match_type: "
|
|
254
|
+
on_update: "r" | "n" | "a" | "d" | "c" | null;
|
|
255
|
+
on_delete: "r" | "n" | "a" | "d" | "c" | null;
|
|
256
|
+
match_type: "f" | "u" | "s" | "p" | null;
|
|
257
257
|
check_expression: string | null;
|
|
258
258
|
owner: string;
|
|
259
259
|
definition: string;
|
|
@@ -292,7 +292,7 @@ export declare class Table extends BasePgModel implements TableLikeObject {
|
|
|
292
292
|
options: string[] | null;
|
|
293
293
|
constraints: {
|
|
294
294
|
name: string;
|
|
295
|
-
constraint_type: "
|
|
295
|
+
constraint_type: "f" | "u" | "p" | "c" | "x";
|
|
296
296
|
deferrable: boolean;
|
|
297
297
|
initially_deferred: boolean;
|
|
298
298
|
validated: boolean;
|
|
@@ -312,9 +312,9 @@ export declare class Table extends BasePgModel implements TableLikeObject {
|
|
|
312
312
|
foreign_key_parent_table: string | null;
|
|
313
313
|
foreign_key_effective_schema: string | null;
|
|
314
314
|
foreign_key_effective_table: string | null;
|
|
315
|
-
on_update: "
|
|
316
|
-
on_delete: "
|
|
317
|
-
match_type: "
|
|
315
|
+
on_update: "r" | "n" | "a" | "d" | "c" | null;
|
|
316
|
+
on_delete: "r" | "n" | "a" | "d" | "c" | null;
|
|
317
|
+
match_type: "f" | "u" | "s" | "p" | null;
|
|
318
318
|
check_expression: string | null;
|
|
319
319
|
owner: string;
|
|
320
320
|
definition: string;
|
|
@@ -328,7 +328,7 @@ export declare class Table extends BasePgModel implements TableLikeObject {
|
|
|
328
328
|
persistence: "u" | "t" | "p";
|
|
329
329
|
row_security: boolean;
|
|
330
330
|
force_row_security: boolean;
|
|
331
|
-
replica_identity: "
|
|
331
|
+
replica_identity: "f" | "n" | "i" | "d";
|
|
332
332
|
parent_schema: string | null;
|
|
333
333
|
parent_name: string | null;
|
|
334
334
|
partition_bound: string | null;
|
|
@@ -13,10 +13,10 @@ declare const compositeTypePropsSchema: z.ZodObject<{
|
|
|
13
13
|
has_subclasses: z.ZodBoolean;
|
|
14
14
|
is_populated: z.ZodBoolean;
|
|
15
15
|
replica_identity: z.ZodEnum<{
|
|
16
|
+
f: "f";
|
|
16
17
|
n: "n";
|
|
17
18
|
i: "i";
|
|
18
19
|
d: "d";
|
|
19
|
-
f: "f";
|
|
20
20
|
}>;
|
|
21
21
|
is_partition: z.ZodBoolean;
|
|
22
22
|
options: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
@@ -82,7 +82,7 @@ export declare class CompositeType extends BasePgModel implements TableLikeObjec
|
|
|
82
82
|
has_triggers: boolean;
|
|
83
83
|
has_subclasses: boolean;
|
|
84
84
|
is_populated: boolean;
|
|
85
|
-
replica_identity: "
|
|
85
|
+
replica_identity: "f" | "n" | "i" | "d";
|
|
86
86
|
is_partition: boolean;
|
|
87
87
|
options: string[] | null;
|
|
88
88
|
partition_bound: string | null;
|
|
@@ -129,7 +129,7 @@ export declare class CompositeType extends BasePgModel implements TableLikeObjec
|
|
|
129
129
|
has_triggers: boolean;
|
|
130
130
|
has_subclasses: boolean;
|
|
131
131
|
is_populated: boolean;
|
|
132
|
-
replica_identity: "
|
|
132
|
+
replica_identity: "f" | "n" | "i" | "d";
|
|
133
133
|
is_partition: boolean;
|
|
134
134
|
options: string[] | null;
|
|
135
135
|
partition_bound: string | null;
|
|
@@ -14,10 +14,10 @@ declare const viewPropsSchema: z.ZodObject<{
|
|
|
14
14
|
has_subclasses: z.ZodBoolean;
|
|
15
15
|
is_populated: z.ZodBoolean;
|
|
16
16
|
replica_identity: z.ZodEnum<{
|
|
17
|
+
f: "f";
|
|
17
18
|
n: "n";
|
|
18
19
|
i: "i";
|
|
19
20
|
d: "d";
|
|
20
|
-
f: "f";
|
|
21
21
|
}>;
|
|
22
22
|
is_partition: z.ZodBoolean;
|
|
23
23
|
options: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
@@ -85,7 +85,7 @@ export declare class View extends BasePgModel implements TableLikeObject {
|
|
|
85
85
|
has_triggers: boolean;
|
|
86
86
|
has_subclasses: boolean;
|
|
87
87
|
is_populated: boolean;
|
|
88
|
-
replica_identity: "
|
|
88
|
+
replica_identity: "f" | "n" | "i" | "d";
|
|
89
89
|
is_partition: boolean;
|
|
90
90
|
options: string[] | null;
|
|
91
91
|
partition_bound: string | null;
|
|
@@ -133,7 +133,7 @@ export declare class View extends BasePgModel implements TableLikeObject {
|
|
|
133
133
|
has_triggers: boolean;
|
|
134
134
|
has_subclasses: boolean;
|
|
135
135
|
is_populated: boolean;
|
|
136
|
-
replica_identity: "
|
|
136
|
+
replica_identity: "f" | "n" | "i" | "d";
|
|
137
137
|
is_partition: boolean;
|
|
138
138
|
options: string[] | null;
|
|
139
139
|
partition_bound: string | null;
|
|
@@ -14,6 +14,5 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
export { createPlan } from "./create.ts";
|
|
17
|
-
export { groupChangesHierarchically } from "./hierarchy.ts";
|
|
18
17
|
export { deserializePlan, serializePlan } from "./io.ts";
|
|
19
|
-
export type { ChangeEntry, ChangeGroup,
|
|
18
|
+
export type { ChangeEntry, ChangeGroup, HierarchicalPlan, Plan, } from "./types.ts";
|
package/dist/core/plan/index.js
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import z from "zod";
|
|
5
5
|
import type { Change } from "../change.types.ts";
|
|
6
6
|
import type { FilterDSL } from "../integrations/filter/dsl.ts";
|
|
7
|
+
import type { ChangeFilter } from "../integrations/filter/filter.types.ts";
|
|
7
8
|
import type { SerializeDSL } from "../integrations/serialize/dsl.ts";
|
|
8
|
-
import type {
|
|
9
|
+
import type { ChangeSerializer } from "../integrations/serialize/serialize.types.ts";
|
|
9
10
|
export type PlanRisk = {
|
|
10
11
|
level: "safe";
|
|
11
12
|
} | {
|
|
@@ -16,24 +17,11 @@ export type PlanRisk = {
|
|
|
16
17
|
* All supported object types in the system.
|
|
17
18
|
* Derived from the Change union type's objectType discriminant.
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Cluster-wide object types (no schema).
|
|
22
|
-
*/
|
|
23
|
-
export type ClusterObjectType = Extract<ObjectType, "event_trigger" | "foreign_data_wrapper" | "language" | "publication" | "role" | "server" | "subscription" | "user_mapping">;
|
|
24
|
-
/**
|
|
25
|
-
* Object types that are children of tables/views.
|
|
26
|
-
*/
|
|
27
|
-
export type ChildObjectType = Extract<ObjectType, "index" | "trigger" | "rule" | "rls_policy">;
|
|
20
|
+
type ObjectType = Change["objectType"];
|
|
28
21
|
/**
|
|
29
22
|
* Parent types for child objects.
|
|
30
23
|
*/
|
|
31
24
|
export type ParentType = Extract<ObjectType, "table" | "view" | "materialized_view" | "foreign_table">;
|
|
32
|
-
/**
|
|
33
|
-
* Change scopes - what aspect of an object is being changed.
|
|
34
|
-
* Derived from the Change union type's scope property.
|
|
35
|
-
*/
|
|
36
|
-
export type ChangeScope = Change["scope"];
|
|
37
25
|
/**
|
|
38
26
|
* A change entry storing both serialized and original change for instanceof checks.
|
|
39
27
|
*/
|
|
@@ -151,3 +139,4 @@ export interface CreatePlanOptions {
|
|
|
151
139
|
/** Role to use when executing the migration (SET ROLE will be added to statements) */
|
|
152
140
|
role?: string;
|
|
153
141
|
}
|
|
142
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @supabase/pg-delta - PostgreSQL migrations made easy
|
|
3
|
+
*
|
|
4
|
+
* This module exports the public API for the pg-delta library.
|
|
5
|
+
*/
|
|
6
|
+
export type { IntegrationDSL } from "./core/integrations/integration-dsl.ts";
|
|
7
|
+
export { applyPlan } from "./core/plan/apply.ts";
|
|
8
|
+
export { createPlan } from "./core/plan/create.ts";
|
|
9
|
+
export type { CreatePlanOptions, Plan } from "./core/plan/types.ts";
|
package/dist/index.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @supabase/pg-delta - PostgreSQL migrations made easy
|
|
3
|
+
*
|
|
4
|
+
* This module exports the public API for the pg-delta library.
|
|
5
|
+
*/
|
|
6
|
+
export { applyPlan } from "./core/plan/apply.js";
|
|
7
|
+
// Core operations
|
|
8
|
+
export { createPlan } from "./core/plan/create.js";
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supabase/pg-delta",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"description": "PostgreSQL migrations made easy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"exports":
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./integrations/supabase": "./dist/core/integrations/supabase.js"
|
|
10
|
+
},
|
|
8
11
|
"bin": {
|
|
9
12
|
"pgdelta": "./dist/cli/bin/cli.js"
|
|
10
13
|
},
|
package/dist/core/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @supabase/pg-delta - PostgreSQL migrations made easy
|
|
3
|
-
*
|
|
4
|
-
* This module exports the public API for the pg-delta library.
|
|
5
|
-
*/
|
|
6
|
-
export type { ChangeGroup, ChangeScope, ChildObjectType, ClusterGroup, ClusterObjectType, CreatePlanOptions, HierarchicalPlan, MaterializedViewChildren, ObjectType, ParentType, Plan, SchemaGroup, TableChildren, TypeGroup, } from "./plan/index.ts";
|
|
7
|
-
export { createPlan, groupChangesHierarchically, } from "./plan/index.ts";
|
|
8
|
-
export type { Integration } from "./integrations/integration.types.ts";
|
|
9
|
-
export { diffCatalogs } from "./catalog.diff.ts";
|
|
10
|
-
export { Catalog, extractCatalog } from "./catalog.model.ts";
|
|
11
|
-
export type { Change } from "./change.types.ts";
|
|
12
|
-
export type { DiffContext } from "./context.ts";
|
|
13
|
-
export { buildPlanScopeFingerprint, collectStableIds, hashStableIds, sha256, } from "./fingerprint.ts";
|
|
14
|
-
export { postgresConfig } from "./postgres-config.ts";
|
|
15
|
-
export { sortChanges } from "./sort/sort-changes.ts";
|
package/dist/core/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @supabase/pg-delta - PostgreSQL migrations made easy
|
|
3
|
-
*
|
|
4
|
-
* This module exports the public API for the pg-delta library.
|
|
5
|
-
*/
|
|
6
|
-
export { createPlan, groupChangesHierarchically, } from "./plan/index.js";
|
|
7
|
-
// =============================================================================
|
|
8
|
-
// Low-level APIs (for advanced usage)
|
|
9
|
-
// =============================================================================
|
|
10
|
-
export { diffCatalogs } from "./catalog.diff.js";
|
|
11
|
-
export { Catalog, extractCatalog } from "./catalog.model.js";
|
|
12
|
-
export { buildPlanScopeFingerprint, collectStableIds, hashStableIds, sha256, } from "./fingerprint.js";
|
|
13
|
-
export { postgresConfig } from "./postgres-config.js";
|
|
14
|
-
export { sortChanges } from "./sort/sort-changes.js";
|
package/dist/core/main.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Change } from "./change.types.ts";
|
|
2
|
-
import type { Integration } from "./integrations/integration.types.ts";
|
|
3
|
-
export type ChangeFilter = (change: Change) => boolean;
|
|
4
|
-
export type ChangeSerializer = (change: Change) => string | undefined;
|
|
5
|
-
export type MainOptions = Integration;
|
package/dist/core/main.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import postgres from "postgres";
|
|
2
|
-
import { diffCatalogs } from "./catalog.diff.js";
|
|
3
|
-
import { extractCatalog } from "./catalog.model.js";
|
|
4
|
-
import { postgresConfig } from "./postgres-config.js";
|
|
5
|
-
import { sortChanges } from "./sort/sort-changes.js";
|
|
6
|
-
async function _main(mainDatabaseUrl, branchDatabaseUrl, options = {}) {
|
|
7
|
-
const mainSql = postgres(mainDatabaseUrl, postgresConfig);
|
|
8
|
-
const branchSql = postgres(branchDatabaseUrl, postgresConfig);
|
|
9
|
-
const [mainCatalog, branchCatalog] = await Promise.all([
|
|
10
|
-
extractCatalog(mainSql),
|
|
11
|
-
extractCatalog(branchSql),
|
|
12
|
-
]);
|
|
13
|
-
await Promise.all([mainSql.end(), branchSql.end()]);
|
|
14
|
-
const changes = diffCatalogs(mainCatalog, branchCatalog);
|
|
15
|
-
// Use provided options as integration (optional)
|
|
16
|
-
const integration = options ?? {};
|
|
17
|
-
// Apply filter if provided
|
|
18
|
-
const ctx = { mainCatalog, branchCatalog };
|
|
19
|
-
let filteredChanges = changes;
|
|
20
|
-
const integrationFilter = integration.filter;
|
|
21
|
-
if (integrationFilter) {
|
|
22
|
-
filteredChanges = filteredChanges.filter((change) => integrationFilter(change));
|
|
23
|
-
}
|
|
24
|
-
if (filteredChanges.length === 0) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
const sortedChanges = sortChanges(ctx, filteredChanges);
|
|
28
|
-
const hasRoutineChanges = sortedChanges.some((change) => change.objectType === "procedure" || change.objectType === "aggregate");
|
|
29
|
-
const sessionConfig = hasRoutineChanges
|
|
30
|
-
? ["SET check_function_bodies = false"]
|
|
31
|
-
: [];
|
|
32
|
-
// Build migration script
|
|
33
|
-
const scriptParts = [];
|
|
34
|
-
scriptParts.push(...sessionConfig);
|
|
35
|
-
// Serialize changes using integration serialize hook (applies masking) or fallback
|
|
36
|
-
const changeStatements = sortedChanges.map((change) => {
|
|
37
|
-
return integration.serialize?.(change) ?? change.serialize();
|
|
38
|
-
});
|
|
39
|
-
scriptParts.push(...changeStatements);
|
|
40
|
-
const migrationScript = `${scriptParts.join(";\n\n")};`;
|
|
41
|
-
return {
|
|
42
|
-
migrationScript,
|
|
43
|
-
};
|
|
44
|
-
}
|