This repository was archived by the owner on Mar 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
skill & skillsProvider removal #126
Open
Sande3p
wants to merge
5
commits into
topcoder-archive:feature/removing_skill_model
Choose a base branch
from
Sande3p:feature/removing_skill_model
base: feature/removing_skill_model
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { DataTypes } = require('sequelize') | ||
|
||
module.exports = { | ||
up: async (query) => { | ||
await query.createTable('Skills', { | ||
id: { | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4 | ||
}, | ||
createdBy: { | ||
type: DataTypes.STRING | ||
}, | ||
updatedBy: { | ||
type: DataTypes.STRING | ||
}, | ||
name: { | ||
type: DataTypes.STRING | ||
}, | ||
externalId: { | ||
type: DataTypes.STRING | ||
}, | ||
uri: { | ||
type: DataTypes.STRING | ||
}, | ||
created: { | ||
type: DataTypes.DATE, | ||
allowNull: false | ||
}, | ||
updated: { | ||
type: DataTypes.DATE | ||
} | ||
}) | ||
}, | ||
down: async (query) => { | ||
await query.dropTable('Skills') | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { DataTypes } = require('sequelize') | ||
|
||
module.exports = { | ||
up: async (query) => { | ||
await query.createTable('SkillsProviders', { | ||
id: { | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4 | ||
}, | ||
createdBy: { | ||
type: DataTypes.STRING | ||
}, | ||
updatedBy: { | ||
type: DataTypes.STRING | ||
}, | ||
name: { | ||
type: DataTypes.STRING | ||
}, | ||
created: { | ||
type: DataTypes.DATE, | ||
allowNull: false | ||
}, | ||
updated: { | ||
type: DataTypes.DATE | ||
} | ||
}) | ||
}, | ||
down: async (query) => { | ||
await query.dropTable('SkillsProviders') | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
const { DataTypes } = require('sequelize') | ||
|
||
module.exports = { | ||
up: async (query) => { | ||
await query.removeColumn('UsersSkills', 'skillId') | ||
await query.removeColumn('OrganizationSkillsProviders', 'skillProviderId') | ||
await query.addColumn('OrganizationSkillsProviders', 'skillProviderId', { | ||
type: DataTypes.UUID | ||
}) | ||
await query.addColumn('UsersSkills', 'skillId', { | ||
type: DataTypes.UUID | ||
}) | ||
await query.dropTable('SkillsProviders') | ||
await query.dropTable('Skills') | ||
}, | ||
down: async (query) => { | ||
await query.createTable('Skills', { | ||
id: { | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4 | ||
}, | ||
createdBy: { | ||
type: DataTypes.STRING | ||
}, | ||
updatedBy: { | ||
type: DataTypes.STRING | ||
}, | ||
name: { | ||
type: DataTypes.STRING | ||
}, | ||
externalId: { | ||
type: DataTypes.STRING | ||
}, | ||
uri: { | ||
type: DataTypes.STRING | ||
}, | ||
created: { | ||
type: DataTypes.DATE, | ||
allowNull: false | ||
}, | ||
updated: { | ||
type: DataTypes.DATE | ||
} | ||
}) | ||
await query.createTable('SkillsProviders', { | ||
id: { | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4 | ||
}, | ||
createdBy: { | ||
type: DataTypes.STRING | ||
}, | ||
updatedBy: { | ||
type: DataTypes.STRING | ||
}, | ||
name: { | ||
type: DataTypes.STRING | ||
}, | ||
created: { | ||
type: DataTypes.DATE, | ||
allowNull: false | ||
}, | ||
updated: { | ||
type: DataTypes.DATE | ||
} | ||
}) | ||
await query.removeColumn('UsersSkills', 'skillId') | ||
await query.removeColumn('OrganizationSkillsProviders', 'skillProviderId') | ||
await query.addColumn('Skills', 'skillProviderId', { | ||
type: DataTypes.UUID, | ||
references: { | ||
model: 'SkillsProviders', | ||
key: 'id' | ||
}, | ||
onUpdate: 'CASCADE' | ||
}) | ||
await query.addColumn('OrganizationSkillsProviders', 'skillProviderId', { | ||
type: DataTypes.UUID, | ||
references: { | ||
model: 'SkillsProviders', | ||
key: 'id' | ||
}, | ||
onUpdate: 'CASCADE' | ||
}) | ||
await query.addColumn('UsersSkills', 'skillId', { | ||
type: DataTypes.UUID, | ||
references: { | ||
model: 'Skills', | ||
key: 'id' | ||
}, | ||
onUpdate: 'CASCADE' | ||
}) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@Sande3p this would cause all the existing data to be lost, I guess. How can we handle that?
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.
@maxceem do you have idea how can handle this without loosing data?
Uh oh!
There was an error while loading. Please reload this page.
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.
Good catch @vikasrohit. I don't think these columns should be removed as we this script adds them back after removing which looks like doesn't make sense. I guess these columns should be left as it is without any changes. The only thing which has to be changed - references from other tables to these columns have to be removed and that's it.
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.
fixed
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.
@xxcxy @Sande3p any of you verified the migration script for preventing data loss on your local? I want to make sure before I run it on dev.
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.
it will drop table
Skills
andSkillsProviders
.If you mean preventing other table's data loss, then yes, i tried.
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.
Yes, that is what I was worried about. If the data is not lost in any tables excepts the two we want to get rid of.