Skip to content

Commit

Permalink
Merge pull request #23 from joshuaalpuerto/wip/add-updated-by-column
Browse files Browse the repository at this point in the history
add updated by column
  • Loading branch information
joshuaalpuerto authored Jul 1, 2018
2 parents 22767a4 + a2716bc commit 0276f56
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/company/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = ({ companyRepository }) => {
.then(() =>
companyRepository.getAll({
attributes: [
'id', 'name', 'address', 'contact', 'tin', 'sss', 'philhealth', 'isDeleted', 'createdBy'
'id', 'name', 'address', 'contact', 'tin', 'sss', 'philhealth', 'isDeleted', 'createdBy', 'updatedBy'
]
})
)
Expand Down
2 changes: 1 addition & 1 deletion src/app/user/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = ({ userRepository }) => {
.then(() =>
userRepository.getAll({
attributes: [
'id', 'firstName', 'lastName', 'middleName', 'email', 'roleId', 'isDeleted', 'createdBy'
'id', 'firstName', 'lastName', 'middleName', 'email', 'roleId', 'isDeleted', 'createdBy', 'updatedBy'
]
})
)
Expand Down
5 changes: 4 additions & 1 deletion src/domain/company/company.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const Company = t.struct({
sss: t.String,
philhealth: t.String,
isDeleted: t.Number,
createdBy: t.String
createdBy: t.maybe(t.String),
updatedBy: t.maybe(t.String),
createdAt: t.maybe(t.Date),
updatedAt: t.maybe(t.Date)
})

module.exports = compose(
Expand Down
5 changes: 4 additions & 1 deletion src/domain/user/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const User = t.struct({
verificationCode: t.maybe(t.String),
isVerified: t.maybe(t.Number),
isDeleted: t.Number,
createdBy: t.String
createdBy: t.maybe(t.String),
updatedBy: t.maybe(t.String),
createdAt: t.maybe(t.Date),
updatedAt: t.maybe(t.Date)
})

module.exports = compose(
Expand Down
8 changes: 6 additions & 2 deletions src/infra/database/models/company.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = function (sequelize, DataTypes) {
const User = sequelize.define('companies', {
const Company = sequelize.define('companies', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
Expand Down Expand Up @@ -37,6 +37,10 @@ module.exports = function (sequelize, DataTypes) {
createdBy: {
type: DataTypes.UUID,
allowNull: false
},
updatedBy: {
type: DataTypes.UUID,
allowNull: true
}
}, {
freezeTableName: true,
Expand All @@ -48,5 +52,5 @@ module.exports = function (sequelize, DataTypes) {
}
})

return User
return Company
}
4 changes: 4 additions & 0 deletions src/infra/database/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ module.exports = function (sequelize, DataTypes) {
createdBy: {
type: DataTypes.UUID,
allowNull: false
},
updatedBy: {
type: DataTypes.UUID,
allowNull: true
}
}, {
hooks: {
Expand Down
6 changes: 4 additions & 2 deletions src/infra/repositories/transforms/company.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const toEntity = ({
sss,
philhealth,
isDeleted,
createdBy
createdBy,
updatedBy
}) => Company({
id,
name,
Expand All @@ -19,7 +20,8 @@ const toEntity = ({
sss,
philhealth,
isDeleted,
createdBy
createdBy,
updatedBy
})

module.exports = {
Expand Down
6 changes: 4 additions & 2 deletions src/infra/repositories/transforms/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const toEntity = ({
password,
roleId,
isDeleted,
createdBy
createdBy,
updatedBy
}) => User({
id,
firstName,
Expand All @@ -19,7 +20,8 @@ const toEntity = ({
password,
roleId,
isDeleted,
createdBy
createdBy,
updatedBy
})

module.exports = {
Expand Down
4 changes: 4 additions & 0 deletions src/infra/sequelize/migrations/001-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ module.exports = {
type: Sequelize.UUID,
allowNull: false
},
updatedBy: {
type: Sequelize.UUID,
allowNull: true
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
Expand Down
4 changes: 4 additions & 0 deletions src/infra/sequelize/migrations/002-company.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ module.exports = {
type: Sequelize.UUID,
allowNull: false
},
updatedBy: {
type: Sequelize.UUID,
allowNull: true
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
Expand Down

0 comments on commit 0276f56

Please sign in to comment.