ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0730-video-channel-sync.ts 1.0 KiB

123456789101112131415161718192021222324252627282930313233343536
  1. import * as Sequelize from 'sequelize'
  2. async function up (utils: {
  3. transaction: Sequelize.Transaction
  4. queryInterface: Sequelize.QueryInterface
  5. sequelize: Sequelize.Sequelize
  6. db: any
  7. }): Promise<void> {
  8. const query = `
  9. CREATE TABLE IF NOT EXISTS "videoChannelSync" (
  10. "id" SERIAL,
  11. "externalChannelUrl" VARCHAR(2000) NOT NULL DEFAULT NULL,
  12. "videoChannelId" INTEGER NOT NULL REFERENCES "videoChannel" ("id")
  13. ON DELETE CASCADE
  14. ON UPDATE CASCADE,
  15. "state" INTEGER NOT NULL DEFAULT 1,
  16. "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
  17. "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
  18. "lastSyncAt" TIMESTAMP WITH TIME ZONE,
  19. PRIMARY KEY ("id")
  20. );
  21. `
  22. await utils.sequelize.query(query, { transaction: utils.transaction })
  23. }
  24. async function down (utils: {
  25. queryInterface: Sequelize.QueryInterface
  26. transaction: Sequelize.Transaction
  27. }) {
  28. await utils.queryInterface.dropTable('videoChannelSync', { transaction: utils.transaction })
  29. }
  30. export {
  31. up,
  32. down
  33. }