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