ニジカ投稿局 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.

0705-local-video-viewers.ts 1.3 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 { transaction } = utils
  9. {
  10. const query = `
  11. CREATE TABLE IF NOT EXISTS "localVideoViewer" (
  12. "id" serial,
  13. "startDate" timestamp with time zone NOT NULL,
  14. "endDate" timestamp with time zone NOT NULL,
  15. "watchTime" integer NOT NULL,
  16. "country" varchar(255),
  17. "uuid" uuid NOT NULL,
  18. "url" varchar(255) NOT NULL,
  19. "videoId" integer NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
  20. "createdAt" timestamp with time zone NOT NULL,
  21. PRIMARY KEY ("id")
  22. );
  23. `
  24. await utils.sequelize.query(query, { transaction })
  25. }
  26. {
  27. const query = `
  28. CREATE TABLE IF NOT EXISTS "localVideoViewerWatchSection" (
  29. "id" serial,
  30. "watchStart" integer NOT NULL,
  31. "watchEnd" integer NOT NULL,
  32. "localVideoViewerId" integer NOT NULL REFERENCES "localVideoViewer" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
  33. "createdAt" timestamp with time zone NOT NULL,
  34. PRIMARY KEY ("id")
  35. );
  36. `
  37. await utils.sequelize.query(query, { transaction })
  38. }
  39. }
  40. function down () {
  41. throw new Error('Not implemented.')
  42. }
  43. export {
  44. up,
  45. down
  46. }