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

45 lines
1.2 KiB

  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. {
  9. const query = `CREATE TABLE IF NOT EXISTS "tracker" (
  10. "id" serial,
  11. "url" varchar(255) NOT NULL,
  12. "createdAt" timestamp WITH time zone NOT NULL,
  13. "updatedAt" timestamp WITH time zone NOT NULL,
  14. PRIMARY KEY ("id")
  15. );`
  16. await utils.sequelize.query(query)
  17. }
  18. {
  19. const query = `CREATE TABLE IF NOT EXISTS "videoTracker" (
  20. "videoId" integer REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
  21. "trackerId" integer REFERENCES "tracker" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
  22. "createdAt" timestamp WITH time zone NOT NULL,
  23. "updatedAt" timestamp WITH time zone NOT NULL,
  24. UNIQUE ("videoId", "trackerId"),
  25. PRIMARY KEY ("videoId", "trackerId")
  26. );`
  27. await utils.sequelize.query(query)
  28. }
  29. await utils.sequelize.query(`CREATE UNIQUE INDEX "tracker_url" ON "tracker" ("url")`)
  30. }
  31. function down (options) {
  32. throw new Error('Not implemented.')
  33. }
  34. export {
  35. up,
  36. down
  37. }