Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@shagital/adonisjs-migrations-generator
Advanced tools
An AdonisJS (nodejs) package to generate migration files from existing DB tables
This package allows you easily generate migration files for your AdonisJS app from an existing Database, including indexes and foreign keys!
You can install the package via composer:
npm install @shagital/adonisjs-migrations-generator
Or with yarn
yarn add @shagital/adonisjs-migrations-generator
Open start/app.js
and add @shagital/adonisjs-migrations-generator/src/Commands/MigrationsGeneratorCommand
to the commands array
adonis
with node ace
if adonis is not installed globally on your system.Will generate migration files for all tables in the DB set as default, and save files in database/migrations
directory
adonis migration:generate
adonis migration:generate --include=table1,table2
adonis migration:generate --exclude=table1,table2
NOTE: Connection type must have been specified in
config/databases
adonis migration:generate --connection=mysql2
NOTE: The package will attempt to create the specified directory if it doesn't exist
adonis migration:generate --path=/var/www/html/backups
This option is suitable for a fresh application install
NOTE: The directory and all it's content will be deleted before the directory is recreated! ENSURE THE DIRECTORY DOESN'T CONTAIN FILES YOU PREFER TO KEEP!!!
adonis migration:generate --force
[MySQL] Because we're generating migrations are being generated from an existing DB, when you run the migration, you might run into foreign key constraint errors because tables might not be created before been referenced in another table. This option adds a command to disable foreign key check so your migrations can run smoothly
adonis migration:generate --disable-fkc
'use strict';
/** @type {import('@adonisjs/lucid/src/Schema')} */
const Schema = use('Schema');
/** @type {import('@adonisjs/lucid/src/Database')} */
const Database = use('Database');
class UsersSchema extends Schema {
static get connection() {
return 'mysql'
}
up() {
return Promise.all([
Database.raw("SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS;"),
Database.raw("SET FOREIGN_KEY_CHECKS=0;")
]).then(() => {
this.create('users', (table) => {
table.increments('id').unsigned();
table.string('username', 80).unique();
table.string('first_name', 80).nullable();
table.string('last_name', 80).nullable();
table.string('email', 100).unique();
table.string('password', 255);
table.timestamp('deleted_at').nullable();
table.timestamp('created_at').defaultTo(Database.fn.now());
table.timestamp('updated_at').defaultTo(Database.fn.now());
table.index(['username'], 'users_username_unique_22');
table.index(['email'], 'users_email_unique_76');
});
});
}
down() {
return Promise.all([
Database.raw("SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS;"),
Database.raw("SET FOREIGN_KEY_CHECKS=0;")
]).then(() => {
this.dropIfExists('users');
});
}
}
module.exports = UsersSchema
Please see CHANGELOG for more information what has changed recently.
If you have a feature you'd like to add, kindly send a Pull Request (PR)
If you discover any security related issues, please email zacchaeus@shagital.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
FAQs
An AdonisJS (nodejs) package to generate migration files from existing DB tables
We found that @shagital/adonisjs-migrations-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.