0210-video-language.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import * as Sequelize from 'sequelize'
  2. import { CONSTRAINTS_FIELDS } from '../constants'
  3. async function up (utils: {
  4. transaction: Sequelize.Transaction,
  5. queryInterface: Sequelize.QueryInterface,
  6. sequelize: Sequelize.Sequelize
  7. }): Promise<void> {
  8. {
  9. await utils.queryInterface.renameColumn('video', 'language', 'oldLanguage')
  10. }
  11. {
  12. const data = {
  13. type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.LANGUAGE.max),
  14. allowNull: true,
  15. defaultValue: null
  16. }
  17. await utils.queryInterface.addColumn('video', 'language', data)
  18. }
  19. {
  20. const languages = [
  21. {
  22. oldLanguage: 1,
  23. newLanguage: 'en'
  24. },
  25. {
  26. oldLanguage: 2,
  27. newLanguage: 'es'
  28. },
  29. {
  30. oldLanguage: 3,
  31. newLanguage: 'zh'
  32. },
  33. {
  34. oldLanguage: 4,
  35. newLanguage: 'hi'
  36. },
  37. {
  38. oldLanguage: 5,
  39. newLanguage: 'ar'
  40. },
  41. {
  42. oldLanguage: 6,
  43. newLanguage: 'pt'
  44. },
  45. {
  46. oldLanguage: 7,
  47. newLanguage: 'bn'
  48. },
  49. {
  50. oldLanguage: 8,
  51. newLanguage: 'ru'
  52. },
  53. {
  54. oldLanguage: 9,
  55. newLanguage: 'ja'
  56. },
  57. {
  58. oldLanguage: 10,
  59. newLanguage: 'pa'
  60. },
  61. {
  62. oldLanguage: 11,
  63. newLanguage: 'de'
  64. },
  65. {
  66. oldLanguage: 12,
  67. newLanguage: 'ko'
  68. },
  69. {
  70. oldLanguage: 13,
  71. newLanguage: 'fr'
  72. },
  73. {
  74. oldLanguage: 14,
  75. newLanguage: 'it'
  76. },
  77. {
  78. oldLanguage: 1000,
  79. newLanguage: 'sgn'
  80. },
  81. {
  82. oldLanguage: 1001,
  83. newLanguage: 'ase'
  84. },
  85. {
  86. oldLanguage: 1002,
  87. newLanguage: 'sdl'
  88. },
  89. {
  90. oldLanguage: 1003,
  91. newLanguage: 'bfi'
  92. },
  93. {
  94. oldLanguage: 1004,
  95. newLanguage: 'bzs'
  96. },
  97. {
  98. oldLanguage: 1005,
  99. newLanguage: 'csl'
  100. },
  101. {
  102. oldLanguage: 1006,
  103. newLanguage: 'cse'
  104. },
  105. {
  106. oldLanguage: 1007,
  107. newLanguage: 'dsl'
  108. },
  109. {
  110. oldLanguage: 1008,
  111. newLanguage: 'fsl'
  112. },
  113. {
  114. oldLanguage: 1009,
  115. newLanguage: 'gsg'
  116. },
  117. {
  118. oldLanguage: 1010,
  119. newLanguage: 'pks'
  120. },
  121. {
  122. oldLanguage: 1011,
  123. newLanguage: 'jsl'
  124. },
  125. {
  126. oldLanguage: 1012,
  127. newLanguage: 'sfs'
  128. },
  129. {
  130. oldLanguage: 1013,
  131. newLanguage: 'swl'
  132. },
  133. {
  134. oldLanguage: 1014,
  135. newLanguage: 'rsl'
  136. }
  137. ]
  138. for (const language of languages) {
  139. const query = 'UPDATE "video" SET "language" = \'' + language.newLanguage + '\' WHERE "oldLanguage" = ' + language.oldLanguage
  140. await utils.sequelize.query(query)
  141. }
  142. }
  143. {
  144. await utils.queryInterface.removeColumn('video', 'oldLanguage')
  145. }
  146. }
  147. function down (options) {
  148. throw new Error('Not implemented.')
  149. }
  150. export {
  151. up,
  152. down
  153. }