diff options
author | Chocobozzz <me@florianbigard.com> | 2021-04-07 10:46:50 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-04-08 10:07:53 +0200 |
commit | 282695e699a35b65441b548061ef0db5de9b3971 (patch) | |
tree | 3966a86fb0453fc4a039be2313e18fefff9ffad2 /server/initializers/migrations | |
parent | 213e30ef90806369529684ac9c247d73b8dc7928 (diff) | |
download | PeerTube-282695e699a35b65441b548061ef0db5de9b3971.tar.gz PeerTube-282695e699a35b65441b548061ef0db5de9b3971.tar.zst PeerTube-282695e699a35b65441b548061ef0db5de9b3971.zip |
Add banner migrations
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r-- | server/initializers/migrations/0630-banner.ts | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/server/initializers/migrations/0630-banner.ts b/server/initializers/migrations/0630-banner.ts new file mode 100644 index 000000000..5766bb171 --- /dev/null +++ b/server/initializers/migrations/0630-banner.ts | |||
@@ -0,0 +1,50 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | db: any | ||
8 | }): Promise<void> { | ||
9 | |||
10 | { | ||
11 | await utils.sequelize.query(`ALTER TABLE "avatar" RENAME to "actorImage"`) | ||
12 | } | ||
13 | |||
14 | { | ||
15 | const data = { | ||
16 | type: Sequelize.INTEGER, | ||
17 | defaultValue: null, | ||
18 | allowNull: true | ||
19 | } | ||
20 | await utils.queryInterface.addColumn('actorImage', 'type', data) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | await utils.sequelize.query(`UPDATE "actorImage" SET "type" = 1`) | ||
25 | } | ||
26 | |||
27 | { | ||
28 | const data = { | ||
29 | type: Sequelize.INTEGER, | ||
30 | defaultValue: null, | ||
31 | allowNull: false | ||
32 | } | ||
33 | await utils.queryInterface.changeColumn('actorImage', 'type', data) | ||
34 | } | ||
35 | |||
36 | { | ||
37 | await utils.sequelize.query( | ||
38 | `ALTER TABLE "actor" ADD COLUMN "bannerId" INTEGER REFERENCES "actorImage" ("id") ON DELETE SET NULL ON UPDATE CASCADE` | ||
39 | ) | ||
40 | } | ||
41 | } | ||
42 | |||
43 | function down (options) { | ||
44 | throw new Error('Not implemented.') | ||
45 | } | ||
46 | |||
47 | export { | ||
48 | up, | ||
49 | down | ||
50 | } | ||