Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/note.picotech.app/public_html/migrations/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up (queryInterface, Sequelize) {
// Create failed_login_attempts table
await queryInterface.createTable('failed_login_attempts', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
email: {
type: Sequelize.STRING(255),
allowNull: false,
comment: 'Email address of failed login attempt'
},
attempts: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 1,
comment: 'Number of failed attempts'
},
lockout_until: {
type: Sequelize.DATE,
allowNull: true,
comment: 'When the account is locked until'
},
last_attempt_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
comment: 'Timestamp of last failed attempt'
},
ip_address: {
type: Sequelize.STRING(45),
allowNull: true,
comment: 'IP address of the attempt (IPv4/IPv6)'
},
user_agent: {
type: Sequelize.TEXT,
allowNull: true,
comment: 'User agent string'
},
created_at: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updated_at: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
}
});
// Add index on email for faster lookups
await queryInterface.addIndex('failed_login_attempts', ['email']);
// Create user_upload_limits table
await queryInterface.createTable('user_upload_limits', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
user_id: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id'
},
onDelete: 'CASCADE',
comment: 'Reference to users table'
},
files_count: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: 'Number of files uploaded by user'
},
total_size_bytes: {
type: Sequelize.BIGINT,
allowNull: false,
defaultValue: 0,
comment: 'Total size of all uploaded files in bytes'
},
reset_at: {
type: Sequelize.DATE,
allowNull: true,
comment: 'When limits should be reset (optional)'
},
created_at: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updated_at: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
}
});
// Add unique index on user_id
await queryInterface.addIndex('user_upload_limits', ['user_id'], {
unique: true,
name: 'unique_user_upload_limits_user_id'
});
},
async down (queryInterface, Sequelize) {
await queryInterface.dropTable('user_upload_limits');
await queryInterface.dropTable('failed_login_attempts');
}
};
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0084 ]-- |