Remove old migration files
This commit is contained in:
parent
e6afb66940
commit
348c2ce3ff
|
@ -1,36 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { Migration } from '../../models/migrations'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.STRING(400),
|
||||
allowNull: false,
|
||||
defaultValue: ''
|
||||
} as Migration.String
|
||||
|
||||
return q.addColumn('Pods', 'email', data)
|
||||
.then(() => {
|
||||
const query = 'UPDATE "Pods" SET "email" = \'dummy@example.com\''
|
||||
return utils.sequelize.query(query, { transaction: utils.transaction })
|
||||
})
|
||||
.then(() => {
|
||||
data.defaultValue = null
|
||||
|
||||
return q.changeColumn('Pods', 'email', data)
|
||||
})
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { Migration } from '../../models/migrations'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.STRING(400),
|
||||
allowNull: false,
|
||||
defaultValue: ''
|
||||
} as Migration.String
|
||||
return q.addColumn('Users', 'email', data)
|
||||
.then(() => {
|
||||
const query = 'UPDATE "Users" SET "email" = CONCAT("username", \'@example.com\')'
|
||||
return utils.sequelize.query(query, { transaction: utils.transaction })
|
||||
})
|
||||
.then(() => {
|
||||
data.defaultValue = null
|
||||
|
||||
return q.changeColumn('Users', 'email', data)
|
||||
})
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0
|
||||
}
|
||||
|
||||
return q.addColumn('Videos', 'views', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0
|
||||
}
|
||||
|
||||
return q.addColumn('Videos', 'likes', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0
|
||||
}
|
||||
|
||||
return q.addColumn('Videos', 'dislikes', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { Migration } from '../../models/migrations'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0
|
||||
} as Migration.Integer
|
||||
|
||||
return q.addColumn('Videos', 'category', data)
|
||||
.then(() => {
|
||||
data.defaultValue = null
|
||||
|
||||
return q.changeColumn('Videos', 'category', data)
|
||||
})
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { Migration } from '../../models/migrations'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0
|
||||
} as Migration.Integer
|
||||
|
||||
return q.addColumn('Videos', 'licence', data)
|
||||
.then(() => {
|
||||
data.defaultValue = null
|
||||
return q.changeColumn('Videos', 'licence', data)
|
||||
})
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { Migration } from '../../models/migrations'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false
|
||||
} as Migration.Boolean
|
||||
|
||||
return q.addColumn('Videos', 'nsfw', data)
|
||||
.then(() => {
|
||||
data.defaultValue = null
|
||||
|
||||
return q.changeColumn('Videos', 'nsfw', data)
|
||||
})
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false
|
||||
}
|
||||
|
||||
return q.addColumn('Users', 'displayNSFW', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
return q.addColumn('Videos', 'language', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { Migration } from '../../models/migrations'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const dataUUID = {
|
||||
type: Sequelize.UUID,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: true
|
||||
} as Migration.UUID
|
||||
|
||||
return q.addColumn('Videos', 'uuid', dataUUID)
|
||||
.then(() => {
|
||||
const query = 'UPDATE "Videos" SET "uuid" = "id" WHERE "remoteId" IS NULL'
|
||||
return utils.sequelize.query(query)
|
||||
})
|
||||
.then(() => {
|
||||
const query = 'UPDATE "Videos" SET "uuid" = "remoteId" WHERE "remoteId" IS NOT NULL'
|
||||
return utils.sequelize.query(query)
|
||||
})
|
||||
.then(() => {
|
||||
dataUUID.defaultValue = null
|
||||
|
||||
return q.changeColumn('Videos', 'uuid', dataUUID)
|
||||
})
|
||||
.then(() => {
|
||||
return removeForeignKey(utils.sequelize, 'RequestVideoQadus')
|
||||
})
|
||||
.then(() => {
|
||||
return removeForeignKey(utils.sequelize, 'RequestVideoEvents')
|
||||
})
|
||||
.then(() => {
|
||||
return removeForeignKey(utils.sequelize, 'BlacklistedVideos')
|
||||
})
|
||||
.then(() => {
|
||||
return removeForeignKey(utils.sequelize, 'UserVideoRates')
|
||||
})
|
||||
.then(() => {
|
||||
return removeForeignKey(utils.sequelize, 'VideoAbuses')
|
||||
})
|
||||
.then(() => {
|
||||
return removeForeignKey(utils.sequelize, 'VideoTags')
|
||||
})
|
||||
.then(() => {
|
||||
const query = 'ALTER TABLE "Videos" DROP CONSTRAINT "Videos_pkey"'
|
||||
return utils.sequelize.query(query)
|
||||
})
|
||||
.then(() => {
|
||||
const query = 'ALTER TABLE "Videos" ADD COLUMN "id2" SERIAL PRIMARY KEY'
|
||||
return utils.sequelize.query(query)
|
||||
})
|
||||
.then(() => {
|
||||
return q.renameColumn('Videos', 'id', 'oldId')
|
||||
})
|
||||
.then(() => {
|
||||
return q.renameColumn('Videos', 'id2', 'id')
|
||||
})
|
||||
.then(() => {
|
||||
return changeForeignKey(q, utils.sequelize, 'RequestVideoQadus', false)
|
||||
})
|
||||
.then(() => {
|
||||
return changeForeignKey(q, utils.sequelize, 'RequestVideoEvents', false)
|
||||
})
|
||||
.then(() => {
|
||||
return changeForeignKey(q, utils.sequelize, 'BlacklistedVideos', false)
|
||||
})
|
||||
.then(() => {
|
||||
return changeForeignKey(q, utils.sequelize, 'UserVideoRates', false)
|
||||
})
|
||||
.then(() => {
|
||||
return changeForeignKey(q, utils.sequelize, 'VideoAbuses', false)
|
||||
})
|
||||
.then(() => {
|
||||
return changeForeignKey(q, utils.sequelize, 'VideoTags', true)
|
||||
})
|
||||
.then(() => {
|
||||
return q.removeColumn('Videos', 'oldId')
|
||||
})
|
||||
.then(() => {
|
||||
const dataRemote = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
defaultValue: false,
|
||||
allowNull: false
|
||||
}
|
||||
return q.addColumn('Videos', 'remote', dataRemote)
|
||||
})
|
||||
.then(() => {
|
||||
const query = 'UPDATE "Videos" SET "remote" = false WHERE "remoteId" IS NULL'
|
||||
return utils.sequelize.query(query)
|
||||
})
|
||||
.then(() => {
|
||||
const query = 'UPDATE "Videos" SET "remote" = true WHERE "remoteId" IS NOT NULL'
|
||||
return utils.sequelize.query(query)
|
||||
})
|
||||
.then(() => {
|
||||
return q.removeColumn('Videos', 'remoteId')
|
||||
})
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
function removeForeignKey (sequelize: Sequelize.Sequelize, tableName: string) {
|
||||
const query = 'ALTER TABLE "' + tableName + '" DROP CONSTRAINT "' + tableName + '_videoId_fkey' + '"'
|
||||
return sequelize.query(query)
|
||||
}
|
||||
|
||||
function changeForeignKey (q: Sequelize.QueryInterface, sequelize: Sequelize.Sequelize, tableName: string, allowNull: boolean) {
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true
|
||||
}
|
||||
|
||||
return q.addColumn(tableName, 'videoId2', data)
|
||||
.then(() => {
|
||||
const query = 'UPDATE "' + tableName + '" SET "videoId2" = ' +
|
||||
'(SELECT "id" FROM "Videos" WHERE "' + tableName + '"."videoId" = "Videos"."oldId")'
|
||||
return sequelize.query(query)
|
||||
})
|
||||
.then(() => {
|
||||
if (allowNull === false) {
|
||||
data.allowNull = false
|
||||
|
||||
return q.changeColumn(tableName, 'videoId2', data)
|
||||
}
|
||||
|
||||
return Promise.resolve()
|
||||
})
|
||||
.then(() => {
|
||||
return q.removeColumn(tableName, 'videoId')
|
||||
})
|
||||
.then(() => {
|
||||
return q.renameColumn(tableName, 'videoId2', 'videoId')
|
||||
})
|
||||
.then(() => {
|
||||
return q.addIndex(tableName, [ 'videoId' ])
|
||||
})
|
||||
.then(() => {
|
||||
const constraintName = tableName + '_videoId_fkey'
|
||||
const query = 'ALTER TABLE "' + tableName + '" ' +
|
||||
' ADD CONSTRAINT "' + constraintName + '"' +
|
||||
' FOREIGN KEY ("videoId") REFERENCES "Videos" ON DELETE CASCADE'
|
||||
|
||||
return sequelize.query(query)
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const query = 'INSERT INTO "VideoFiles" ("videoId", "resolution", "size", "extname", "infoHash", "createdAt", "updatedAt") ' +
|
||||
'SELECT "id" AS "videoId", 0 AS "resolution", 0 AS "size", ' +
|
||||
'"extname"::"text"::"enum_VideoFiles_extname" as "extname", "infoHash", "createdAt", "updatedAt" ' +
|
||||
'FROM "Videos"'
|
||||
|
||||
return utils.db.VideoFile.sync()
|
||||
.then(() => utils.sequelize.query(query))
|
||||
.then(() => {
|
||||
return q.removeColumn('Videos', 'extname')
|
||||
})
|
||||
.then(() => {
|
||||
return q.removeColumn('Videos', 'infoHash')
|
||||
})
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
throw new Error('Removed, please upgrade from a previous version first.')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { Migration } from '../../models/migrations'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.BIGINT,
|
||||
allowNull: false,
|
||||
defaultValue: -1
|
||||
} as Migration.BigInteger
|
||||
|
||||
return q.addColumn('Users', 'videoQuota', data)
|
||||
.then(() => {
|
||||
data.defaultValue = null
|
||||
return q.changeColumn('Users', 'videoQuota', data)
|
||||
})
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
import { readdir, rename } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import * as Sequelize from 'sequelize'
|
||||
import { getVideoStreamDimensionsInfo } from '../../helpers/ffmpeg/ffprobe-utils'
|
||||
import { CONFIG } from '../../initializers/config'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const torrentDir = CONFIG.STORAGE.TORRENTS_DIR
|
||||
const videoFileDir = CONFIG.STORAGE.VIDEOS_DIR
|
||||
|
||||
return readdir(videoFileDir)
|
||||
.then(videoFiles => {
|
||||
const tasks: Promise<any>[] = []
|
||||
for (const videoFile of videoFiles) {
|
||||
const matches = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.([a-z0-9]+)/.exec(videoFile)
|
||||
if (matches === null) {
|
||||
console.log('Invalid video file name %s.', videoFile)
|
||||
continue
|
||||
}
|
||||
|
||||
const uuid = matches[1]
|
||||
const ext = matches[2]
|
||||
|
||||
const p = getVideoStreamDimensionsInfo(join(videoFileDir, videoFile))
|
||||
.then(async ({ resolution }) => {
|
||||
const oldTorrentName = uuid + '.torrent'
|
||||
const newTorrentName = uuid + '-' + resolution + '.torrent'
|
||||
await rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => resolution)
|
||||
|
||||
const newVideoFileName = uuid + '-' + resolution + '.' + ext
|
||||
await rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => resolution)
|
||||
|
||||
const query = 'UPDATE "VideoFiles" SET "resolution" = ' + resolution +
|
||||
' WHERE "videoId" = (SELECT "id" FROM "Videos" WHERE "uuid" = \'' + uuid + '\')'
|
||||
return utils.sequelize.query(query)
|
||||
})
|
||||
|
||||
tasks.push(p)
|
||||
}
|
||||
|
||||
return Promise.all(tasks).then(() => undefined)
|
||||
})
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
import { buildUUID } from '@shared/extra-utils'
|
||||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
// Assert not friends
|
||||
|
||||
// Create uuid column for author
|
||||
const dataAuthorUUID = {
|
||||
type: Sequelize.UUID,
|
||||
defaultValue: Sequelize.UUIDV4,
|
||||
allowNull: true
|
||||
}
|
||||
await q.addColumn('Authors', 'uuid', dataAuthorUUID)
|
||||
|
||||
// Set UUID to previous authors
|
||||
{
|
||||
const authors = await utils.db.Author.findAll()
|
||||
for (const author of authors) {
|
||||
author.uuid = buildUUID()
|
||||
await author.save()
|
||||
}
|
||||
}
|
||||
|
||||
dataAuthorUUID.allowNull = false
|
||||
await q.changeColumn('Authors', 'uuid', dataAuthorUUID)
|
||||
|
||||
// Create one author per user that does not already exist
|
||||
const users = await utils.db.User.findAll()
|
||||
for (const user of users) {
|
||||
const author = await utils.db.Author.find({ where: { userId: user.id } })
|
||||
if (!author) {
|
||||
await utils.db.Author.create({
|
||||
name: user.username,
|
||||
podId: null, // It is our pod
|
||||
userId: user.id
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Create video channels table
|
||||
await utils.db.VideoChannel.sync()
|
||||
|
||||
// For each author, create its default video channel
|
||||
const authors = await utils.db.Author.findAll()
|
||||
for (const author of authors) {
|
||||
await utils.db.VideoChannel.create({
|
||||
name: `Default ${author.name} channel`,
|
||||
remote: false,
|
||||
authorId: author.id
|
||||
})
|
||||
}
|
||||
|
||||
// Create channelId column for videos
|
||||
const dataChannelId = {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: null,
|
||||
allowNull: true
|
||||
}
|
||||
await q.addColumn('Videos', 'channelId', dataChannelId)
|
||||
|
||||
const query = 'SELECT "id", "authorId" FROM "Videos"'
|
||||
const options = {
|
||||
type: Sequelize.QueryTypes.SELECT
|
||||
}
|
||||
const rawVideos = await utils.sequelize.query(query, options) as any
|
||||
|
||||
for (const rawVideo of rawVideos) {
|
||||
const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId } })
|
||||
|
||||
const video = await utils.db.Video.findByPk(rawVideo.id)
|
||||
video.channelId = videoChannel.id
|
||||
await video.save()
|
||||
}
|
||||
|
||||
dataChannelId.allowNull = false
|
||||
await q.changeColumn('Videos', 'channelId', dataChannelId)
|
||||
|
||||
const constraintName = 'Videos_channelId_fkey'
|
||||
const queryForeignKey = 'ALTER TABLE "Videos" ' +
|
||||
' ADD CONSTRAINT "' + constraintName + '"' +
|
||||
' FOREIGN KEY ("channelId") REFERENCES "VideoChannels" ON UPDATE CASCADE ON DELETE CASCADE'
|
||||
|
||||
await utils.sequelize.query(queryForeignKey)
|
||||
|
||||
await q.removeColumn('Videos', 'authorId')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
// update "Applications" SET "migrationVersion" = 75;
|
||||
// delete from "Authors";
|
||||
// alter table "Authors" drop column "uuid";
|
||||
// ALTER SEQUENCE "Authors_id_seq" RESTART WITH 1
|
||||
// INSERT INTO "Authors" ("name", "createdAt", "updatedAt", "userId") VALUES ('root', NOW(), NOW(), 1);
|
||||
// alter table "Videos" drop column "channelId";
|
||||
// drop table "VideoChannels";
|
||||
// alter table "Videos" add column "authorId" INTEGER DEFAULT 1;
|
||||
// alter table "Videos" ADD CONSTRAINT "coucou" FOREIGN KEY ("authorId") REFERENCES "Authors"
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
await q.renameColumn('Users', 'role', 'oldRole')
|
||||
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true
|
||||
}
|
||||
await q.addColumn('Users', 'role', data)
|
||||
|
||||
let query = 'UPDATE "Users" SET "role" = 0 WHERE "oldRole" = \'admin\''
|
||||
await utils.sequelize.query(query)
|
||||
|
||||
query = 'UPDATE "Users" SET "role" = 2 WHERE "oldRole" = \'user\''
|
||||
await utils.sequelize.query(query)
|
||||
|
||||
data.allowNull = false
|
||||
await q.changeColumn('Users', 'role', data)
|
||||
|
||||
await q.removeColumn('Users', 'oldRole')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.STRING(3000),
|
||||
allowNull: false
|
||||
}
|
||||
await q.changeColumn('Videos', 'description', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: null,
|
||||
allowNull: true
|
||||
}
|
||||
await q.addColumn('Videos', 'privacy', data)
|
||||
|
||||
const query = 'UPDATE "Videos" SET "privacy" = 1'
|
||||
const options = {
|
||||
type: Sequelize.QueryTypes.BULKUPDATE
|
||||
}
|
||||
await utils.sequelize.query(query, options)
|
||||
|
||||
data.allowNull = false
|
||||
await q.changeColumn('Videos', 'privacy', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,216 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto'
|
||||
import { shareVideoByServerAndChannel } from '../../lib/activitypub/share'
|
||||
import { getLocalVideoActivityPubUrl, getLocalVideoChannelActivityPubUrl } from '../../lib/activitypub/url'
|
||||
import { createLocalAccountWithoutKeys } from '../../lib/user'
|
||||
import { ApplicationModel } from '../../models/application/application'
|
||||
import { SERVER_ACTOR_NAME } from '../constants'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
const db = utils.db
|
||||
|
||||
// Assert there are no friends
|
||||
{
|
||||
const query = 'SELECT COUNT(*) as total FROM "Pods"'
|
||||
const options = {
|
||||
type: Sequelize.QueryTypes.SELECT
|
||||
}
|
||||
const res = await utils.sequelize.query(query, options) as any
|
||||
|
||||
if (!res[0] || res[0].total !== 0) {
|
||||
throw new Error('You need to quit friends.')
|
||||
}
|
||||
}
|
||||
|
||||
// Pods -> Servers
|
||||
await utils.queryInterface.renameTable('Pods', 'Servers')
|
||||
|
||||
// Create Account table
|
||||
await db.Account.sync()
|
||||
|
||||
// Create AccountFollows table
|
||||
await db.AccountFollow.sync()
|
||||
|
||||
// Modify video abuse table
|
||||
await db.VideoAbuse.destroy({ truncate: true })
|
||||
await utils.queryInterface.removeColumn('VideoAbuses', 'reporterPodId')
|
||||
await utils.queryInterface.removeColumn('VideoAbuses', 'reporterUsername')
|
||||
|
||||
// Create column link with Account table
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: 'Accounts',
|
||||
key: 'id'
|
||||
},
|
||||
onDelete: 'CASCADE'
|
||||
}
|
||||
await q.addColumn('VideoAbuses', 'reporterAccountId', data)
|
||||
}
|
||||
|
||||
// Drop request tables
|
||||
await utils.queryInterface.dropTable('RequestToPods')
|
||||
await utils.queryInterface.dropTable('RequestVideoEvents')
|
||||
await utils.queryInterface.dropTable('RequestVideoQadus')
|
||||
await utils.queryInterface.dropTable('Requests')
|
||||
|
||||
// Create application account
|
||||
{
|
||||
const applicationInstance = await ApplicationModel.findOne()
|
||||
const accountCreated = await createLocalAccountWithoutKeys({
|
||||
name: SERVER_ACTOR_NAME,
|
||||
userId: null,
|
||||
applicationId: applicationInstance.id,
|
||||
t: undefined
|
||||
})
|
||||
|
||||
const { publicKey, privateKey } = await createPrivateAndPublicKeys()
|
||||
accountCreated.Actor.publicKey = publicKey
|
||||
accountCreated.Actor.privateKey = privateKey
|
||||
|
||||
await accountCreated.save()
|
||||
}
|
||||
|
||||
// Drop old video channel foreign key (referencing Authors)
|
||||
{
|
||||
const query = 'ALTER TABLE "VideoChannels" DROP CONSTRAINT "VideoChannels_authorId_fkey"'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
// Recreate accounts for each user
|
||||
const users = await db.User.findAll()
|
||||
for (const user of users) {
|
||||
const account = await createLocalAccountWithoutKeys({ name: user.username, userId: user.id, applicationId: null, t: undefined })
|
||||
|
||||
const { publicKey, privateKey } = await createPrivateAndPublicKeys()
|
||||
account.Actor.publicKey = publicKey
|
||||
account.Actor.privateKey = privateKey
|
||||
await account.save()
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
onDelete: 'CASCADE',
|
||||
reference: {
|
||||
model: 'Account',
|
||||
key: 'id'
|
||||
}
|
||||
}
|
||||
await q.addColumn('VideoChannels', 'accountId', data)
|
||||
|
||||
{
|
||||
const query = 'UPDATE "VideoChannels" SET "accountId" = ' +
|
||||
'(SELECT "Accounts"."id" FROM "Accounts" INNER JOIN "Authors" ON "Authors"."userId" = "Accounts"."userId" ' +
|
||||
'WHERE "VideoChannels"."authorId" = "Authors"."id")'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
data.allowNull = false
|
||||
await q.changeColumn('VideoChannels', 'accountId', data)
|
||||
|
||||
await q.removeColumn('VideoChannels', 'authorId')
|
||||
}
|
||||
|
||||
// Add url column to "Videos"
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING,
|
||||
defaultValue: null,
|
||||
allowNull: true
|
||||
}
|
||||
await q.addColumn('Videos', 'url', data)
|
||||
|
||||
const videos = await db.Video.findAll()
|
||||
for (const video of videos) {
|
||||
video.url = getLocalVideoActivityPubUrl(video)
|
||||
await video.save()
|
||||
}
|
||||
|
||||
data.allowNull = false
|
||||
await q.changeColumn('Videos', 'url', data)
|
||||
}
|
||||
|
||||
// Add url column to "VideoChannels"
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING,
|
||||
defaultValue: null,
|
||||
allowNull: true
|
||||
}
|
||||
await q.addColumn('VideoChannels', 'url', data)
|
||||
|
||||
const videoChannels = await db.VideoChannel.findAll()
|
||||
for (const videoChannel of videoChannels) {
|
||||
videoChannel.url = getLocalVideoChannelActivityPubUrl(videoChannel)
|
||||
await videoChannel.save()
|
||||
}
|
||||
|
||||
data.allowNull = false
|
||||
await q.changeColumn('VideoChannels', 'url', data)
|
||||
}
|
||||
|
||||
// Loss old video rates, whatever
|
||||
await utils.queryInterface.dropTable('UserVideoRates')
|
||||
await db.AccountVideoRate.sync()
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.ENUM('transcoding', 'activitypub-http'),
|
||||
defaultValue: 'transcoding',
|
||||
allowNull: false
|
||||
}
|
||||
await q.addColumn('Jobs', 'category', data)
|
||||
}
|
||||
|
||||
await db.VideoShare.sync()
|
||||
await db.VideoChannelShare.sync()
|
||||
|
||||
{
|
||||
const videos = await db.Video.findAll({
|
||||
include: [
|
||||
{
|
||||
model: db.Video['sequelize'].models.VideoChannel,
|
||||
include: [
|
||||
{
|
||||
model: db.Video['sequelize'].models.Account,
|
||||
include: [ { model: db.Video['sequelize'].models.Server, required: false } ]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
model: db.Video['sequelize'].models.AccountVideoRate,
|
||||
include: [ db.Video['sequelize'].models.Account ]
|
||||
},
|
||||
{
|
||||
model: db.Video['sequelize'].models.VideoShare,
|
||||
include: [ db.Video['sequelize'].models.Account ]
|
||||
},
|
||||
db.Video['sequelize'].models.Tag,
|
||||
db.Video['sequelize'].models.VideoFile
|
||||
]
|
||||
})
|
||||
|
||||
for (const video of videos) {
|
||||
await shareVideoByServerAndChannel(video, undefined)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
await utils.queryInterface.removeColumn('Servers', 'email')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
await utils.queryInterface.removeColumn('Servers', 'publicKey')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
await utils.db.Avatar.sync()
|
||||
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: 'Avatars',
|
||||
key: 'id'
|
||||
},
|
||||
onDelete: 'CASCADE'
|
||||
}
|
||||
await utils.queryInterface.addColumn('Accounts', 'avatarId', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('Videos', 'licence', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('Videos', 'category', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(10000),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('Videos', 'description', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
await utils.queryInterface.renameTable('Applications', 'application')
|
||||
await utils.queryInterface.renameTable('AccountFollows', 'accountFollow')
|
||||
await utils.queryInterface.renameTable('AccountVideoRates', 'accountVideoRate')
|
||||
await utils.queryInterface.renameTable('Accounts', 'account')
|
||||
await utils.queryInterface.renameTable('Avatars', 'avatar')
|
||||
await utils.queryInterface.renameTable('BlacklistedVideos', 'videoBlacklist')
|
||||
await utils.queryInterface.renameTable('Jobs', 'job')
|
||||
await utils.queryInterface.renameTable('OAuthClients', 'oAuthClient')
|
||||
await utils.queryInterface.renameTable('OAuthTokens', 'oAuthToken')
|
||||
await utils.queryInterface.renameTable('Servers', 'server')
|
||||
await utils.queryInterface.renameTable('Tags', 'tag')
|
||||
await utils.queryInterface.renameTable('Users', 'user')
|
||||
await utils.queryInterface.renameTable('VideoAbuses', 'videoAbuse')
|
||||
await utils.queryInterface.renameTable('VideoChannels', 'videoChannel')
|
||||
await utils.queryInterface.renameTable('VideoChannelShares', 'videoChannelShare')
|
||||
await utils.queryInterface.renameTable('VideoFiles', 'videoFile')
|
||||
await utils.queryInterface.renameTable('VideoShares', 'videoShare')
|
||||
await utils.queryInterface.renameTable('VideoTags', 'videoTag')
|
||||
await utils.queryInterface.renameTable('Videos', 'video')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const q = utils.queryInterface
|
||||
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true
|
||||
}
|
||||
|
||||
return q.addColumn('user', 'autoPlayVideo', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,260 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { DataType } from 'sequelize-typescript'
|
||||
import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
// Create actor table
|
||||
{
|
||||
const queries = [
|
||||
`DROP TYPE IF EXISTS enum_actor_type`,
|
||||
`
|
||||
CREATE TYPE enum_actor_type AS ENUM (
|
||||
'Group',
|
||||
'Person',
|
||||
'Application'
|
||||
)
|
||||
`,
|
||||
`
|
||||
CREATE TABLE actor (
|
||||
id integer NOT NULL,
|
||||
type enum_actor_type NOT NULL,
|
||||
uuid uuid NOT NULL,
|
||||
"preferredUsername" character varying(255) NOT NULL,
|
||||
url character varying(2000) NOT NULL,
|
||||
"publicKey" character varying(5000),
|
||||
"privateKey" character varying(5000),
|
||||
"followersCount" integer NOT NULL,
|
||||
"followingCount" integer NOT NULL,
|
||||
"inboxUrl" character varying(2000) NOT NULL,
|
||||
"outboxUrl" character varying(2000) NOT NULL,
|
||||
"sharedInboxUrl" character varying(2000) NOT NULL,
|
||||
"followersUrl" character varying(2000) NOT NULL,
|
||||
"followingUrl" character varying(2000) NOT NULL,
|
||||
"avatarId" integer,
|
||||
"serverId" integer,
|
||||
"createdAt" timestamp with time zone NOT NULL,
|
||||
"updatedAt" timestamp with time zone NOT NULL
|
||||
);`,
|
||||
`CREATE SEQUENCE actor_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1`,
|
||||
`ALTER SEQUENCE actor_id_seq OWNED BY actor.id`,
|
||||
`ALTER TABLE ONLY actor ALTER COLUMN id SET DEFAULT nextval('actor_id_seq'::regclass)`,
|
||||
`ALTER TABLE ONLY actor ADD CONSTRAINT actor_pkey PRIMARY KEY (id);`,
|
||||
`CREATE UNIQUE INDEX actor_preferred_username_server_id ON actor USING btree ("preferredUsername", "serverId")`,
|
||||
`ALTER TABLE ONLY actor
|
||||
ADD CONSTRAINT "actor_avatarId_fkey" FOREIGN KEY ("avatarId") REFERENCES avatar(id) ON UPDATE CASCADE ON DELETE CASCADE`,
|
||||
`ALTER TABLE ONLY actor
|
||||
ADD CONSTRAINT "actor_serverId_fkey" FOREIGN KEY ("serverId") REFERENCES server(id) ON UPDATE CASCADE ON DELETE CASCADE;`
|
||||
]
|
||||
|
||||
for (const query of queries) {
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const query1 =
|
||||
`
|
||||
INSERT INTO "actor"
|
||||
(
|
||||
type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl",
|
||||
"sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt"
|
||||
)
|
||||
SELECT
|
||||
'Application', uuid, name, url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl",
|
||||
"sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt"
|
||||
FROM account
|
||||
WHERE "applicationId" IS NOT NULL
|
||||
`
|
||||
await utils.sequelize.query(query1)
|
||||
|
||||
const query2 =
|
||||
`
|
||||
INSERT INTO "actor"
|
||||
(
|
||||
type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl",
|
||||
"sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt"
|
||||
)
|
||||
SELECT
|
||||
'Person', uuid, name, url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl",
|
||||
"sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt"
|
||||
FROM account
|
||||
WHERE "applicationId" IS NULL
|
||||
`
|
||||
await utils.sequelize.query(query2)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: DataType.INTEGER,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: 'actor',
|
||||
key: 'id'
|
||||
},
|
||||
onDelete: 'CASCADE'
|
||||
}
|
||||
await utils.queryInterface.addColumn('account', 'actorId', data)
|
||||
|
||||
const query1 = `UPDATE account SET "actorId" = (SELECT id FROM actor WHERE actor.url = account.url)`
|
||||
await utils.sequelize.query(query1)
|
||||
|
||||
data.allowNull = false
|
||||
await utils.queryInterface.changeColumn('account', 'actorId', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = `
|
||||
INSERT INTO actor
|
||||
(
|
||||
type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl",
|
||||
"sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt"
|
||||
)
|
||||
SELECT
|
||||
'Group', "videoChannel".uuid, "videoChannel".uuid, "videoChannel".url, null, null, 0, 0, "videoChannel".url || '/inbox',
|
||||
"videoChannel".url || '/outbox', "videoChannel".url || '/inbox', "videoChannel".url || '/followers', "videoChannel".url || '/following',
|
||||
null, account."serverId", "videoChannel"."createdAt", "videoChannel"."updatedAt"
|
||||
FROM "videoChannel"
|
||||
INNER JOIN "account" on "videoChannel"."accountId" = "account".id
|
||||
`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: DataType.INTEGER,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: 'actor',
|
||||
key: 'id'
|
||||
},
|
||||
onDelete: 'CASCADE'
|
||||
}
|
||||
await utils.queryInterface.addColumn('videoChannel', 'actorId', data)
|
||||
|
||||
const query1 = `UPDATE "videoChannel" SET "actorId" = (SELECT id FROM actor WHERE actor.url = "videoChannel".url)`
|
||||
await utils.sequelize.query(query1)
|
||||
|
||||
data.allowNull = false
|
||||
await utils.queryInterface.changeColumn('videoChannel', 'actorId', data)
|
||||
}
|
||||
|
||||
{
|
||||
await utils.queryInterface.renameTable('accountFollow', 'actorFollow')
|
||||
await utils.queryInterface.renameColumn('actorFollow', 'accountId', 'actorId')
|
||||
await utils.queryInterface.renameColumn('actorFollow', 'targetAccountId', 'targetActorId')
|
||||
|
||||
try {
|
||||
await utils.queryInterface.removeConstraint('actorFollow', 'AccountFollows_accountId_fkey')
|
||||
await utils.queryInterface.removeConstraint('actorFollow', 'AccountFollows_targetAccountId_fkey')
|
||||
} catch {
|
||||
await utils.queryInterface.removeConstraint('actorFollow', 'accountFollow_accountId_fkey')
|
||||
await utils.queryInterface.removeConstraint('actorFollow', 'accountFollow_targetAccountId_fkey')
|
||||
}
|
||||
|
||||
{
|
||||
const query1 = `UPDATE "actorFollow"
|
||||
SET "actorId" =
|
||||
(SELECT "account"."actorId" FROM account WHERE "account"."id" = "actorFollow"."actorId")`
|
||||
await utils.sequelize.query(query1)
|
||||
|
||||
const query2 = `UPDATE "actorFollow"
|
||||
SET "targetActorId" =
|
||||
(SELECT "account"."actorId" FROM account WHERE "account"."id" = "actorFollow"."targetActorId")`
|
||||
|
||||
await utils.sequelize.query(query2)
|
||||
}
|
||||
|
||||
{
|
||||
const query1 = `ALTER TABLE ONLY "actorFollow"
|
||||
ADD CONSTRAINT "actorFollow_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES actor(id) ON UPDATE CASCADE ON DELETE CASCADE;`
|
||||
await utils.sequelize.query(query1)
|
||||
|
||||
const query2 = `ALTER TABLE ONLY "actorFollow"
|
||||
ADD CONSTRAINT "actorFollow_targetActorId_fkey" FOREIGN KEY ("targetActorId") REFERENCES actor(id) ON UPDATE CASCADE ON DELETE CASCADE;`
|
||||
await utils.sequelize.query(query2)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
await utils.queryInterface.renameColumn('videoShare', 'accountId', 'actorId')
|
||||
|
||||
try {
|
||||
await utils.queryInterface.removeConstraint('videoShare', 'VideoShares_accountId_fkey')
|
||||
} catch {
|
||||
await utils.queryInterface.removeConstraint('videoShare', 'videoShare_accountId_fkey')
|
||||
}
|
||||
|
||||
const query = `UPDATE "videoShare"
|
||||
SET "actorId" =
|
||||
(SELECT "actorId" FROM account WHERE id = "videoShare"."actorId")`
|
||||
await utils.sequelize.query(query)
|
||||
|
||||
{
|
||||
const query1 = `ALTER TABLE ONLY "videoShare"
|
||||
ADD CONSTRAINT "videoShare_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES actor(id) ON UPDATE CASCADE ON DELETE CASCADE;`
|
||||
await utils.sequelize.query(query1)
|
||||
|
||||
const query2 = `ALTER TABLE ONLY "videoShare"
|
||||
ADD CONSTRAINT "videoShare_videoId_fkey" FOREIGN KEY ("videoId") REFERENCES video(id) ON UPDATE CASCADE ON DELETE CASCADE;`
|
||||
await utils.sequelize.query(query2)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const columnsToDelete = [
|
||||
'uuid',
|
||||
'url',
|
||||
'publicKey',
|
||||
'privateKey',
|
||||
'followersCount',
|
||||
'followingCount',
|
||||
'inboxUrl',
|
||||
'outboxUrl',
|
||||
'sharedInboxUrl',
|
||||
'followersUrl',
|
||||
'followingUrl',
|
||||
'serverId',
|
||||
'avatarId'
|
||||
]
|
||||
for (const columnToDelete of columnsToDelete) {
|
||||
await utils.queryInterface.removeColumn('account', columnToDelete)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const columnsToDelete = [
|
||||
'uuid',
|
||||
'remote',
|
||||
'url'
|
||||
]
|
||||
for (const columnToDelete of columnsToDelete) {
|
||||
await utils.queryInterface.removeColumn('videoChannel', columnToDelete)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'SELECT * FROM "actor" WHERE "serverId" IS NULL AND "publicKey" IS NULL'
|
||||
const options = { type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT }
|
||||
const [ res ] = await utils.sequelize.query<any>(query, options)
|
||||
|
||||
for (const actor of res) {
|
||||
const { privateKey, publicKey } = await createPrivateAndPublicKeys()
|
||||
|
||||
const queryUpdate = `UPDATE "actor" SET "publicKey" = '${publicKey}', "privateKey" = '${privateKey}' WHERE id = ${actor.id}`
|
||||
await utils.sequelize.query(queryUpdate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { WEBSERVER } from '../constants'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const toReplace = WEBSERVER.HOSTNAME + ':443'
|
||||
const by = WEBSERVER.HOST
|
||||
const replacer = column => `replace("${column}", '${toReplace}', '${by}')`
|
||||
|
||||
{
|
||||
const query = `UPDATE video SET url = ${replacer('url')}`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const query = `
|
||||
UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')},
|
||||
"sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')},
|
||||
"followingUrl" = ${replacer('followingUrl')}
|
||||
`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const query = `UPDATE server SET host = replace(host, ':443', '')`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
await utils.queryInterface.dropTable('Authors')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
await utils.queryInterface.removeConstraint('actor', 'actor_avatarId_fkey')
|
||||
|
||||
await utils.queryInterface.addConstraint('actor', {
|
||||
fields: [ 'avatarId' ],
|
||||
type: 'foreign key',
|
||||
references: {
|
||||
table: 'avatar',
|
||||
field: 'id'
|
||||
},
|
||||
onDelete: 'set null',
|
||||
onUpdate: 'CASCADE'
|
||||
})
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { Migration } from '../../models/migrations'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true
|
||||
} as Migration.Boolean
|
||||
await utils.queryInterface.addColumn('video', 'commentsEnabled', data)
|
||||
|
||||
data.defaultValue = null
|
||||
return utils.queryInterface.changeColumn('video', 'commentsEnabled', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
{
|
||||
const toReplace = ':443'
|
||||
const by = ''
|
||||
const replacer = column => `replace("${column}", '${toReplace}', '${by}')`
|
||||
|
||||
const query = `
|
||||
UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')},
|
||||
"sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')},
|
||||
"followingUrl" = ${replacer('followingUrl')}
|
||||
`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const toReplace = '/account/'
|
||||
const by = '/accounts/'
|
||||
const replacer = column => `replace("${column}", '${toReplace}', '${by}')`
|
||||
|
||||
const query = `
|
||||
UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')},
|
||||
"sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')},
|
||||
"followingUrl" = ${replacer('followingUrl')}
|
||||
`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
{
|
||||
const toReplace = ':443'
|
||||
const by = ''
|
||||
const replacer = column => `replace("${column}", '${toReplace}', '${by}')`
|
||||
|
||||
const query = `UPDATE video SET url = ${replacer('url')}`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { ACTOR_FOLLOW_SCORE } from '../constants'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
await utils.queryInterface.removeColumn('server', 'score')
|
||||
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: ACTOR_FOLLOW_SCORE.BASE
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('actorFollow', 'score', data)
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const query = 'UPDATE "actor" SET ' +
|
||||
'"followersCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."targetActorId"), ' +
|
||||
'"followingCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."actorId") ' +
|
||||
'WHERE "actor"."serverId" IS NULL'
|
||||
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
await utils.queryInterface.dropTable('job')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
{
|
||||
const query = 'DELETE FROM "videoShare" s1 ' +
|
||||
'USING (SELECT MIN(id) as id, "actorId", "videoId" FROM "videoShare" GROUP BY "actorId", "videoId" HAVING COUNT(*) > 1) s2 ' +
|
||||
'WHERE s1."actorId" = s2."actorId" AND s1."videoId" = s2."videoId" AND s1.id <> s2.id'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('videoShare', 'url', data)
|
||||
|
||||
const query = `UPDATE "videoShare" SET "url" = (SELECT "url" FROM "video" WHERE "id" = "videoId") || '/announces/' || "actorId"`
|
||||
await utils.sequelize.query(query)
|
||||
|
||||
data.allowNull = false
|
||||
await utils.queryInterface.changeColumn('videoShare', 'url', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
{
|
||||
const query = 'DELETE FROM "videoComment" s1 ' +
|
||||
'USING (SELECT MIN(id) as id, url FROM "videoComment" GROUP BY "url" HAVING COUNT(*) > 1) s2 ' +
|
||||
'WHERE s1."url" = s2."url" AND s1.id <> s2.id'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(500),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('video', 'support', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(500),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('videoChannel', 'support', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(250),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('account', 'description', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(10000),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('video', 'description', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: Sequelize.NOW
|
||||
}
|
||||
await utils.queryInterface.addColumn('video', 'publishedAt', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE video SET "publishedAt" = video."createdAt"'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
// Sequelize does not alter the column with NOW as default value
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: Sequelize.NOW
|
||||
}
|
||||
await utils.queryInterface.changeColumn('video', 'publishedAt', data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.ENUM('do_not_list', 'blur', 'display'),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('user', 'nsfwPolicy', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "user" SET "nsfwPolicy" = \'do_not_list\''
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "user" SET "nsfwPolicy" = \'display\' WHERE "displayNSFW" = true'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'ALTER TABLE "user" ALTER COLUMN "nsfwPolicy" SET NOT NULL'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
await utils.queryInterface.removeColumn('user', 'displayNSFW')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { CONSTRAINTS_FIELDS } from '../constants'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
await utils.queryInterface.renameColumn('video', 'language', 'oldLanguage')
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.LANGUAGE.max),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('video', 'language', data)
|
||||
}
|
||||
|
||||
{
|
||||
const languages = [
|
||||
{
|
||||
oldLanguage: 1,
|
||||
newLanguage: 'en'
|
||||
},
|
||||
{
|
||||
oldLanguage: 2,
|
||||
newLanguage: 'es'
|
||||
},
|
||||
{
|
||||
oldLanguage: 3,
|
||||
newLanguage: 'zh'
|
||||
},
|
||||
{
|
||||
oldLanguage: 4,
|
||||
newLanguage: 'hi'
|
||||
},
|
||||
{
|
||||
oldLanguage: 5,
|
||||
newLanguage: 'ar'
|
||||
},
|
||||
{
|
||||
oldLanguage: 6,
|
||||
newLanguage: 'pt'
|
||||
},
|
||||
{
|
||||
oldLanguage: 7,
|
||||
newLanguage: 'bn'
|
||||
},
|
||||
{
|
||||
oldLanguage: 8,
|
||||
newLanguage: 'ru'
|
||||
},
|
||||
{
|
||||
oldLanguage: 9,
|
||||
newLanguage: 'ja'
|
||||
},
|
||||
{
|
||||
oldLanguage: 10,
|
||||
newLanguage: 'pa'
|
||||
},
|
||||
{
|
||||
oldLanguage: 11,
|
||||
newLanguage: 'de'
|
||||
},
|
||||
{
|
||||
oldLanguage: 12,
|
||||
newLanguage: 'ko'
|
||||
},
|
||||
{
|
||||
oldLanguage: 13,
|
||||
newLanguage: 'fr'
|
||||
},
|
||||
{
|
||||
oldLanguage: 14,
|
||||
newLanguage: 'it'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1000,
|
||||
newLanguage: 'sgn'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1001,
|
||||
newLanguage: 'ase'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1002,
|
||||
newLanguage: 'sdl'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1003,
|
||||
newLanguage: 'bfi'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1004,
|
||||
newLanguage: 'bzs'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1005,
|
||||
newLanguage: 'csl'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1006,
|
||||
newLanguage: 'cse'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1007,
|
||||
newLanguage: 'dsl'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1008,
|
||||
newLanguage: 'fsl'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1009,
|
||||
newLanguage: 'gsg'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1010,
|
||||
newLanguage: 'pks'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1011,
|
||||
newLanguage: 'jsl'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1012,
|
||||
newLanguage: 'sfs'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1013,
|
||||
newLanguage: 'swl'
|
||||
},
|
||||
{
|
||||
oldLanguage: 1014,
|
||||
newLanguage: 'rsl'
|
||||
}
|
||||
]
|
||||
|
||||
for (const language of languages) {
|
||||
const query = 'UPDATE "video" SET "language" = \'' + language.newLanguage + '\' WHERE "oldLanguage" = ' + language.oldLanguage
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
await utils.queryInterface.removeColumn('video', 'oldLanguage')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(500),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('video', 'support', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(500),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('videoChannel', 'support', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(500),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('videoChannel', 'description', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
// waitingTranscoding column
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('video', 'waitTranscoding', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE video SET "waitTranscoding" = false'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('video', 'waitTranscoding', data)
|
||||
}
|
||||
|
||||
// state
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('video', 'state', data)
|
||||
}
|
||||
|
||||
{
|
||||
// Published
|
||||
const query = 'UPDATE video SET "state" = 1'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('video', 'state', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,22 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('videoFile', 'fps', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,37 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
await utils.sequelize.query('DROP INDEX IF EXISTS video_id_privacy_state_wait_transcoding;')
|
||||
await utils.sequelize.query('DROP INDEX IF EXISTS video_name;')
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const query = 'DELETE FROM "videoFile" WHERE id IN ' +
|
||||
'(SELECT id FROM (SELECT MIN(id) AS id, "videoId", "resolution", "fps" ' +
|
||||
'FROM "videoFile" GROUP BY "videoId", "resolution", "fps" HAVING COUNT(*) > 1) t)'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const query = 'DELETE FROM "actor" WHERE id IN ' +
|
||||
'(SELECT id FROM (SELECT MIN(id) AS id, "uuid" ' +
|
||||
'FROM "actor" GROUP BY "uuid" HAVING COUNT(*) > 1) t)'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const query = 'DELETE FROM "account" WHERE id IN ' +
|
||||
'(SELECT id FROM (SELECT MIN(id) AS id, "actorId" ' +
|
||||
'FROM "account" GROUP BY "actorId" HAVING COUNT(*) > 1) t)'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,80 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
|
||||
const indexNames = [
|
||||
'accounts_application_id',
|
||||
'accounts_user_id',
|
||||
'accounts_name',
|
||||
|
||||
'account_video_rates_video_id_account_id',
|
||||
'account_video_rates_video_id_account_id_type',
|
||||
|
||||
'account_follows_account_id_target_account_id',
|
||||
'account_follow_account_id_target_account_id',
|
||||
'account_follow_account_id',
|
||||
'account_follow_target_account_id',
|
||||
'account_follows_account_id',
|
||||
'account_follows_target_account_id',
|
||||
|
||||
'o_auth_clients_client_id',
|
||||
'o_auth_clients_client_id_client_secret',
|
||||
|
||||
'o_auth_tokens_access_token',
|
||||
'o_auth_tokens_refresh_token',
|
||||
'o_auth_tokens_o_auth_client_id',
|
||||
'o_auth_tokens_user_id',
|
||||
|
||||
'pods_host',
|
||||
'servers_host',
|
||||
|
||||
'tags_name',
|
||||
|
||||
'users_email',
|
||||
'users_username',
|
||||
|
||||
'videos_channel_id',
|
||||
'videos_created_at',
|
||||
'videos_duration',
|
||||
'videos_likes',
|
||||
'videos_name',
|
||||
'videos_uuid',
|
||||
'videos_views',
|
||||
|
||||
'video_abuses_reporter_account_id',
|
||||
'video_abuses_video_id',
|
||||
|
||||
'blacklisted_videos_video_id',
|
||||
|
||||
'video_channels_account_id',
|
||||
|
||||
'video_files_info_hash',
|
||||
'video_files_video_id',
|
||||
|
||||
'video_shares_account_id',
|
||||
'video_shares_video_id',
|
||||
|
||||
'video_tags_tag_id',
|
||||
'video_tags_video_id'
|
||||
]
|
||||
|
||||
for (const indexName of indexNames) {
|
||||
await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";')
|
||||
}
|
||||
|
||||
await utils.sequelize.query('ALTER TABLE "account" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";')
|
||||
await utils.sequelize.query('ALTER TABLE "videoChannel" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";')
|
||||
await utils.sequelize.query('ALTER TABLE "videoShare" DROP CONSTRAINT IF EXISTS "VideoShares_videoId_fkey";')
|
||||
|
||||
await utils.sequelize.query('DROP TABLE IF EXISTS "videoChannelShare";')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,45 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('user', 'blocked', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "user" SET "blocked" = false'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('user', 'blocked', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(250),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('user', 'blockedReason', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,46 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { AbuseState } from '../../../shared/models'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('videoAbuse', 'state', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "videoAbuse" SET "state" = ' + AbuseState.PENDING
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('videoAbuse', 'state', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(300),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('videoAbuse', 'moderationComment', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,23 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(300),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('videoBlacklist', 'reason', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,22 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BIGINT,
|
||||
allowNull: false,
|
||||
defaultValue: -1
|
||||
}
|
||||
await utils.queryInterface.addColumn('user', 'videoQuotaDaily', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,24 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('user', 'emailVerified', data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,24 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('server', 'redundancyAllowed', data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,40 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
// Delete duplicated keys
|
||||
{
|
||||
const query = 'DELETE FROM "server" s1 USING "server" s2 WHERE s1.id < s2.id AND s1."host" = s2."host"'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'DELETE FROM "videoFile" vf1 USING "videoFile" vf2 WHERE vf1.id < vf2.id ' +
|
||||
'AND vf1."videoId" = vf2."videoId" AND vf1.resolution = vf2.resolution AND vf1.fps IS NULL'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "videoFile" SET fps = -1 WHERE fps IS NULL;'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: -1
|
||||
}
|
||||
await utils.queryInterface.changeColumn('videoFile', 'fps', data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,28 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('user', 'webTorrentEnabled', data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function down (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<any> {
|
||||
await utils.queryInterface.removeColumn('user', 'webTorrentEnabled')
|
||||
}
|
||||
|
||||
export { up, down }
|
|
@ -1,53 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(1000),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('video', 'support', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(1000),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('videoChannel', 'support', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(1000),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('videoChannel', 'description', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(1000),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('account', 'description', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(2000),
|
||||
allowNull: true
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('accountVideoRate', 'url', data)
|
||||
}
|
||||
|
||||
{
|
||||
const builtUrlQuery = `SELECT "actor"."url" || '/' || "accountVideoRate"."type" || 's/' || "videoId" ` +
|
||||
'FROM "accountVideoRate" ' +
|
||||
'INNER JOIN account ON account.id = "accountVideoRate"."accountId" ' +
|
||||
'INNER JOIN actor ON actor.id = account."actorId" ' +
|
||||
'WHERE "base".id = "accountVideoRate".id'
|
||||
|
||||
const query = 'UPDATE "accountVideoRate" base SET "url" = (' + builtUrlQuery + ') WHERE "url" IS NULL'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(2000),
|
||||
allowNull: false,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('accountVideoRate', 'url', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
await utils.queryInterface.renameColumn('videoFile', 'extname', 'extname_old')
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING,
|
||||
defaultValue: null,
|
||||
allowNull: true
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('videoFile', 'extname', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "videoFile" SET "extname" = "extname_old"::text'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING,
|
||||
defaultValue: null,
|
||||
allowNull: false
|
||||
}
|
||||
await utils.queryInterface.changeColumn('videoFile', 'extname', data)
|
||||
}
|
||||
|
||||
{
|
||||
await utils.queryInterface.removeColumn('videoFile', 'extname_old')
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('user', 'videosHistoryEnabled', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const query = `INSERT INTO "videoShare" (url, "actorId", "videoId", "createdAt", "updatedAt") ` +
|
||||
`(` +
|
||||
`SELECT ` +
|
||||
`video.url || '/announces/' || "videoChannel"."actorId" as url, ` +
|
||||
`"videoChannel"."actorId" AS "actorId", ` +
|
||||
`"video"."id" AS "videoId", ` +
|
||||
`NOW() AS "createdAt", ` +
|
||||
`NOW() AS "updatedAt" ` +
|
||||
`FROM video ` +
|
||||
`INNER JOIN "videoChannel" ON "video"."channelId" = "videoChannel"."id" ` +
|
||||
`WHERE "video"."remote" = false AND "video"."privacy" != 3 AND "video"."state" = 1` +
|
||||
`) ` +
|
||||
`ON CONFLICT DO NOTHING`
|
||||
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const query = `INSERT INTO "videoShare" (url, "actorId", "videoId", "createdAt", "updatedAt") ` +
|
||||
`(` +
|
||||
`SELECT ` +
|
||||
`video.url || '/announces/' || (SELECT id FROM actor WHERE "preferredUsername" = 'peertube' ORDER BY id ASC LIMIT 1) as url, ` +
|
||||
`(SELECT id FROM actor WHERE "preferredUsername" = 'peertube' ORDER BY id ASC LIMIT 1) AS "actorId", ` +
|
||||
`"video"."id" AS "videoId", ` +
|
||||
`NOW() AS "createdAt", ` +
|
||||
`NOW() AS "updatedAt" ` +
|
||||
`FROM video ` +
|
||||
`WHERE "video"."remote" = false AND "video"."privacy" != 3 AND "video"."state" = 1` +
|
||||
`) ` +
|
||||
`ON CONFLICT DO NOTHING`
|
||||
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const indexNames = [
|
||||
'video_category',
|
||||
'video_licence',
|
||||
'video_nsfw',
|
||||
'video_language',
|
||||
'video_wait_transcoding',
|
||||
'video_state',
|
||||
'video_remote',
|
||||
'video_likes'
|
||||
]
|
||||
|
||||
for (const indexName of indexNames) {
|
||||
await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";')
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
const query = `
|
||||
CREATE TABLE IF NOT EXISTS "userNotificationSetting" ("id" SERIAL,
|
||||
"newVideoFromSubscription" INTEGER NOT NULL DEFAULT NULL,
|
||||
"newCommentOnMyVideo" INTEGER NOT NULL DEFAULT NULL,
|
||||
"videoAbuseAsModerator" INTEGER NOT NULL DEFAULT NULL,
|
||||
"blacklistOnMyVideo" INTEGER NOT NULL DEFAULT NULL,
|
||||
"myVideoPublished" INTEGER NOT NULL DEFAULT NULL,
|
||||
"myVideoImportFinished" INTEGER NOT NULL DEFAULT NULL,
|
||||
"newUserRegistration" INTEGER NOT NULL DEFAULT NULL,
|
||||
"newFollow" INTEGER NOT NULL DEFAULT NULL,
|
||||
"commentMention" INTEGER NOT NULL DEFAULT NULL,
|
||||
"userId" INTEGER REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
PRIMARY KEY ("id"))
|
||||
`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'INSERT INTO "userNotificationSetting" ' +
|
||||
'("newVideoFromSubscription", "newCommentOnMyVideo", "videoAbuseAsModerator", "blacklistOnMyVideo", ' +
|
||||
'"myVideoPublished", "myVideoImportFinished", "newUserRegistration", "newFollow", "commentMention", ' +
|
||||
'"userId", "createdAt", "updatedAt") ' +
|
||||
'(SELECT 1, 1, 3, 3, 1, 1, 1, 1, 1, id, NOW(), NOW() FROM "user")'
|
||||
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('videoBlacklist', 'unfederated', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(3000),
|
||||
allowNull: false,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('videoAbuse', 'reason', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(3000),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('videoAbuse', 'moderationComment', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
const query = `
|
||||
CREATE TABLE IF NOT EXISTS "videoStreamingPlaylist"
|
||||
(
|
||||
"id" SERIAL,
|
||||
"type" INTEGER NOT NULL,
|
||||
"playlistUrl" VARCHAR(2000) NOT NULL,
|
||||
"p2pMediaLoaderInfohashes" VARCHAR(255)[] NOT NULL,
|
||||
"segmentsSha256Url" VARCHAR(255) NOT NULL,
|
||||
"videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('videoRedundancy', 'videoFileId', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'ALTER TABLE "videoRedundancy" ADD COLUMN "videoStreamingPlaylistId" INTEGER NULL ' +
|
||||
'REFERENCES "videoStreamingPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE'
|
||||
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { Migration } from '../../models/migrations'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true
|
||||
} as Migration.Boolean
|
||||
await utils.queryInterface.addColumn('video', 'downloadEnabled', data)
|
||||
|
||||
data.defaultValue = null
|
||||
return utils.queryInterface.changeColumn('video', 'downloadEnabled', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
const data = {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('video', 'originallyPublishedAt', data)
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { buildUUID } from '@shared/extra-utils'
|
||||
import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos'
|
||||
import { WEBSERVER } from '../constants'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
const transaction = utils.transaction
|
||||
|
||||
{
|
||||
const query = `
|
||||
CREATE TABLE IF NOT EXISTS "videoPlaylist"
|
||||
(
|
||||
"id" SERIAL,
|
||||
"name" VARCHAR(255) NOT NULL,
|
||||
"description" VARCHAR(255),
|
||||
"privacy" INTEGER NOT NULL,
|
||||
"url" VARCHAR(2000) NOT NULL,
|
||||
"uuid" UUID NOT NULL,
|
||||
"type" INTEGER NOT NULL DEFAULT 1,
|
||||
"ownerAccountId" INTEGER NOT NULL REFERENCES "account" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
"videoChannelId" INTEGER REFERENCES "videoChannel" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);`
|
||||
await utils.sequelize.query(query, { transaction })
|
||||
}
|
||||
|
||||
{
|
||||
const query = `
|
||||
CREATE TABLE IF NOT EXISTS "videoPlaylistElement"
|
||||
(
|
||||
"id" SERIAL,
|
||||
"url" VARCHAR(2000) NOT NULL,
|
||||
"position" INTEGER NOT NULL DEFAULT 1,
|
||||
"startTimestamp" INTEGER,
|
||||
"stopTimestamp" INTEGER,
|
||||
"videoPlaylistId" INTEGER NOT NULL REFERENCES "videoPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
"videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);`
|
||||
|
||||
await utils.sequelize.query(query, { transaction })
|
||||
}
|
||||
|
||||
{
|
||||
const userQuery = 'SELECT "username" FROM "user";'
|
||||
|
||||
const options = { transaction, type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT }
|
||||
const userResult = await utils.sequelize.query<{ username: string }>(userQuery, options)
|
||||
const usernames = userResult.map(r => r.username)
|
||||
|
||||
for (const username of usernames) {
|
||||
const uuid = buildUUID()
|
||||
|
||||
const baseUrl = WEBSERVER.URL + '/video-playlists/' + uuid
|
||||
const query = `
|
||||
INSERT INTO "videoPlaylist" ("url", "uuid", "name", "privacy", "type", "ownerAccountId", "createdAt", "updatedAt")
|
||||
SELECT '${baseUrl}' AS "url",
|
||||
'${uuid}' AS "uuid",
|
||||
'Watch later' AS "name",
|
||||
${VideoPlaylistPrivacy.PRIVATE} AS "privacy",
|
||||
${VideoPlaylistType.WATCH_LATER} AS "type",
|
||||
"account"."id" AS "ownerAccountId",
|
||||
NOW() as "createdAt",
|
||||
NOW() as "updatedAt"
|
||||
FROM "user" INNER JOIN "account" ON "user"."id" = "account"."userId"
|
||||
WHERE "user"."username" = '${username}'`
|
||||
|
||||
await utils.sequelize.query(query, { transaction })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import { VideoBlacklistType } from '../../../shared/models/videos'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('videoBlacklist', 'type', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "videoBlacklist" SET "type" = ' + VideoBlacklistType.MANUAL
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('videoBlacklist', 'type', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: null,
|
||||
allowNull: true
|
||||
}
|
||||
await utils.queryInterface.addColumn('userNotificationSetting', 'videoAutoBlacklistAsModerator', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "userNotificationSetting" SET "videoAutoBlacklistAsModerator" = 3'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: null,
|
||||
allowNull: false
|
||||
}
|
||||
await utils.queryInterface.changeColumn('userNotificationSetting', 'videoAutoBlacklistAsModerator', data)
|
||||
}
|
||||
}
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('videoStreamingPlaylist', 'p2pMediaLoaderPeerVersion', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = `UPDATE "videoStreamingPlaylist" SET "p2pMediaLoaderPeerVersion" = 0;`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.changeColumn('videoStreamingPlaylist', 'p2pMediaLoaderPeerVersion', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: null,
|
||||
allowNull: true
|
||||
}
|
||||
await utils.queryInterface.addColumn('userNotificationSetting', 'newInstanceFollower', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "userNotificationSetting" SET "newInstanceFollower" = 1'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: null,
|
||||
allowNull: false
|
||||
}
|
||||
await utils.queryInterface.changeColumn('userNotificationSetting', 'newInstanceFollower', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: null,
|
||||
allowNull: true
|
||||
}
|
||||
await utils.queryInterface.addColumn('user', 'adminFlags', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "user" SET "adminFlags" = 0'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: null,
|
||||
allowNull: false
|
||||
}
|
||||
await utils.queryInterface.changeColumn('user', 'adminFlags', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const query = `
|
||||
CREATE TABLE IF NOT EXISTS "thumbnail"
|
||||
(
|
||||
"id" SERIAL,
|
||||
"filename" VARCHAR(255) NOT NULL,
|
||||
"height" INTEGER DEFAULT NULL,
|
||||
"width" INTEGER DEFAULT NULL,
|
||||
"type" INTEGER NOT NULL,
|
||||
"fileUrl" VARCHAR(255),
|
||||
"videoId" INTEGER REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
"videoPlaylistId" INTEGER REFERENCES "videoPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
// All video thumbnails
|
||||
const query = 'INSERT INTO "thumbnail" ("filename", "type", "videoId", "height", "width", "createdAt", "updatedAt")' +
|
||||
'SELECT uuid || \'.jpg\', 1, id, 110, 200, NOW(), NOW() FROM "video"'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
// All video previews
|
||||
const query = 'INSERT INTO "thumbnail" ("filename", "type", "videoId", "height", "width", "createdAt", "updatedAt")' +
|
||||
'SELECT uuid || \'.jpg\', 2, id, 315, 560, NOW(), NOW() FROM "video"'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const data = {
|
||||
type: Sequelize.STRING(1000),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('account', 'description', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
try {
|
||||
await utils.queryInterface.removeColumn('application', 'createdAt')
|
||||
} catch { /* the column could not exist */ }
|
||||
|
||||
try {
|
||||
await utils.queryInterface.removeColumn('application', 'updatedAt')
|
||||
} catch { /* the column could not exist */ }
|
||||
|
||||
try {
|
||||
await utils.queryInterface.removeColumn('videoView', 'updatedAt')
|
||||
} catch { /* the column could not exist */ }
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
await utils.queryInterface.removeColumn('actor', 'uuid')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const data = {
|
||||
type: Sequelize.STRING(400),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('user', 'pendingEmail', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const data = {
|
||||
type: Sequelize.ARRAY(Sequelize.STRING),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('user', 'videoLanguages', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const data = {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false,
|
||||
defaultValue: 'instance-default'
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('user', 'theme', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const query = `
|
||||
CREATE TABLE IF NOT EXISTS "plugin"
|
||||
(
|
||||
"id" SERIAL,
|
||||
"name" VARCHAR(255) NOT NULL,
|
||||
"type" INTEGER NOT NULL,
|
||||
"version" VARCHAR(255) NOT NULL,
|
||||
"latestVersion" VARCHAR(255),
|
||||
"enabled" BOOLEAN NOT NULL,
|
||||
"uninstalled" BOOLEAN NOT NULL,
|
||||
"peertubeEngine" VARCHAR(255) NOT NULL,
|
||||
"description" VARCHAR(255),
|
||||
"homepage" VARCHAR(255) NOT NULL,
|
||||
"settings" JSONB,
|
||||
"storage" JSONB,
|
||||
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);`
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
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', {
|
||||
fields: [ '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
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('thumbnail', 'automaticallyGenerated', data)
|
||||
}
|
||||
|
||||
{
|
||||
// Set auto generated to true for watch later playlists
|
||||
const query = 'UPDATE thumbnail SET "automaticallyGenerated" = true WHERE "videoPlaylistId" IN ' +
|
||||
'(SELECT id FROM "videoPlaylist" WHERE type = 2)'
|
||||
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
// We'll add a unique index on filename, so delete duplicates or PeerTube won't start
|
||||
const query = 'DELETE FROM "avatar" s1 ' +
|
||||
'USING (SELECT MIN(id) as id, filename FROM "avatar" GROUP BY "filename" HAVING COUNT(*) > 1) s2 ' +
|
||||
'WHERE s1."filename" = s2."filename" AND s1.id <> s2.id'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('avatar', 'fileUrl', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('avatar', 'onDisk', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "avatar" SET "onDisk" = true;'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('avatar', 'onDisk', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
const data = {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('actor', 'outboxUrl', data)
|
||||
await utils.queryInterface.changeColumn('actor', 'followersUrl', data)
|
||||
await utils.queryInterface.changeColumn('actor', 'followingUrl', data)
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: null,
|
||||
allowNull: true
|
||||
}
|
||||
await utils.queryInterface.addColumn('userNotificationSetting', 'autoInstanceFollowing', data)
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'UPDATE "userNotificationSetting" SET "autoInstanceFollowing" = 1'
|
||||
await utils.sequelize.query(query)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: null,
|
||||
allowNull: false
|
||||
}
|
||||
await utils.queryInterface.changeColumn('userNotificationSetting', 'autoInstanceFollowing', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('user', 'noInstanceConfigWarningModal', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('user', 'noWelcomeModal', data)
|
||||
data.defaultValue = false
|
||||
|
||||
await utils.queryInterface.changeColumn('user', 'noWelcomeModal', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('user', 'autoPlayNextVideo', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('actor', 'sharedInboxUrl', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: 'videoStreamingPlaylist',
|
||||
key: 'id'
|
||||
},
|
||||
onDelete: 'CASCADE'
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('videoFile', 'videoStreamingPlaylistId', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('videoFile', 'videoId', data)
|
||||
}
|
||||
|
||||
{
|
||||
await utils.queryInterface.removeIndex('videoFile', 'video_file_video_id_resolution_fps')
|
||||
}
|
||||
|
||||
{
|
||||
const query = 'insert into "videoFile" ' +
|
||||
'(resolution, size, "infoHash", "videoId", "createdAt", "updatedAt", fps, extname, "videoStreamingPlaylistId")' +
|
||||
'(SELECT "videoFile".resolution, "videoFile".size, \'fake\', NULL, "videoFile"."createdAt", "videoFile"."updatedAt", ' +
|
||||
'"videoFile"."fps", "videoFile".extname, "videoStreamingPlaylist".id FROM "videoStreamingPlaylist" ' +
|
||||
'inner join video ON video.id = "videoStreamingPlaylist"."videoId" inner join "videoFile" ON "videoFile"."videoId" = video.id)'
|
||||
|
||||
await utils.sequelize.query(query, { transaction: utils.transaction })
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('videoComment', 'accountId', data)
|
||||
}
|
||||
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
await utils.queryInterface.addColumn('videoComment', 'deletedAt', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('user', 'autoPlayNextVideoPlaylist', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING(2000),
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('thumbnail', 'fileUrl', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
await utils.sequelize.query('DROP INDEX IF EXISTS video_share_account_id;')
|
||||
await utils.sequelize.query('DROP INDEX IF EXISTS video_published_at;')
|
||||
|
||||
await utils.sequelize.query('ALTER TABLE "avatar" DROP COLUMN IF EXISTS "avatarId"')
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.changeColumn('videoRedundancy', 'expiresOn', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
db: any
|
||||
}): Promise<void> {
|
||||
{
|
||||
const data = {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true,
|
||||
defaultValue: null
|
||||
}
|
||||
|
||||
await utils.queryInterface.addColumn('videoCaption', 'fileUrl', data)
|
||||
}
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
const deletedVideo = {
|
||||
type: Sequelize.JSONB,
|
||||
allowNull: true
|
||||
}
|
||||
await utils.queryInterface.addColumn('videoAbuse', 'deletedVideo', deletedVideo)
|
||||
await utils.sequelize.query(`ALTER TABLE "videoAbuse" ALTER COLUMN "videoId" DROP NOT NULL;`)
|
||||
await utils.sequelize.query(`ALTER TABLE "videoAbuse" DROP CONSTRAINT IF EXISTS "videoAbuse_videoId_fkey";`)
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
const password = {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true
|
||||
}
|
||||
await utils.queryInterface.changeColumn('user', 'password', password)
|
||||
}
|
||||
|
||||
{
|
||||
const pluginAuth = {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true
|
||||
}
|
||||
await utils.queryInterface.addColumn('user', 'pluginAuth', pluginAuth)
|
||||
}
|
||||
|
||||
{
|
||||
const authName = {
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true
|
||||
}
|
||||
await utils.queryInterface.addColumn('oAuthToken', 'authName', authName)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
|
||||
async function up (utils: {
|
||||
transaction: Sequelize.Transaction
|
||||
queryInterface: Sequelize.QueryInterface
|
||||
sequelize: Sequelize.Sequelize
|
||||
}): Promise<void> {
|
||||
|
||||
{
|
||||
const description = {
|
||||
type: Sequelize.STRING(1000),
|
||||
allowNull: true
|
||||
}
|
||||
await utils.queryInterface.changeColumn('videoPlaylist', 'description', description)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function down (options) {
|
||||
throw new Error('Not implemented.')
|
||||
}
|
||||
|
||||
export {
|
||||
up,
|
||||
down
|
||||
}
|
Loading…
Reference in New Issue