open-music-api-node
Version:
27 lines (23 loc) • 632 B
JavaScript
/* eslint-disable camelcase */
exports.shorthands = undefined;
exports.up = (pgm) => {
pgm.createTable('playlist_song', {
id: {
type: 'VARCHAR(50)',
primaryKey: true,
},
playlist_id: {
type: 'TEXT',
notNull: true,
},
song_id: {
type: 'TEXT',
notNull: true,
},
});
pgm.addConstraint('playlist_song', 'fk_playlist', 'FOREIGN KEY(playlist_id) REFERENCES playlist(id) ON DELETE CASCADE');
pgm.addConstraint('playlist_song', 'fk_song', 'FOREIGN KEY(song_id) REFERENCES songs(id) ON DELETE CASCADE');
};
exports.down = (pgm) => {
pgm.dropTable('playlist_song');
};