split FKs into another file

This commit is contained in:
counterweight 2025-03-10 13:43:55 +01:00
parent 3b2edb4ca9
commit 317ca7ded2
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 74 additions and 38 deletions

View file

@ -0,0 +1,42 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) => {
return Promise.all([
queryInterface.addConstraint('login_challenge_created', {
fields: ['nostr_challenge_uuid'],
type: 'foreign key',
references: {
table: 'nostr_challenge_created',
field: 'uuid',
},
onDelete: 'cascade',
onUpdate: 'cascade',
}),
queryInterface.addConstraint('nostr_challenge_completed', {
fields: ['challenge'],
type: 'foreign key',
references: {
table: 'nostr_challenge_created',
field: 'challenge',
},
onDelete: 'cascade',
onUpdate: 'cascade',
}),
queryInterface.addConstraint('login_challenge_completed', {
fields: ['nostr_challenge_completed_uuid'],
type: 'foreign key',
references: {
table: 'nostr_challenge_completed',
field: 'uuid',
},
onDelete: 'cascade',
onUpdate: 'cascade',
}),
]);
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('Users');
},
};