Fix jwt-token
This commit is contained in:
@@ -250,8 +250,16 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create default tenant for backward compatibility
|
// Create default tenant for backward compatibility (only if it doesn't exist)
|
||||||
const defaultTenantId = await queryInterface.bulkInsert('tenants', [{
|
const [existingTenant] = await queryInterface.sequelize.query(
|
||||||
|
'SELECT id FROM tenants WHERE slug = \'default\' LIMIT 1',
|
||||||
|
{ type: Sequelize.QueryTypes.SELECT }
|
||||||
|
);
|
||||||
|
|
||||||
|
let defaultTenantId;
|
||||||
|
if (!existingTenant) {
|
||||||
|
console.log('🏢 Creating default tenant...');
|
||||||
|
defaultTenantId = await queryInterface.bulkInsert('tenants', [{
|
||||||
id: Sequelize.literal('gen_random_uuid()'),
|
id: Sequelize.literal('gen_random_uuid()'),
|
||||||
name: 'Default Organization',
|
name: 'Default Organization',
|
||||||
slug: 'default',
|
slug: 'default',
|
||||||
@@ -268,6 +276,10 @@ module.exports = {
|
|||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date()
|
updated_at: new Date()
|
||||||
}], { returning: true });
|
}], { returning: true });
|
||||||
|
} else {
|
||||||
|
console.log('⚠️ Default tenant already exists, skipping...');
|
||||||
|
defaultTenantId = existingTenant.id;
|
||||||
|
}
|
||||||
|
|
||||||
// Associate existing users with default tenant
|
// Associate existing users with default tenant
|
||||||
await queryInterface.sequelize.query(`
|
await queryInterface.sequelize.query(`
|
||||||
|
|||||||
Reference in New Issue
Block a user