aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-26 14:08:35 +0200
committerChocobozzz <me@florianbigard.com>2018-09-26 14:08:35 +0200
commit2e7cf5ae0cf8fbc9526742b67a0079d42211644c (patch)
tree5a7ad1a7c7033f3b6f894be8cfecb2af8f337da4 /server/initializers/migrations
parent60e74f80d87cdb366a70a48e4316bb0dff4cab16 (diff)
downloadPeerTube-2e7cf5ae0cf8fbc9526742b67a0079d42211644c.tar.gz
PeerTube-2e7cf5ae0cf8fbc9526742b67a0079d42211644c.tar.zst
PeerTube-2e7cf5ae0cf8fbc9526742b67a0079d42211644c.zip
Fix video files duplicated when fps is null
Null values are not considered equal in a UNIQUE index
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r--server/initializers/migrations/0260-upload-quota-daily.ts (renamed from server/initializers/migrations/0260-upload_quota_daily.ts)0
-rw-r--r--server/initializers/migrations/0275-video-file-unique.ts34
2 files changed, 34 insertions, 0 deletions
diff --git a/server/initializers/migrations/0260-upload_quota_daily.ts b/server/initializers/migrations/0260-upload-quota-daily.ts
index d25154ba6..d25154ba6 100644
--- a/server/initializers/migrations/0260-upload_quota_daily.ts
+++ b/server/initializers/migrations/0260-upload-quota-daily.ts
diff --git a/server/initializers/migrations/0275-video-file-unique.ts b/server/initializers/migrations/0275-video-file-unique.ts
new file mode 100644
index 000000000..fd89188c0
--- /dev/null
+++ b/server/initializers/migrations/0275-video-file-unique.ts
@@ -0,0 +1,34 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
7}): Promise<any> {
8 {
9 const query = 'DELETE FROM "videoFile" vf1 USING "videoFile" vf2 WHERE vf1.id < vf2.id ' +
10 'AND vf1."videoId" = vf2."videoId" AND vf1.resolution = vf2.resolution AND vf1.fps IS NULL'
11 await utils.sequelize.query(query)
12 }
13
14 {
15 const query = 'UPDATE "videoFile" SET fps = -1 WHERE fps IS NULL;'
16 await utils.sequelize.query(query)
17 }
18
19 {
20 const data = {
21 type: Sequelize.INTEGER,
22 allowNull: false,
23 defaultValue: -1
24 }
25 await utils.queryInterface.changeColumn('videoFile', 'fps', data)
26 }
27
28}
29
30function down (options) {
31 throw new Error('Not implemented.')
32}
33
34export { up, down }