iut-hapi/lib/migrations/0-favorites.js

19 lines
589 B
JavaScript

// Migration pour créer la table des favoris
'use strict';
module.exports = {
async up(knex) {
await knex.schema.createTable('favorites', (table) => {
table.integer('user_id').unsigned().notNullable();
table.integer('movie_id').unsigned().notNullable();
table.primary(['user_id', 'movie_id']);
table.foreign('user_id').references('id').inTable('user');
table.foreign('movie_id').references('id').inTable('movie');
});
},
async down(knex) {
await knex.schema.dropTable('favorites');
}
}