Fix jwt-token
This commit is contained in:
@@ -168,7 +168,12 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add tenant-related columns to users table (idempotent)
|
// Add tenant-related columns to users table (idempotent)
|
||||||
const usersTableDescription = await queryInterface.describeTable('users');
|
const tables = await queryInterface.showAllTables();
|
||||||
|
|
||||||
|
if (!tables.includes('users')) {
|
||||||
|
console.log('⚠️ Users table does not exist yet, skipping user tenant columns migration...');
|
||||||
|
} else {
|
||||||
|
const usersTableDescription = await queryInterface.describeTable('users');
|
||||||
|
|
||||||
if (!usersTableDescription.tenant_id) {
|
if (!usersTableDescription.tenant_id) {
|
||||||
await queryInterface.addColumn('users', 'tenant_id', {
|
await queryInterface.addColumn('users', 'tenant_id', {
|
||||||
@@ -318,6 +323,8 @@ module.exports = {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('Alert_rules table not found or already has tenant_id column');
|
console.log('Alert_rules table not found or already has tenant_id column');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // Close the else block for users table check
|
||||||
|
|
||||||
console.log('✅ Multi-tenant support added successfully');
|
console.log('✅ Multi-tenant support added successfully');
|
||||||
console.log('✅ Default tenant created for backward compatibility');
|
console.log('✅ Default tenant created for backward compatibility');
|
||||||
|
|||||||
@@ -7,8 +7,16 @@
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: async (queryInterface, Sequelize) => {
|
up: async (queryInterface, Sequelize) => {
|
||||||
// Check if the columns already exist
|
try {
|
||||||
const tableDescription = await queryInterface.describeTable('tenants');
|
// Check if tenants table exists first
|
||||||
|
const tables = await queryInterface.showAllTables();
|
||||||
|
if (!tables.includes('tenants')) {
|
||||||
|
console.log('⚠️ Tenants table does not exist yet, skipping auth session config migration...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the columns already exist
|
||||||
|
const tableDescription = await queryInterface.describeTable('tenants');
|
||||||
|
|
||||||
// Add session configuration fields
|
// Add session configuration fields
|
||||||
if (!tableDescription.session_timeout) {
|
if (!tableDescription.session_timeout) {
|
||||||
@@ -78,6 +86,10 @@ module.exports = {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('⚠️ Auth provider enum already includes ad or error occurred:', error.message);
|
console.log('⚠️ Auth provider enum already includes ad or error occurred:', error.message);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('⚠️ Migration skipped - tables may not exist yet:', error.message);
|
||||||
|
// Don't throw error, just skip this migration if tables don't exist
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
down: async (queryInterface, Sequelize) => {
|
down: async (queryInterface, Sequelize) => {
|
||||||
|
|||||||
@@ -7,8 +7,16 @@
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: async (queryInterface, Sequelize) => {
|
up: async (queryInterface, Sequelize) => {
|
||||||
// Check if the columns already exist
|
try {
|
||||||
const tableDescription = await queryInterface.describeTable('tenants');
|
// Check if tenants table exists first
|
||||||
|
const tables = await queryInterface.showAllTables();
|
||||||
|
if (!tables.includes('tenants')) {
|
||||||
|
console.log('⚠️ Tenants table does not exist yet, skipping IP restrictions migration...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the columns already exist
|
||||||
|
const tableDescription = await queryInterface.describeTable('tenants');
|
||||||
|
|
||||||
if (!tableDescription.ip_whitelist) {
|
if (!tableDescription.ip_whitelist) {
|
||||||
await queryInterface.addColumn('tenants', 'ip_whitelist', {
|
await queryInterface.addColumn('tenants', 'ip_whitelist', {
|
||||||
@@ -45,6 +53,10 @@ module.exports = {
|
|||||||
} else {
|
} else {
|
||||||
console.log('⚠️ Column ip_restriction_message already exists, skipping...');
|
console.log('⚠️ Column ip_restriction_message already exists, skipping...');
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log('⚠️ Migration skipped - tables may not exist yet:', error.message);
|
||||||
|
// Don't throw error, just skip this migration if tables don't exist
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
down: async (queryInterface, Sequelize) => {
|
down: async (queryInterface, Sequelize) => {
|
||||||
|
|||||||
@@ -7,7 +7,15 @@
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: async (queryInterface, Sequelize) => {
|
up: async (queryInterface, Sequelize) => {
|
||||||
await queryInterface.addColumn('tenants', 'allow_registration', {
|
try {
|
||||||
|
// Check if tenants table exists first
|
||||||
|
const tables = await queryInterface.showAllTables();
|
||||||
|
if (!tables.includes('tenants')) {
|
||||||
|
console.log('⚠️ Tenants table does not exist yet, skipping allow_registration migration...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await queryInterface.addColumn('tenants', 'allow_registration', {
|
||||||
type: Sequelize.BOOLEAN,
|
type: Sequelize.BOOLEAN,
|
||||||
defaultValue: false, // Default to false for security
|
defaultValue: false, // Default to false for security
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
@@ -21,6 +29,10 @@ module.exports = {
|
|||||||
console.log('✅ Added allow_registration field to tenants table');
|
console.log('✅ Added allow_registration field to tenants table');
|
||||||
console.log('⚠️ Registration is disabled by default for all tenants for security');
|
console.log('⚠️ Registration is disabled by default for all tenants for security');
|
||||||
console.log('💡 To enable registration for a tenant, update the allow_registration field to true');
|
console.log('💡 To enable registration for a tenant, update the allow_registration field to true');
|
||||||
|
} catch (error) {
|
||||||
|
console.log('⚠️ Migration skipped - tables may not exist yet:', error.message);
|
||||||
|
// Don't throw error, just skip this migration if tables don't exist
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
down: async (queryInterface, Sequelize) => {
|
down: async (queryInterface, Sequelize) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user