]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix old DB enum names
authorChocobozzz <me@florianbigard.com>
Tue, 13 Sep 2022 13:22:02 +0000 (15:22 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 13 Sep 2022 13:22:02 +0000 (15:22 +0200)
server/initializers/constants.ts
server/initializers/migrations/0740-fix-old-enums.ts [new file with mode: 0644]

index f7d9a41da52a4ff6be18bb06024ed8f31c2aab58..7039ab457ceebb0ec61648d9158dd8642f0cefce 100644 (file)
@@ -25,7 +25,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
 
 // ---------------------------------------------------------------------------
 
-const LAST_MIGRATION_VERSION = 735
+const LAST_MIGRATION_VERSION = 740
 
 // ---------------------------------------------------------------------------
 
diff --git a/server/initializers/migrations/0740-fix-old-enums.ts b/server/initializers/migrations/0740-fix-old-enums.ts
new file mode 100644 (file)
index 0000000..501d0cc
--- /dev/null
@@ -0,0 +1,33 @@
+import * as Sequelize from 'sequelize'
+
+async function up (utils: {
+  transaction: Sequelize.Transaction
+  queryInterface: Sequelize.QueryInterface
+  sequelize: Sequelize.Sequelize
+  db: any
+}): Promise<void> {
+  try {
+    await utils.sequelize.query('drop type "enum_actorFollow_state"')
+    await utils.sequelize.query('alter type "enum_AccountFollows_state" rename to "enum_actorFollow_state";')
+  } catch {
+    // empty
+  }
+
+  try {
+    await utils.sequelize.query('drop type "enum_accountVideoRate_type"')
+    await utils.sequelize.query('alter type "enum_AccountVideoRates_type" rename to "enum_accountVideoRate_type";')
+  } catch {
+    // empty
+  }
+}
+
+async function down (utils: {
+  queryInterface: Sequelize.QueryInterface
+  transaction: Sequelize.Transaction
+}) {
+}
+
+export {
+  up,
+  down
+}