0660-object-storage.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import * as Sequelize from 'sequelize'
  2. import { FileStorage } from '@peertube/peertube-models'
  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. const query = `
  11. CREATE TABLE IF NOT EXISTS "videoJobInfo" (
  12. "id" serial,
  13. "pendingMove" INTEGER NOT NULL,
  14. "pendingTranscode" INTEGER NOT NULL,
  15. "videoId" serial UNIQUE NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
  16. "createdAt" timestamp WITH time zone NOT NULL,
  17. "updatedAt" timestamp WITH time zone NOT NULL,
  18. PRIMARY KEY ("id")
  19. );
  20. `
  21. await utils.sequelize.query(query)
  22. }
  23. {
  24. await utils.queryInterface.addColumn('videoFile', 'storage', {
  25. type: Sequelize.INTEGER,
  26. allowNull: true,
  27. defaultValue: FileStorage.FILE_SYSTEM
  28. })
  29. await utils.queryInterface.changeColumn('videoFile', 'storage', { type: Sequelize.INTEGER, allowNull: false, defaultValue: null })
  30. }
  31. {
  32. await utils.queryInterface.addColumn('videoStreamingPlaylist', 'storage', {
  33. type: Sequelize.INTEGER,
  34. allowNull: true,
  35. defaultValue: FileStorage.FILE_SYSTEM
  36. })
  37. await utils.queryInterface.changeColumn('videoStreamingPlaylist', 'storage', {
  38. type: Sequelize.INTEGER,
  39. allowNull: false,
  40. defaultValue: null
  41. })
  42. }
  43. }
  44. function down (options) {
  45. throw new Error('Not implemented.')
  46. }
  47. export {
  48. up,
  49. down
  50. }