aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0490-abuse-video.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-04-16 14:22:27 +0200
committerRigel Kent <par@rigelk.eu>2020-05-01 16:41:02 +0200
commit68d19a0ace01cb7a3550da420d27663e2db1b98d (patch)
treefcdac5341001b9e6d15ddd0ca8239372ec2b3053 /server/initializers/migrations/0490-abuse-video.ts
parent165ee2929bc76fc7f9985ae81cc33736820c7865 (diff)
downloadPeerTube-68d19a0ace01cb7a3550da420d27663e2db1b98d.tar.gz
PeerTube-68d19a0ace01cb7a3550da420d27663e2db1b98d.tar.zst
PeerTube-68d19a0ace01cb7a3550da420d27663e2db1b98d.zip
Make sure a report doesn't get deleted upon the deletion of its video
Diffstat (limited to 'server/initializers/migrations/0490-abuse-video.ts')
-rw-r--r--server/initializers/migrations/0490-abuse-video.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/server/initializers/migrations/0490-abuse-video.ts b/server/initializers/migrations/0490-abuse-video.ts
new file mode 100644
index 000000000..26333feb5
--- /dev/null
+++ b/server/initializers/migrations/0490-abuse-video.ts
@@ -0,0 +1,28 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
7}): Promise<void> {
8
9 const deletedVideo = {
10 type: Sequelize.JSONB,
11 allowNull: true
12 }
13 await utils.queryInterface.addColumn('videoAbuse', 'deletedVideo', deletedVideo)
14 await utils.sequelize.query(`ALTER TABLE "videoAbsue" ALTER COLUMN "videoId" DROP NOT NULL;`)
15 await utils.sequelize.query(`ALTER TABLE "videoAbuse" DROP CONSTRAINT IF EXISTS "videoAbuse_videoId_fkey";`)
16 await utils.sequelize.query(`ALTER TABLE "videoAbuse" ADD CONSTRAINT "videoAbuse_videoId_fkey"
17 FOREIGN KEY ("videoId") REFERENCES video(id) ON UPDATE CASCADE ON DELETE SET NULL;`)
18
19}
20
21function down (options) {
22 throw new Error('Not implemented.')
23}
24
25export {
26 up,
27 down
28}