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 api_keys table for backend-managed API keys
await queryInterface.createTable('api_keys', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
service_name: {
type: Sequelize.STRING(100),
allowNull: false,
comment: 'Name of the external service (e.g., openai, anthropic, google_oauth)'
},
key_type: {
type: Sequelize.ENUM('api_key', 'client_id', 'client_secret', 'access_token', 'refresh_token'),
allowNull: false,
comment: 'Type of credential'
},
key_value: {
type: Sequelize.TEXT,
allowNull: false,
comment: 'Encrypted API key or token value'
},
is_active: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: true,
comment: 'Whether this key is currently active'
},
expires_at: {
type: Sequelize.DATE,
allowNull: true,
comment: 'Expiration date for tokens'
},
last_used_at: {
type: Sequelize.DATE,
allowNull: true,
comment: 'Last time this key was used'
},
usage_count: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: 'Number of times this key has been used'
},
rate_limit_remaining: {
type: Sequelize.INTEGER,
allowNull: true,
comment: 'Remaining API calls for rate-limited services'
},
rate_limit_reset_at: {
type: Sequelize.DATE,
allowNull: true,
comment: 'When rate limit resets'
},
metadata: {
type: Sequelize.JSON,
allowNull: true,
comment: 'Additional service-specific metadata'
},
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 indexes for performance
await queryInterface.addIndex('api_keys', ['service_name']);
await queryInterface.addIndex('api_keys', ['is_active']);
await queryInterface.addIndex('api_keys', ['expires_at']);
await queryInterface.addIndex('api_keys', ['service_name', 'key_type'], {
unique: true,
name: 'unique_service_key_type'
});
},
async down (queryInterface, Sequelize) {
await queryInterface.dropTable('api_keys');
}
};
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0044 ]-- |