diff --git a/server/models/User.js b/server/models/User.js index 74b3e46..3648c5c 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -10,7 +10,6 @@ module.exports = (sequelize) => { username: { type: DataTypes.STRING, allowNull: false, - unique: true, validate: { len: [3, 50] } @@ -101,7 +100,9 @@ module.exports = (sequelize) => { fields: ['email'] }, { - fields: ['username'] + fields: ['username', 'tenant_id'], + unique: true, + name: 'unique_username_per_tenant' }, { fields: ['phone_number'] diff --git a/server/tests/models/models.test.js b/server/tests/models/models.test.js index 039ff4a..9eaf15b 100644 --- a/server/tests/models/models.test.js +++ b/server/tests/models/models.test.js @@ -65,7 +65,6 @@ describe('Models', () => { const tenant2 = await createTestTenant({ slug: 'tenant2' }); const timestamp = Date.now(); - console.log('Creating user1 with tenant:', tenant1.id); const user1 = await models.User.create({ username: 'testuser', email: `test1-${timestamp}@example.com`, @@ -73,7 +72,6 @@ describe('Models', () => { tenant_id: tenant1.id }); - console.log('Creating user2 with tenant:', tenant2.id); const user2 = await models.User.create({ username: 'testuser', email: `test2-${timestamp}@example.com`,