Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
sequelize-paranoid-cascade
Advanced tools
Readme
sequelize-paranoid-cascade allows cascading deletions when using paranoid mode in sequelize
There are a couple of use case missing:
The following example uses a MySql database through sequelize and persists the migration data in the database itself through the sequelize storage.
// index.js
const { Sequelize } = require('sequelize');
const { Umzug, SequelizeStorage } = require('umzug');
const { queryInterfaceDecorator } = require('sequelize-paranoid-cascade');
const sequelize = new Sequelize({ dialect: 'mysql', storage: './db.mysql' });
const umzug = new Umzug({
migrations: { glob: 'migrations/*.js' },
// as simple as the following line
context: queryInterfaceDecorator(sequelize.getQueryInterface()),
storage: new SequelizeStorage({ sequelize }),
logger: console,
});
// migrations/00_initial.js
const { Sequelize } = require('sequelize');
async function up({ context: queryInterface }) {
await queryInterface.createTable('resources', {
id: {
type: Sequelize.INTEGER,
allowNull: false,
primaryKey: true,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
userId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id',
},
// here we specify the behavior
onDelete: 'PARANOID CASCADE',
}
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
deletedAt: {
type: Sequelize.DATE,
allowNull: true,
},
});
}
This is going to create a trigger in the users table, when a user gets "deleted", the resource will be marked as deleted as well.
If the table was already created, you can use addColumn as well.
const { Sequelize } = require('sequelize');
async function up({ context: queryInterface }) {
await queryInterface.addColumn('resources', 'userId', {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id',
},
// here we specify the behavior
onDelete: 'PARANOID CASCADE',
});
}
sequelize-paranoid-cascade is available on npm by specifying the correct tag:
npm install sequelize-paranoid-cascade
OR
yarn add sequelize-paranoid-cascade
See the LICENSE file
FAQs
sequelize-paranoid-cascade allows cascading deletions when using paranoid mode
We found that sequelize-paranoid-cascade 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.