add name field for migrations created via run_sql (close #541) (#750)

This commit is contained in:
Shrey
2018-10-15 18:09:27 +05:30
committed by Shahidh K Muhammed
parent fb9407f696
commit 421606f124
3 changed files with 3027 additions and 2995 deletions

5978
console/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -26,7 +26,7 @@ const MODAL_OPEN = 'EditItem/MODAL_OPEN';
const modalOpen = () => ({ type: MODAL_OPEN });
const modalClose = () => ({ type: MODAL_CLOSE });
const executeSQL = isMigration => (dispatch, getState) => {
const executeSQL = (isMigration, migrationName) => (dispatch, getState) => {
dispatch({ type: MAKING_REQUEST });
dispatch(showSuccessNotification('Executing the Query...'));
@@ -78,7 +78,6 @@ const executeSQL = isMigration => (dispatch, getState) => {
// check if its a migration and send to hasuractl migrate
if (isMigration) {
url = migrateUrl;
const migrationName = 'run_sql_migration';
requestBody = {
name: migrationName,
up: schemaChangesUp,

View File

@@ -31,6 +31,12 @@ const migrationTip = (
migrations
</Tooltip>
);
const migrationNameTip = (
<Tooltip id="tooltip-migration">
Use this to change the name of the generated migration files. Defaults to
'run_sql_migration'
</Tooltip>
);
const trackTableTip = (
<Tooltip id="tooltip-tracktable">
If you are creating a table/view, you can track them to query them with
@@ -89,6 +95,11 @@ const RawSQL = ({
if (migrationMode) {
const checkboxElem = document.getElementById('migration-checkbox');
const isMigration = checkboxElem ? checkboxElem.checked : false;
const textboxElem = document.getElementById('migration-name');
let migrationName = textboxElem.value;
if (migrationName.length === 0) {
migrationName = 'run_sql_migration';
}
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();
@@ -101,16 +112,16 @@ const RawSQL = ({
dispatch(modalOpen());
const confirmation = false;
if (confirmation) {
dispatch(executeSQL(isMigration));
dispatch(executeSQL(isMigration, migrationName));
}
} else {
dispatch(executeSQL(isMigration));
dispatch(executeSQL(isMigration, migrationName));
}
} else {
dispatch(executeSQL(isMigration));
dispatch(executeSQL(isMigration, migrationName));
}
} else {
dispatch(executeSQL(false));
dispatch(executeSQL(false, ''));
}
};
@@ -313,6 +324,28 @@ const RawSQL = ({
aria-hidden="true"
/>
</OverlayTrigger>
<div className={styles.padd_top}>
Migration Name:
<OverlayTrigger placement="right" overlay={migrationNameTip}>
<i
className={`${styles.padd_small_left} fa fa-info-circle`}
aria-hidden="true"
/>
</OverlayTrigger>
</div>
<input
className={
styles.add_mar_right_small +
' ' +
styles.tableNameInput +
' ' +
styles.add_mar_top_small +
' form-control'
}
placeholder={'Name of the generated migration file'}
id="migration-name"
type="text"
/>
<hr />
</div>
) : (