-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
console: don't generate unnecessary migrations (close #4215) #4393
Changes from 1 commit
272cb2a
a6e97ff
edc824e
867e9a7
82f384d
3f7f9f4
0904e93
c77b329
a256a6c
caf870e
f141c28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | |||
---|---|---|---|---|---|
|
@@ -84,8 +84,8 @@ const REMOVE_PRIMARY_KEY = 'ModifyTable/REMOVE_PRIMARY_KEY'; | ||||
const RESET_PRIMARY_KEY = 'ModifyTable/RESET_PRIMARY_KEY'; | |||||
const SET_PRIMARY_KEYS = 'ModifyTable/SET_PRIMARY_KEYS'; | |||||
|
|||||
const SET_COLUMN_EDIT = 'ModifyTable/SET_COLUMN_EDIT;'; | |||||
const RESET_COLUMN_EDIT = 'ModifyTable/RESET_COLUMN_EDIT;'; | |||||
const SET_COLUMN_EDIT = 'ModifyTable/SET_COLUMN_EDIT'; | |||||
const RESET_COLUMN_EDIT = 'ModifyTable/RESET_COLUMN_EDIT'; | |||||
const EDIT_COLUMN = 'ModifyTable/EDIT_COLUMN'; | |||||
|
|||||
const SET_FOREIGN_KEYS = 'ModifyTable/SET_FOREIGN_KEYS'; | |||||
|
@@ -1438,18 +1438,25 @@ const saveTableCommentSql = isTable => { | ||||
}; | |||||
|
|||||
const isColumnUnique = (tableSchema, colName) => { | |||||
beerose marked this conversation as resolved.
Show resolved
Hide resolved
|
|||||
return ( | |||||
tableSchema.unique_constraints.filter( | |||||
const { primary_key, unique_constraints } = tableSchema; | |||||
|
|||||
const columnPkConstraint = | |||||
primary_key.columns.includes(colName) && primary_key.columns.length === 1; | |||||
|
|||||
const columnUniqueConstraint = | |||||
unique_constraints.filter( | |||||
constraint => | |||||
constraint.columns.includes(colName) && constraint.columns.length === 1 | |||||
).length !== 0 | |||||
); | |||||
).length > 0; | |||||
|
|||||
return columnPkConstraint || columnUniqueConstraint; | |||||
}; | |||||
|
|||||
const saveColumnChangesSql = (colName, column, onSuccess) => { | |||||
// eslint-disable-line no-unused-vars | |||||
return (dispatch, getState) => { | |||||
const columnEdit = getState().tables.modify.columnEdit[colName]; | |||||
|
|||||
const { tableName } = columnEdit; | |||||
const colType = columnEdit.type; | |||||
const nullable = columnEdit.isNullable; | |||||
|
@@ -1464,7 +1471,7 @@ const saveColumnChangesSql = (colName, column, onSuccess) => { | ||||
const table = findTable(getState().tables.allSchemas, tableDef); | |||||
|
|||||
// check if column type has changed before making it part of the migration | |||||
const originalColType = column.data_type; // "value" | |||||
const originalColType = column.udt_name; // "value" | |||||
Comment on lines
-1486
to
+1487
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice find! Is Referencing
|
|||||
const originalColDefault = column.column_default || ''; // null or "value" | |||||
const originalColComment = column.comment || ''; // null or "value" | |||||
const originalColNullable = column.is_nullable; // "YES" or "NO" | |||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops ;';