From bfbd912886eba17b4aa9a40dcef2fddc685d85bf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 31 Jul 2019 15:57:32 +0200 Subject: Fix broken playlist api --- .../migrations/0410-video-playlist-element.ts | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 server/initializers/migrations/0410-video-playlist-element.ts (limited to 'server/initializers/migrations') diff --git a/server/initializers/migrations/0410-video-playlist-element.ts b/server/initializers/migrations/0410-video-playlist-element.ts new file mode 100644 index 000000000..f536632a2 --- /dev/null +++ b/server/initializers/migrations/0410-video-playlist-element.ts @@ -0,0 +1,39 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction, + queryInterface: Sequelize.QueryInterface, + sequelize: Sequelize.Sequelize, + db: any +}): Promise { + { + const data = { + type: Sequelize.INTEGER, + allowNull: true, + defaultValue: null + } + + await utils.queryInterface.changeColumn('videoPlaylistElement', 'videoId', data) + } + + await utils.queryInterface.removeConstraint('videoPlaylistElement', 'videoPlaylistElement_videoId_fkey') + + await utils.queryInterface.addConstraint('videoPlaylistElement', [ 'videoId' ], { + type: 'foreign key', + references: { + table: 'video', + field: 'id' + }, + onDelete: 'set null', + onUpdate: 'CASCADE' + }) +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3