From 6f0c39e2de400685b7baf8340b9e132f2659365a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Mar 2017 20:53:11 +0200 Subject: Server: add licence video attribute --- .../initializers/migrations/0035-video-licence.js | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 server/initializers/migrations/0035-video-licence.js (limited to 'server/initializers/migrations') diff --git a/server/initializers/migrations/0035-video-licence.js b/server/initializers/migrations/0035-video-licence.js new file mode 100644 index 000000000..9cf75858d --- /dev/null +++ b/server/initializers/migrations/0035-video-licence.js @@ -0,0 +1,34 @@ +'use strict' + +const waterfall = require('async/waterfall') + +// utils = { transaction, queryInterface, sequelize, Sequelize } +exports.up = function (utils, finalCallback) { + const q = utils.queryInterface + const Sequelize = utils.Sequelize + + const data = { + type: Sequelize.INTEGER, + allowNull: false, + defaultValue: 0 + } + + waterfall([ + + function addLicenceColumn (callback) { + q.addColumn('Videos', 'licence', data, { transaction: utils.transaction }).asCallback(function (err) { + return callback(err) + }) + }, + + function nullOnDefault (callback) { + data.defaultValue = null + + q.changeColumn('Videos', 'licence', data, { transaction: utils.transaction }).asCallback(callback) + } + ], finalCallback) +} + +exports.down = function (options, callback) { + throw new Error('Not implemented.') +} -- cgit v1.2.3