Created
November 28, 2018 09:47
-
-
Save Eth3rnit3/8186ca6e24917fa3c08b8c1d923d84b6 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
module.exports = { | |
up: (queryInterface, Sequelize) => { | |
return queryInterface.createTable('Companies', { | |
id: { | |
allowNull: false, | |
autoIncrement: true, | |
primaryKey: true, | |
type: Sequelize.INTEGER | |
}, | |
name: { | |
type: Sequelize.STRING | |
}, | |
createdAt: { | |
allowNull: false, | |
type: Sequelize.DATE | |
}, | |
updatedAt: { | |
allowNull: false, | |
type: Sequelize.DATE | |
} | |
}); | |
}, | |
down: (queryInterface, Sequelize) => { | |
return queryInterface.dropTable('Companies'); | |
} | |
}; |
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
'use strict'; | |
module.exports = { | |
up: (queryInterface, Sequelize) => { | |
return queryInterface.createTable('Users', { | |
id: { | |
allowNull: false, | |
autoIncrement: true, | |
primaryKey: true, | |
type: Sequelize.INTEGER | |
}, | |
email: { | |
type: Sequelize.STRING | |
}, | |
firstName: { | |
type: Sequelize.STRING | |
}, | |
lastName: { | |
type: Sequelize.STRING | |
}, | |
companyId: { | |
type: Sequelize.INTEGER, | |
allowNull: false, | |
references: { // User belongsTo Company 1:1 | |
model: 'Companies', | |
key: 'id' | |
} | |
}, | |
createdAt: { | |
allowNull: false, | |
type: Sequelize.DATE | |
}, | |
updatedAt: { | |
allowNull: false, | |
type: Sequelize.DATE | |
} | |
}); | |
}, | |
down: (queryInterface, Sequelize) => { | |
return queryInterface.dropTable('Users'); | |
} | |
}; |
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
'use strict'; | |
module.exports = { | |
up: (queryInterface, Sequelize) => { | |
return queryInterface.createTable('WorkingDays', { | |
id: { | |
allowNull: false, | |
autoIncrement: true, | |
primaryKey: true, | |
type: Sequelize.INTEGER | |
}, | |
weekDay: { | |
type: Sequelize.STRING | |
}, | |
workingDate: { | |
type: Sequelize.DATE | |
}, | |
isWorking: { | |
type: Sequelize.BOOLEAN | |
}, | |
createdAt: { | |
allowNull: false, | |
type: Sequelize.DATE | |
}, | |
updatedAt: { | |
allowNull: false, | |
type: Sequelize.DATE | |
} | |
}); | |
}, | |
down: (queryInterface, Sequelize) => { | |
return queryInterface.dropTable('WorkingDays'); | |
} | |
}; |
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
'use strict'; | |
module.exports = { | |
up: (queryInterface, Sequelize) => { | |
return queryInterface.createTable('UsersWorkingDays', { | |
id: { | |
allowNull: false, | |
autoIncrement: true, | |
primaryKey: true, | |
type: Sequelize.INTEGER | |
}, | |
userId: { | |
type: Sequelize.INTEGER, | |
allowNull: false, | |
references: { // User hasMany WorkingDays n:n | |
model: 'Users', | |
key: 'id' | |
} | |
}, | |
workingDayId: { | |
type: Sequelize.INTEGER, | |
allowNull: false, | |
references: { // WorkingDays hasMany Users n:n | |
model: 'WorkingDays', | |
key: 'id' | |
} | |
}, | |
createdAt: { | |
allowNull: false, | |
type: Sequelize.DATE | |
}, | |
updatedAt: { | |
allowNull: false, | |
type: Sequelize.DATE | |
} | |
}); | |
}, | |
down: (queryInterface, Sequelize) => { | |
return queryInterface.dropTable('UsersWorkingDays'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment