Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict'

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
// Remove the current primary key constraint
await queryInterface.removeConstraint('users_credentials', 'users_credentials_pkey')

// Add the 'email' column as the new primary key
await queryInterface.addConstraint('users_credentials', {
fields: ['email'],
type: 'primary key',
name: 'users_credentials_pkey',
})
},

async down(queryInterface, Sequelize) {
// Remove the current primary key constraint
await queryInterface.removeConstraint('users_credentials', 'users_credentials_email_pkey')

// Recreate the primary key constraint on the 'id' column
await queryInterface.addConstraint('users_credentials', {
fields: ['id'],
type: 'primary key',
name: 'users_credentials_pkey',
})
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict'

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
// Remove the current primary key constraint
await queryInterface.removeConstraint('organization_user_invites', 'org_user_invites_pkey')

// Add the 'id' and 'organization_id' columns as the new composite primary key
await queryInterface.addConstraint('organization_user_invites', {
fields: ['id', 'organization_id'],
type: 'primary key',
name: 'org_user_invites_pkey',
})
},

async down(queryInterface, Sequelize) {
// Remove the current primary key constraint
await queryInterface.removeConstraint('organization_user_invites', 'org_user_invites_pkey')

// Recreate the primary key constraint on the 'id' column
await queryInterface.addConstraint('organization_user_invites', {
fields: ['id'],
type: 'primary key',
name: 'org_user_invites_pkey',
})
},
}
1 change: 1 addition & 0 deletions src/database/models/organizationUserInvite.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = (sequelize, DataTypes) => {
organization_id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
},
roles: {
type: DataTypes.ARRAY(DataTypes.INTEGER),
Expand Down
2 changes: 1 addition & 1 deletion src/database/models/userCredential.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ module.exports = (sequelize, DataTypes) => {
id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true,
},
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
primaryKey: true,
},
password: {
type: DataTypes.STRING,
Expand Down
2 changes: 1 addition & 1 deletion src/services/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports = class AccountHelper {
if (invitedUserId) {
invitedUserMatch = await userInviteQueries.findOne({
id: invitedUserId.organization_user_invite_id,
})
}) //add org id here to optimize the query
}

let isOrgAdmin = false
Expand Down