From 7ef349ce69bfbf111b463f6ee2ebe4990cc17bb6 Mon Sep 17 00:00:00 2001 From: Anton Kovalenko Date: Sun, 3 Nov 2024 18:16:41 +0100 Subject: [PATCH 1/3] fix: added more options to alter table query template --- src/containers/Tenant/utils/schemaActions.ts | 3 +++ src/containers/Tenant/utils/schemaQueryTemplates.ts | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/containers/Tenant/utils/schemaActions.ts b/src/containers/Tenant/utils/schemaActions.ts index 04bed6ab4..66a0fbf3e 100644 --- a/src/containers/Tenant/utils/schemaActions.ts +++ b/src/containers/Tenant/utils/schemaActions.ts @@ -28,6 +28,7 @@ import { dropAsyncReplicationTemplate, dropExternalTableTemplate, dropTableIndex, + dropTableTemplate, dropTopicTemplate, dropViewTemplate, selectQueryTemplate, @@ -100,6 +101,7 @@ const bindActions = ( alterAsyncReplication: inputQuery(alterAsyncReplicationTemplate, 'script'), dropAsyncReplication: inputQuery(dropAsyncReplicationTemplate, 'script'), alterTable: inputQuery(alterTableTemplate, 'script'), + dropTable: inputQuery(dropTableTemplate, 'script'), selectQuery: inputQuery(selectQueryTemplate), upsertQuery: inputQuery(upsertQueryTemplate), createExternalTable: inputQuery(createExternalTableTemplate, 'script'), @@ -166,6 +168,7 @@ export const getActions = [copyItem], [ {text: i18n('actions.alterTable'), action: actions.alterTable}, + {text: i18n('actions.dropTable'), action: actions.dropTable}, {text: i18n('actions.selectQuery'), action: actions.selectQuery}, {text: i18n('actions.upsertQuery'), action: actions.upsertQuery}, {text: i18n('actions.addTableIndex'), action: actions.addTableIndex}, diff --git a/src/containers/Tenant/utils/schemaQueryTemplates.ts b/src/containers/Tenant/utils/schemaQueryTemplates.ts index eb0f100a7..72015dd06 100644 --- a/src/containers/Tenant/utils/schemaQueryTemplates.ts +++ b/src/containers/Tenant/utils/schemaQueryTemplates.ts @@ -68,7 +68,12 @@ WITH ( );`; }; export const alterTableTemplate = (params?: SchemaQueryParams) => { - return `ALTER TABLE \`${params?.relativePath || '$path'}\` + return `-- docs: https://ydb.tech/docs/en/yql/reference/syntax/alter_table/ + +ALTER TABLE \`${params?.relativePath || '$path'}\` + -- RENAME TO new_table_name + -- DROP COLUMN some_existing_column + -- ADD COLUMN text_column Utf8 NOT NULL DEFAULT 'default_value' ADD COLUMN numeric_column Int32;`; }; export const selectQueryTemplate = (params?: SchemaQueryParams) => { From 2b80e22585a5c4f6e2aafad08b945f8f6c8fbebc Mon Sep 17 00:00:00 2001 From: Anton Kovalenko Date: Mon, 4 Nov 2024 13:47:25 +0100 Subject: [PATCH 2/3] fix: rename create cdc action, add create cdc to a table --- src/containers/Tenant/Query/NewSQL/i18n/en.json | 2 +- src/containers/Tenant/i18n/en.json | 1 + src/containers/Tenant/utils/schemaActions.ts | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/containers/Tenant/Query/NewSQL/i18n/en.json b/src/containers/Tenant/Query/NewSQL/i18n/en.json index d08599580..3484a226a 100644 --- a/src/containers/Tenant/Query/NewSQL/i18n/en.json +++ b/src/containers/Tenant/Query/NewSQL/i18n/en.json @@ -21,7 +21,7 @@ "action.create-topic": "Create Topic", "action.drop-topic": "Drop Topic", "action.alter-topic": "Alter Topic", - "action.create-cdc-stream": "Create CDC Stream", + "action.create-cdc-stream": "Create changefeed", "action.create-async-replication": "Create async replication", "action.create-user": "Create user", "action.create-group": "Create group", diff --git a/src/containers/Tenant/i18n/en.json b/src/containers/Tenant/i18n/en.json index 3d5795d22..0cba4a7a9 100644 --- a/src/containers/Tenant/i18n/en.json +++ b/src/containers/Tenant/i18n/en.json @@ -38,6 +38,7 @@ "actions.dropView": "Drop view...", "actions.alterTable": "Alter table...", "actions.addTableIndex": "Add index...", + "actions.createCdcStream": "Create changefeed...", "actions.alterTopic": "Alter topic...", "actions.selectQuery": "Select query...", "actions.upsertQuery": "Upsert query...", diff --git a/src/containers/Tenant/utils/schemaActions.ts b/src/containers/Tenant/utils/schemaActions.ts index 66a0fbf3e..b107e2a5f 100644 --- a/src/containers/Tenant/utils/schemaActions.ts +++ b/src/containers/Tenant/utils/schemaActions.ts @@ -20,6 +20,7 @@ import { alterTableTemplate, alterTopicTemplate, createAsyncReplicationTemplate, + createCdcStreamTemplate, createColumnTableTemplate, createExternalTableTemplate, createTableTemplate, @@ -114,6 +115,7 @@ const bindActions = ( dropView: inputQuery(dropViewTemplate, 'script'), dropIndex: inputQuery(dropTableIndex, 'script'), addTableIndex: inputQuery(addTableIndex, 'script'), + createCdcStream: inputQuery(createCdcStreamTemplate, 'script'), copyPath: () => { try { copy(params.relativePath); @@ -172,6 +174,7 @@ export const getActions = {text: i18n('actions.selectQuery'), action: actions.selectQuery}, {text: i18n('actions.upsertQuery'), action: actions.upsertQuery}, {text: i18n('actions.addTableIndex'), action: actions.addTableIndex}, + {text: i18n('actions.createCdcStream'), action: actions.createCdcStream}, ], ]; From fcc1e1407ffba11b4f30e61b0271b68d7faf050d Mon Sep 17 00:00:00 2001 From: Anton Kovalenko Date: Tue, 5 Nov 2024 15:34:28 +0100 Subject: [PATCH 3/3] fix: removed default value for add table --- src/containers/Tenant/utils/schemaQueryTemplates.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/containers/Tenant/utils/schemaQueryTemplates.ts b/src/containers/Tenant/utils/schemaQueryTemplates.ts index 72015dd06..5a2159934 100644 --- a/src/containers/Tenant/utils/schemaQueryTemplates.ts +++ b/src/containers/Tenant/utils/schemaQueryTemplates.ts @@ -73,7 +73,6 @@ export const alterTableTemplate = (params?: SchemaQueryParams) => { ALTER TABLE \`${params?.relativePath || '$path'}\` -- RENAME TO new_table_name -- DROP COLUMN some_existing_column - -- ADD COLUMN text_column Utf8 NOT NULL DEFAULT 'default_value' ADD COLUMN numeric_column Int32;`; }; export const selectQueryTemplate = (params?: SchemaQueryParams) => {