반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- kotlin
- 동일 프로세스
- naver storage
- Android
- MySQL
- c#
- onsen-ui
- naver storage bucket error
- nodejs
- Vuetify
- vuetifyjs
- JavaScript
- electron-nuxt
- CSS
- f035d
- bucket cors
- bucket max-key
- sequelize
- v-text-field height
- Electron
- vuejs
- v-select
- Vue
- xlsx
- onsenui
- 동일 프로그램
- 프로세스 방지
- error
- NUXT
- sort
Archives
- Today
- Total
앙큼한 개발기록
[sequelize] migration 정리 본문
맨날 쓰고
맨날 까먹는
sequelize migration 정리
command
sequelize migration:create --name 파일명
sequelize db:migrate
sequelize db:migrate:undo
addColumn
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn('테이블명', '변수명', {
type: Sequelize.타입[BOOLEAN, STRING(4, 8, 16), TEXT, INTEGER],
comment: ""
...
})
}
}
removeColumn
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn('테이블명', '변수명')
}
}
renameColumn
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.renameColumn('테이블명', '변수명', '바꿀 변수 명')
}
}
changeColumn
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.changeColumn('테이블명','변수명',
{
type: Sequelize.타입[BOOLEAN, STRING(4, 8, 16), TEXT, INTEGER],
comment: "",
...
}
)
}
}
addConstraint (참조 테이블에 변수랑 테이블에 변수가 선언되어 있어야 한다)
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addConstraint('테이블명', {
fields: ['변수명'],
type: 'foreign key',
name: '왜래키명',
references: {
table: '참조 테이블',
field: '참조 변수명'
}
})
}
}
removeConstraint
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint('테이블명', '왜래키명')
}
}
'개발 > mysql' 카테고리의 다른 글
mysql duplicate column name error (0) | 2019.05.15 |
---|
Comments