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

55 lines
1.5 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. }): Promise<void> {
  7. await utils.sequelize.query(`
  8. CREATE TABLE IF NOT EXISTS "abuseMessage" (
  9. "id" serial,
  10. "message" text NOT NULL,
  11. "byModerator" boolean NOT NULL,
  12. "accountId" integer REFERENCES "account" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
  13. "abuseId" integer NOT NULL REFERENCES "abuse" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
  14. "createdAt" timestamp WITH time zone NOT NULL,
  15. "updatedAt" timestamp WITH time zone NOT NULL,
  16. PRIMARY KEY ("id")
  17. );
  18. `)
  19. const notificationSettingColumns = [ 'abuseStateChange', 'abuseNewMessage' ]
  20. for (const column of notificationSettingColumns) {
  21. const data = {
  22. type: Sequelize.INTEGER,
  23. defaultValue: null,
  24. allowNull: true
  25. }
  26. await utils.queryInterface.addColumn('userNotificationSetting', column, data)
  27. }
  28. {
  29. const query = 'UPDATE "userNotificationSetting" SET "abuseStateChange" = 3, "abuseNewMessage" = 3'
  30. await utils.sequelize.query(query)
  31. }
  32. for (const column of notificationSettingColumns) {
  33. const data = {
  34. type: Sequelize.INTEGER,
  35. defaultValue: null,
  36. allowNull: false
  37. }
  38. await utils.queryInterface.changeColumn('userNotificationSetting', column, data)
  39. }
  40. }
  41. function down (options) {
  42. throw new Error('Not implemented.')
  43. }
  44. export {
  45. up,
  46. down
  47. }