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,27 @@
'use strict'

module.exports = {
async up(queryInterface, Sequelize) {
// Remove the primary key constraint from 'id'
await queryInterface.removeConstraint('user_sessions', 'user_sessions_pkey')

// Add a unique constraint for the combination of 'id' and 'user_id'
await queryInterface.addConstraint('user_sessions', {
fields: ['id', 'user_id'],
type: 'primary key',
name: 'user_sessions_pkey',
})
},

async down(queryInterface, Sequelize) {
// Remove the unique constraint for the combination of 'id' and 'user_id'
await queryInterface.removeConstraint('user_sessions', 'user_sessions_pkey')

// Add back the primary key constraint on 'id'
await queryInterface.addConstraint('user_sessions', {
type: 'primary key',
fields: ['id'],
name: 'user_sessions_pkey',
})
},
}
1 change: 1 addition & 0 deletions src/database/models/user-sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = (sequelize, DataTypes) => {
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
},
started_at: {
type: DataTypes.BIGINT,
Expand Down