split FKs into another file
This commit is contained in:
parent
3b2edb4ca9
commit
317ca7ded2
3 changed files with 74 additions and 38 deletions
42
src/database/migrations/20250308000001-first-schema-fks.js
Normal file
42
src/database/migrations/20250308000001-first-schema-fks.js
Normal 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');
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue