From 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 12 Dec 2017 17:53:50 +0100 Subject: Move models to typescript-sequelize --- server/initializers/migrations/0065-video-file-size.ts | 5 ++--- server/initializers/migrations/0100-activitypub.ts | 6 +++--- server/initializers/migrations/0105-server-mail.ts | 3 +-- server/initializers/migrations/0110-server-key.ts | 3 +-- server/initializers/migrations/0115-account-avatar.ts | 3 +-- server/initializers/migrations/0120-video-null.ts | 3 +-- 6 files changed, 9 insertions(+), 14 deletions(-) (limited to 'server/initializers/migrations') diff --git a/server/initializers/migrations/0065-video-file-size.ts b/server/initializers/migrations/0065-video-file-size.ts index 58f8f3bcc..4e2075f8b 100644 --- a/server/initializers/migrations/0065-video-file-size.ts +++ b/server/initializers/migrations/0065-video-file-size.ts @@ -1,8 +1,7 @@ import * as Sequelize from 'sequelize' import * as Promise from 'bluebird' import { stat } from 'fs' - -import { VideoInstance } from '../../models' +import { VideoModel } from '../../models/video/video' function up (utils: { transaction: Sequelize.Transaction, @@ -11,7 +10,7 @@ function up (utils: { db: any }): Promise { return utils.db.Video.listOwnedAndPopulateAuthorAndTags() - .then((videos: VideoInstance[]) => { + .then((videos: VideoModel[]) => { const tasks: Promise[] = [] videos.forEach(video => { diff --git a/server/initializers/migrations/0100-activitypub.ts b/server/initializers/migrations/0100-activitypub.ts index 50a0adc14..fb42e1d57 100644 --- a/server/initializers/migrations/0100-activitypub.ts +++ b/server/initializers/migrations/0100-activitypub.ts @@ -4,14 +4,14 @@ import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' import { shareVideoByServer } from '../../lib/activitypub/share' import { getVideoActivityPubUrl, getVideoChannelActivityPubUrl } from '../../lib/activitypub/url' import { createLocalAccountWithoutKeys } from '../../lib/user' +import { ApplicationModel } from '../../models/application/application' import { JOB_CATEGORIES, SERVER_ACCOUNT_NAME } from '../constants' -import { PeerTubeDatabase } from '../database' async function up (utils: { transaction: Sequelize.Transaction, queryInterface: Sequelize.QueryInterface, sequelize: Sequelize.Sequelize, - db: PeerTubeDatabase + db: any }): Promise { const q = utils.queryInterface const db = utils.db @@ -65,7 +65,7 @@ async function up (utils: { // Create application account { - const applicationInstance = await db.Application.findOne() + const applicationInstance = await ApplicationModel.findOne() const accountCreated = await createLocalAccountWithoutKeys(SERVER_ACCOUNT_NAME, null, applicationInstance.id, undefined) const { publicKey, privateKey } = await createPrivateAndPublicKeys() diff --git a/server/initializers/migrations/0105-server-mail.ts b/server/initializers/migrations/0105-server-mail.ts index 5836992d5..4b9600e91 100644 --- a/server/initializers/migrations/0105-server-mail.ts +++ b/server/initializers/migrations/0105-server-mail.ts @@ -1,11 +1,10 @@ import * as Sequelize from 'sequelize' -import { PeerTubeDatabase } from '../database' async function up (utils: { transaction: Sequelize.Transaction, queryInterface: Sequelize.QueryInterface, sequelize: Sequelize.Sequelize, - db: PeerTubeDatabase + db: any }): Promise { await utils.queryInterface.removeColumn('Servers', 'email') } diff --git a/server/initializers/migrations/0110-server-key.ts b/server/initializers/migrations/0110-server-key.ts index 560353945..5ff6daf69 100644 --- a/server/initializers/migrations/0110-server-key.ts +++ b/server/initializers/migrations/0110-server-key.ts @@ -1,11 +1,10 @@ import * as Sequelize from 'sequelize' -import { PeerTubeDatabase } from '../database' async function up (utils: { transaction: Sequelize.Transaction, queryInterface: Sequelize.QueryInterface, sequelize: Sequelize.Sequelize, - db: PeerTubeDatabase + db: any }): Promise { await utils.queryInterface.removeColumn('Servers', 'publicKey') } diff --git a/server/initializers/migrations/0115-account-avatar.ts b/server/initializers/migrations/0115-account-avatar.ts index 2b947ceda..b318e8163 100644 --- a/server/initializers/migrations/0115-account-avatar.ts +++ b/server/initializers/migrations/0115-account-avatar.ts @@ -1,11 +1,10 @@ import * as Sequelize from 'sequelize' -import { PeerTubeDatabase } from '../database' async function up (utils: { transaction: Sequelize.Transaction, queryInterface: Sequelize.QueryInterface, sequelize: Sequelize.Sequelize, - db: PeerTubeDatabase + db: any }): Promise { await utils.db.Avatar.sync() diff --git a/server/initializers/migrations/0120-video-null.ts b/server/initializers/migrations/0120-video-null.ts index 9130d10ee..63f3984dd 100644 --- a/server/initializers/migrations/0120-video-null.ts +++ b/server/initializers/migrations/0120-video-null.ts @@ -1,12 +1,11 @@ import * as Sequelize from 'sequelize' import { CONSTRAINTS_FIELDS } from '../constants' -import { PeerTubeDatabase } from '../database' async function up (utils: { transaction: Sequelize.Transaction, queryInterface: Sequelize.QueryInterface, sequelize: Sequelize.Sequelize, - db: PeerTubeDatabase + db: any }): Promise { { -- cgit v1.2.3