UNPKG

open-music-api-node

Version:
29 lines (24 loc) 742 B
/* eslint-disable camelcase */ exports.shorthands = undefined; exports.up = (pgm) => { pgm.createTable('collaborations', { id: { type: 'VARCHAR(50)', primaryKey: true, }, playlist_id: { type: 'VARCHAR(50)', notNull: true, }, user_id: { type: 'VARCHAR(50)', notNull: true, }, }); pgm.addConstraint('collaborations', 'unique_id', 'UNIQUE(playlist_id, user_id)'); pgm.addConstraint('collaborations', 'fk_playlist_id', 'FOREIGN KEY(playlist_id) REFERENCES playlist(id) ON DELETE CASCADE'); pgm.addConstraint('collaborations', 'fk_users_id', 'FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE'); }; exports.down = (pgm) => { pgm.dropTable('collaborations'); };