Cleanup DB indexes
authorChocobozzz <me@florianbigard.com>
Fri, 10 Jan 2020 09:41:05 +0000 (10:41 +0100)
committerChocobozzz <me@florianbigard.com>
Fri, 10 Jan 2020 12:33:22 +0000 (13:33 +0100)
server/initializers/constants.ts
server/initializers/migrations/0470-cleaup-indexes.ts [new file with mode: 0644]

index 8461c732004e790f0e50fce3019fa559b95ec449..d4ac8bbbe2599190760173bc8c22d037e0329d63 100644 (file)
@@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 465
+const LAST_MIGRATION_VERSION = 470
 
 // ---------------------------------------------------------------------------
 
diff --git a/server/initializers/migrations/0470-cleaup-indexes.ts b/server/initializers/migrations/0470-cleaup-indexes.ts
new file mode 100644 (file)
index 0000000..53e401c
--- /dev/null
@@ -0,0 +1,22 @@
+import * as Sequelize from 'sequelize'
+
+async function up (utils: {
+  transaction: Sequelize.Transaction,
+  queryInterface: Sequelize.QueryInterface,
+  sequelize: Sequelize.Sequelize,
+  db: any
+}): Promise<void> {
+  await utils.sequelize.query('DROP INDEX IF EXISTS video_share_account_id;')
+  await utils.sequelize.query('DROP INDEX IF EXISTS video_published_at;')
+
+  await utils.sequelize.query('ALTER TABLE "avatar" DROP COLUMN IF EXISTS "avatarId"')
+}
+
+function down (options) {
+  throw new Error('Not implemented.')
+}
+
+export {
+  up,
+  down
+}