Skip to content

Commit 7ef349c

Browse files
fix: added more options to alter table query template
1 parent 3287f99 commit 7ef349c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/containers/Tenant/utils/schemaActions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
dropAsyncReplicationTemplate,
2929
dropExternalTableTemplate,
3030
dropTableIndex,
31+
dropTableTemplate,
3132
dropTopicTemplate,
3233
dropViewTemplate,
3334
selectQueryTemplate,
@@ -100,6 +101,7 @@ const bindActions = (
100101
alterAsyncReplication: inputQuery(alterAsyncReplicationTemplate, 'script'),
101102
dropAsyncReplication: inputQuery(dropAsyncReplicationTemplate, 'script'),
102103
alterTable: inputQuery(alterTableTemplate, 'script'),
104+
dropTable: inputQuery(dropTableTemplate, 'script'),
103105
selectQuery: inputQuery(selectQueryTemplate),
104106
upsertQuery: inputQuery(upsertQueryTemplate),
105107
createExternalTable: inputQuery(createExternalTableTemplate, 'script'),
@@ -166,6 +168,7 @@ export const getActions =
166168
[copyItem],
167169
[
168170
{text: i18n('actions.alterTable'), action: actions.alterTable},
171+
{text: i18n('actions.dropTable'), action: actions.dropTable},
169172
{text: i18n('actions.selectQuery'), action: actions.selectQuery},
170173
{text: i18n('actions.upsertQuery'), action: actions.upsertQuery},
171174
{text: i18n('actions.addTableIndex'), action: actions.addTableIndex},

src/containers/Tenant/utils/schemaQueryTemplates.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ WITH (
6868
);`;
6969
};
7070
export const alterTableTemplate = (params?: SchemaQueryParams) => {
71-
return `ALTER TABLE \`${params?.relativePath || '$path'}\`
71+
return `-- docs: https://ydb.tech/docs/en/yql/reference/syntax/alter_table/
72+
73+
ALTER TABLE \`${params?.relativePath || '$path'}\`
74+
-- RENAME TO new_table_name
75+
-- DROP COLUMN some_existing_column
76+
-- ADD COLUMN text_column Utf8 NOT NULL DEFAULT 'default_value'
7277
ADD COLUMN numeric_column Int32;`;
7378
};
7479
export const selectQueryTemplate = (params?: SchemaQueryParams) => {

0 commit comments

Comments
 (0)