aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0060-video-file.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-08-25 11:36:23 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-08-25 11:36:23 +0200
commit93e1258c7cbc0d1235ca6d2a1f7c1875985328b8 (patch)
treeb0a1f77af7ab54dc5f58f569fcd1e9d84b04c533 /server/initializers/migrations/0060-video-file.ts
parent69f224587e99d56008e1fa129d0641840a486620 (diff)
downloadPeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.tar.gz
PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.tar.zst
PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.zip
Move video file metadata in their own table
Will be used for user video quotas and multiple video resolutions
Diffstat (limited to 'server/initializers/migrations/0060-video-file.ts')
-rw-r--r--server/initializers/migrations/0060-video-file.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/server/initializers/migrations/0060-video-file.ts b/server/initializers/migrations/0060-video-file.ts
new file mode 100644
index 000000000..c362cf71a
--- /dev/null
+++ b/server/initializers/migrations/0060-video-file.ts
@@ -0,0 +1,34 @@
1import * as Sequelize from 'sequelize'
2import * as Promise from 'bluebird'
3
4function up (utils: {
5 transaction: Sequelize.Transaction,
6 queryInterface: Sequelize.QueryInterface,
7 sequelize: Sequelize.Sequelize,
8 db: any
9}): Promise<void> {
10 const q = utils.queryInterface
11
12 const query = 'INSERT INTO "VideoFiles" ("videoId", "resolution", "size", "extname", "infoHash", "createdAt", "updatedAt") ' +
13 'SELECT "id" AS "videoId", 0 AS "resolution", 0 AS "size", ' +
14 '"extname"::"text"::"enum_VideoFiles_extname" as "extname", "infoHash", "createdAt", "updatedAt" ' +
15 'FROM "Videos"'
16
17 return utils.db.VideoFile.sync()
18 .then(() => utils.sequelize.query(query))
19 .then(() => {
20 return q.removeColumn('Videos', 'extname')
21 })
22 .then(() => {
23 return q.removeColumn('Videos', 'infoHash')
24 })
25}
26
27function down (options) {
28 throw new Error('Not implemented.')
29}
30
31export {
32 up,
33 down
34}