This repository was archived by the owner on Mar 12, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +84
-19
lines changed Expand file tree Collapse file tree 6 files changed +84
-19
lines changed Original file line number Diff line number Diff line change 1
1
const sequelize = require ( '../../src/models/index' )
2
2
const path = require ( 'path' )
3
- const Umzug = require ( 'umzug' )
3
+ const { Umzug, SequelizeStorage } = require ( 'umzug' )
4
4
5
5
function getUmzug ( ) {
6
6
return new Umzug ( {
7
7
migrations : {
8
- // indicates the folder containing the migration .js files
9
- path : path . join ( __dirname , './migrations' ) ,
8
+ glob : path . join ( __dirname , './migrations/*.js' ) ,
10
9
// inject sequelize's QueryInterface in the migrations
11
10
params : [
12
11
sequelize . getQueryInterface ( )
13
12
]
14
13
} ,
14
+ context : sequelize . getQueryInterface ( ) ,
15
15
// indicates that the migration data should be store in the database
16
16
// itself through sequelize. The default configuration creates a table
17
17
// named `SequelizeMeta`.
18
- storage : 'sequelize' ,
19
- storageOptions : {
20
- sequelize : sequelize
21
- }
18
+ storage : new SequelizeStorage ( { sequelize } )
22
19
} )
23
20
}
24
21
Original file line number Diff line number Diff line change 1
1
const { DataTypes } = require ( 'sequelize' )
2
2
3
3
module . exports = {
4
- up : async ( query ) => {
5
- await query . createTable ( 'Taxonomies' , {
4
+ up : async ( { context : queryInterface } ) => {
5
+ await queryInterface . createTable ( 'Taxonomies' , {
6
6
id : {
7
7
primaryKey : true ,
8
8
type : DataTypes . UUID ,
@@ -29,7 +29,7 @@ module.exports = {
29
29
}
30
30
} )
31
31
} ,
32
- down : async ( query ) => {
33
- await query . dropTable ( 'Taxonomies' )
32
+ down : async ( { context : queryInterface } ) => {
33
+ await queryInterface . dropTable ( 'Taxonomies' )
34
34
}
35
35
}
Original file line number Diff line number Diff line change 1
1
const { DataTypes } = require ( 'sequelize' )
2
2
3
3
module . exports = {
4
- up : async ( query ) => {
5
- await query . createTable ( 'Skills' , {
4
+ up : async ( { context : queryInterface } ) => {
5
+ await queryInterface . createTable ( 'Skills' , {
6
6
id : {
7
7
primaryKey : true ,
8
8
type : DataTypes . UUID ,
@@ -35,7 +35,7 @@ module.exports = {
35
35
}
36
36
} )
37
37
} ,
38
- down : async ( query ) => {
39
- await query . dropTable ( 'Skills' )
38
+ down : async ( { context : queryInterface } ) => {
39
+ await queryInterface . dropTable ( 'Skills' )
40
40
}
41
41
}
Original file line number Diff line number Diff line change 1
1
const { DataTypes } = require ( 'sequelize' )
2
2
3
3
module . exports = {
4
- up : async ( query ) => {
5
- await query . addColumn ( 'Skills' , 'taxonomyId' , {
4
+ up : async ( { context : queryInterface } ) => {
5
+ await queryInterface . addColumn ( 'Skills' , 'taxonomyId' , {
6
6
type : DataTypes . UUID ,
7
7
references : {
8
8
model : 'Taxonomies' ,
@@ -11,7 +11,7 @@ module.exports = {
11
11
onUpdate : 'CASCADE'
12
12
} )
13
13
} ,
14
- down : async ( query ) => {
15
- await query . removeColumn ( 'Skills' , 'taxonomyId' )
14
+ down : async ( { context : queryInterface } ) => {
15
+ await queryInterface . removeColumn ( 'Skills' , 'taxonomyId' )
16
16
}
17
17
}
Original file line number Diff line number Diff line change
1
+ const { DataTypes } = require ( 'sequelize' )
2
+
3
+ module . exports = {
4
+ up : async ( { context : queryInterface } ) => {
5
+
6
+ await queryInterface . createTable ( 'TCSkills' , {
7
+ id : {
8
+ primaryKey : true ,
9
+ type : DataTypes . UUID ,
10
+ defaultValue : DataTypes . UUIDV4
11
+ } ,
12
+ name : {
13
+ type : DataTypes . STRING ,
14
+ allowNull : false
15
+ } ,
16
+ description : {
17
+ type : DataTypes . TEXT
18
+ } ,
19
+ createdAt : {
20
+ type : DataTypes . DATE ,
21
+ allowNull : false
22
+ } ,
23
+ updatedAt : {
24
+ type : DataTypes . DATE
25
+ }
26
+ } )
27
+
28
+ await queryInterface . addIndex ( 'TCSkills' , [ 'name' ] , {
29
+ name : "TCSkill_name_key" ,
30
+ unique : true ,
31
+ } )
32
+
33
+ } ,
34
+ down : async ( { context : queryInterface } ) => {
35
+ await queryInterface . dropTable ( 'TCSkills' )
36
+ }
37
+ }
Original file line number Diff line number Diff line change
1
+ const { DataTypes } = require ( 'sequelize' )
2
+
3
+ module . exports = ( sequelize ) => {
4
+ const TCSkill = sequelize . define ( 'TCSkill' , {
5
+ id : {
6
+ primaryKey : true ,
7
+ type : DataTypes . UUID ,
8
+ defaultValue : DataTypes . UUIDV4
9
+ } ,
10
+ name : {
11
+ type : DataTypes . STRING ,
12
+ allowNull : false
13
+ } ,
14
+ description : {
15
+ type : DataTypes . TEXT
16
+ }
17
+ } ,
18
+ {
19
+ timestamps : true ,
20
+ indexes : [
21
+ {
22
+ name : "TCSkill_name_key" ,
23
+ unique : true ,
24
+ fields : [
25
+ { name : "name" } ,
26
+ ]
27
+ } ,
28
+ ]
29
+ } )
30
+ return TCSkill
31
+ }
You can’t perform that action at this time.
0 commit comments