diff --git a/console/src/components/Services/Data/RawSQL/RawSQL.js b/console/src/components/Services/Data/RawSQL/RawSQL.js index 17bcd84d88b07..b7369534d4bbf 100644 --- a/console/src/components/Services/Data/RawSQL/RawSQL.js +++ b/console/src/components/Services/Data/RawSQL/RawSQL.js @@ -84,6 +84,36 @@ const RawSQL = ({ ); } + const submitSQL = () => { + // check migration mode global + if (migrationMode) { + const checkboxElem = document.getElementById('migration-checkbox'); + const isMigration = checkboxElem ? checkboxElem.checked : false; + if (!isMigration && globals.consoleMode === 'cli') { + // if migration is not checked, check if the sql text has any of 'create', 'alter', 'drop' + const formattedSql = sql.toLowerCase(); + if ( + formattedSql.indexOf('create') !== -1 || + formattedSql.indexOf('alter') !== -1 || + formattedSql.indexOf('drop') !== -1 + ) { + // const confirmation = window.confirm('Your SQL Statement has a schema modifying command. Are you sure its not a migration?'); + dispatch(modalOpen()); + const confirmation = false; + if (confirmation) { + dispatch(executeSQL(isMigration)); + } + } else { + dispatch(executeSQL(isMigration)); + } + } else { + dispatch(executeSQL(isMigration)); + } + } else { + dispatch(executeSQL(false)); + } + }; + const onModalClose = () => { dispatch(modalClose()); }; @@ -184,6 +214,15 @@ const RawSQL = ({ maxLines={100} width="100%" showPrintMargin={false} + commands={[ + { + name: 'submit', + bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter' }, + exec: () => { + submitSQL(); + }, + }, + ]} onChange={val => { dispatch({ type: SET_SQL, data: val }); const formattedSql = val.toLowerCase(); @@ -282,37 +321,7 @@ const RawSQL = ({