Skip to content

Commit 8c6d852

Browse files
committed
fix broken formatting
1 parent d134e61 commit 8c6d852

File tree

1 file changed

+84
-4
lines changed

1 file changed

+84
-4
lines changed

src/current/_includes/molt/fetch-schema-table-filtering.md

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,91 @@ When migrating from Oracle, you **must** include `--schema-filter` to name an Or
2828
</section>
2929

3030
{% if page.name != "migrate-bulk-load.md" %}
31-
<section class="filter-content" markdown="1" data-scope="mysql">
32-
{% include molt/fetch-table-filter-userscript.md %}
31+
<section class="filter-content" markdown="1" data-scope="oracle">
32+
#### Table filter userscript
33+
34+
When loading a subset of tables using `--table-filter`, you **must** provide a TypeScript userscript to specify which tables to replicate.
35+
36+
For example, the following `table_filter.ts` userscript filters change events to the specified source tables:
37+
38+
~~~ ts
39+
import * as api from "replicator@v1";
40+
41+
// List the source tables (matching source names and casing) to include in replication
42+
const allowedTables = ["EMPLOYEES", "PAYMENTS", "ORDERS"];
43+
44+
// Update this to your target CockroachDB database and schema name
45+
api.configureSource("molt.migration_schema", {
46+
dispatch: (doc: Document, meta: Document): Record<Table, Document[]> | null => {
47+
// Replicate only if the table matches one of the allowed tables
48+
if (allowedTables.includes(meta.table)) {
49+
let ret: Record<Table, Document[]> = {};
50+
ret[meta.table] = [doc];
51+
return ret;
52+
}
53+
// Ignore all other tables
54+
return null;
55+
},
56+
deletesTo: (doc: Document, meta: Document): Record<Table, Document[]> | null => {
57+
// Optionally filter deletes the same way
58+
if (allowedTables.includes(meta.table)) {
59+
let ret: Record<Table, Document[]> = {};
60+
ret[meta.table] = [doc];
61+
return ret;
62+
}
63+
return null;
64+
},
65+
});
66+
~~~
67+
68+
Pass the userscript to MOLT Replicator with the `--userscript` [flag](#replication-flags):
69+
70+
~~~
71+
--userscript table_filter.ts
72+
~~~
3373
</section>
3474

35-
<section class="filter-content" markdown="1" data-scope="oracle">
36-
{% include molt/fetch-table-filter-userscript.md %}
75+
<section class="filter-content" markdown="1" data-scope="mysql">
76+
#### Table filter userscript
77+
78+
When loading a subset of tables using `--table-filter`, you **must** provide a TypeScript userscript to specify which tables to replicate.
79+
80+
For example, the following `table_filter.ts` userscript filters change events to the specified source tables:
81+
82+
~~~ ts
83+
import * as api from "replicator@v1";
84+
85+
// List the source tables (matching source names and casing) to include in replication
86+
const allowedTables = ["EMPLOYEES", "PAYMENTS", "ORDERS"];
87+
88+
// Update this to your target CockroachDB database and schema name
89+
api.configureSource("molt.public", {
90+
dispatch: (doc: Document, meta: Document): Record<Table, Document[]> | null => {
91+
// Replicate only if the table matches one of the allowed tables
92+
if (allowedTables.includes(meta.table)) {
93+
let ret: Record<Table, Document[]> = {};
94+
ret[meta.table] = [doc];
95+
return ret;
96+
}
97+
// Ignore all other tables
98+
return null;
99+
},
100+
deletesTo: (doc: Document, meta: Document): Record<Table, Document[]> | null => {
101+
// Optionally filter deletes the same way
102+
if (allowedTables.includes(meta.table)) {
103+
let ret: Record<Table, Document[]> = {};
104+
ret[meta.table] = [doc];
105+
return ret;
106+
}
107+
return null;
108+
},
109+
});
110+
~~~
111+
112+
Pass the userscript to MOLT Replicator with the `--userscript` [flag](#replication-flags):
113+
114+
~~~
115+
--userscript table_filter.ts
116+
~~~
37117
</section>
38118
{% endif %}

0 commit comments

Comments
 (0)