diff options
Diffstat (limited to 'server/initializers/migrations/0085-user-role.ts')
-rw-r--r-- | server/initializers/migrations/0085-user-role.ts | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/server/initializers/migrations/0085-user-role.ts b/server/initializers/migrations/0085-user-role.ts deleted file mode 100644 index ec7428fd5..000000000 --- a/server/initializers/migrations/0085-user-role.ts +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
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 | const q = utils.queryInterface | ||
10 | |||
11 | await q.renameColumn('Users', 'role', 'oldRole') | ||
12 | |||
13 | const data = { | ||
14 | type: Sequelize.INTEGER, | ||
15 | allowNull: true | ||
16 | } | ||
17 | await q.addColumn('Users', 'role', data) | ||
18 | |||
19 | let query = 'UPDATE "Users" SET "role" = 0 WHERE "oldRole" = \'admin\'' | ||
20 | await utils.sequelize.query(query) | ||
21 | |||
22 | query = 'UPDATE "Users" SET "role" = 2 WHERE "oldRole" = \'user\'' | ||
23 | await utils.sequelize.query(query) | ||
24 | |||
25 | data.allowNull = false | ||
26 | await q.changeColumn('Users', 'role', data) | ||
27 | |||
28 | await q.removeColumn('Users', 'oldRole') | ||
29 | } | ||
30 | |||
31 | function down (options) { | ||
32 | throw new Error('Not implemented.') | ||
33 | } | ||
34 | |||
35 | export { | ||
36 | up, | ||
37 | down | ||
38 | } | ||