Skip to content

Commit 7205874

Browse files
Copilotantonkovalenkoartemmufazalov
authored
feat: add read replicas template for row tables (#3187)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: antonkovalenko <[email protected]> Co-authored-by: mufazalov <[email protected]>
1 parent 2623940 commit 7205874

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

src/containers/Tenant/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"actions.alterTable": "Alter table...",
4444
"actions.manageColumns": "Manage columns...",
4545
"actions.manageAutoPartitioning": "Manage auto partitioning...",
46+
"actions.manageReadReplicas": "Add read-only replicas...",
4647
"actions.addTableIndex": "Add index...",
4748
"actions.addVectorIndex": "Add vector index...",
4849
"actions.createCdcStream": "Create changefeed...",

src/containers/Tenant/utils/schemaActions.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
dropTransferTemplate,
4848
dropViewTemplate,
4949
manageAutoPartitioningTemplate,
50+
manageReadReplicasTemplate,
5051
selectQueryTemplate,
5152
showCreateTableTemplate,
5253
upsertQueryTemplate,
@@ -137,6 +138,7 @@ const bindActions = (
137138
alterTable: inputQuery(alterTableTemplate),
138139
dropTable: inputQuery(dropTableTemplate),
139140
manageAutoPartitioning: inputQuery(manageAutoPartitioningTemplate),
141+
manageReadReplicas: inputQuery(manageReadReplicasTemplate),
140142
selectQuery: inputQuery(selectQueryTemplate),
141143
showCreateTable: inputQuery(showCreateTableTemplate),
142144
upsertQuery: inputQuery(upsertQueryTemplate),
@@ -248,15 +250,23 @@ export const getActions =
248250
{text: i18n('actions.createStreamingQuery'), action: actions.createStreamingQuery},
249251
];
250252

251-
const alterTableGroupItem = {
253+
const manageColumnsItem = {text: i18n('actions.manageColumns'), action: actions.alterTable};
254+
const manageAutoPartitioningItem = {
255+
text: i18n('actions.manageAutoPartitioning'),
256+
action: actions.manageAutoPartitioning,
257+
};
258+
const manageReadReplicasItem = {
259+
text: i18n('actions.manageReadReplicas'),
260+
action: actions.manageReadReplicas,
261+
};
262+
263+
const alterRowTableGroupItem = {
252264
text: i18n('actions.alterTable'),
253-
items: [
254-
{text: i18n('actions.manageColumns'), action: actions.alterTable},
255-
{
256-
text: i18n('actions.manageAutoPartitioning'),
257-
action: actions.manageAutoPartitioning,
258-
},
259-
],
265+
items: [manageColumnsItem, manageAutoPartitioningItem, manageReadReplicasItem],
266+
};
267+
const alterColumnTableGroupItem = {
268+
text: i18n('actions.alterTable'),
269+
items: [manageColumnsItem, manageAutoPartitioningItem],
260270
};
261271

262272
let DB_SET: ActionsSet = [[copyItem, connectToDBItem], createEntitiesSet];
@@ -288,7 +298,7 @@ export const getActions =
288298
const ROW_TABLE_SET: ActionsSet = [
289299
[copyItem],
290300
[
291-
alterTableGroupItem,
301+
alterRowTableGroupItem,
292302
{text: i18n('actions.dropTable'), action: actions.dropTable},
293303
getActionWithLoader({
294304
text: i18n('actions.selectQuery'),
@@ -309,7 +319,7 @@ export const getActions =
309319
const COLUMN_TABLE_SET: ActionsSet = [
310320
[copyItem],
311321
[
312-
alterTableGroupItem,
322+
alterColumnTableGroupItem,
313323
{text: i18n('actions.dropTable'), action: actions.dropTable},
314324
{text: i18n('actions.selectQuery'), action: actions.selectQuery},
315325
{text: i18n('actions.upsertQuery'), action: actions.upsertQuery},

src/containers/Tenant/utils/schemaQueryTemplates.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,18 @@ ALTER TABLE ${path} SET
143143
AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 100 -- Partitions are split only if their number doesn't exceed the value specified by this parameter.
144144
)`;
145145
};
146+
147+
export const manageReadReplicasTemplate = (params?: SchemaQueryParams) => {
148+
const path = params?.relativePath
149+
? `\`${normalizeParameter(params.relativePath)}\``
150+
: '${1:<my_table>}';
151+
152+
return `ALTER TABLE ${path} SET
153+
(
154+
READ_REPLICAS_SETTINGS = 'PER_AZ:1' -- Enable read replicas for stale read, launch one replica in every availability zone. docs: https://clck.ru/3Qh8iQ
155+
)`;
156+
};
157+
146158
export const selectQueryTemplate = (params?: SchemaQueryParams) => {
147159
const path = params?.relativePath
148160
? `\`${normalizeParameter(params.relativePath)}\``

0 commit comments

Comments
 (0)