mirror of
https://github.com/Troplo/Colubrina.git
synced 2024-11-23 11:46:44 +11:00
231 lines
4.9 KiB
JavaScript
231 lines
4.9 KiB
JavaScript
|
"use strict"
|
||
|
|
||
|
module.exports = {
|
||
|
up: async (queryInterface, Sequelize) => {
|
||
|
await queryInterface.createTable("Chats", {
|
||
|
id: {
|
||
|
allowNull: false,
|
||
|
autoIncrement: true,
|
||
|
primaryKey: true,
|
||
|
type: Sequelize.BIGINT
|
||
|
},
|
||
|
type: {
|
||
|
type: Sequelize.ENUM(["direct", "group", "channel"])
|
||
|
},
|
||
|
privacy: {
|
||
|
type: Sequelize.ENUM([
|
||
|
"direct",
|
||
|
"everyoneInvited",
|
||
|
"tenantInvited",
|
||
|
"manualInvited"
|
||
|
])
|
||
|
},
|
||
|
name: {
|
||
|
type: Sequelize.STRING,
|
||
|
defaultValue: "Unnamed Group",
|
||
|
allowNull: false
|
||
|
},
|
||
|
userId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
usersId: {
|
||
|
type: Sequelize.JSON,
|
||
|
defaultValue: [],
|
||
|
allowNull: false
|
||
|
},
|
||
|
icon: {
|
||
|
type: Sequelize.STRING,
|
||
|
defaultValue: null
|
||
|
},
|
||
|
privilegedUserIds: {
|
||
|
type: Sequelize.JSON,
|
||
|
defaultValue: [],
|
||
|
allowNull: false
|
||
|
},
|
||
|
createdAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
},
|
||
|
updatedAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
}
|
||
|
})
|
||
|
await queryInterface.createTable("Messages", {
|
||
|
id: {
|
||
|
allowNull: false,
|
||
|
autoIncrement: true,
|
||
|
primaryKey: true,
|
||
|
type: Sequelize.BIGINT
|
||
|
},
|
||
|
chatId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
userId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
content: {
|
||
|
type: Sequelize.TEXT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
type: {
|
||
|
type: Sequelize.ENUM([
|
||
|
"message",
|
||
|
"leave",
|
||
|
"join",
|
||
|
"pin",
|
||
|
"administrator",
|
||
|
"rename",
|
||
|
"system"
|
||
|
])
|
||
|
},
|
||
|
embeds: {
|
||
|
type: Sequelize.JSON,
|
||
|
defaultValue: [],
|
||
|
allowNull: false
|
||
|
},
|
||
|
attachments: {
|
||
|
type: Sequelize.JSON,
|
||
|
defaultValue: [],
|
||
|
allowNull: false
|
||
|
},
|
||
|
createdAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
},
|
||
|
updatedAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
}
|
||
|
})
|
||
|
await queryInterface.createTable("Invites", {
|
||
|
id: {
|
||
|
allowNull: false,
|
||
|
autoIncrement: true,
|
||
|
primaryKey: true,
|
||
|
type: Sequelize.BIGINT
|
||
|
},
|
||
|
invite: {
|
||
|
type: Sequelize.STRING,
|
||
|
allowNull: false
|
||
|
},
|
||
|
chatId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
userId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
expiresAt: {
|
||
|
type: Sequelize.DATE,
|
||
|
allowNull: false
|
||
|
},
|
||
|
createdAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
},
|
||
|
updatedAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
}
|
||
|
})
|
||
|
await queryInterface.createTable("BlockedUsers", {
|
||
|
id: {
|
||
|
allowNull: false,
|
||
|
autoIncrement: true,
|
||
|
primaryKey: true,
|
||
|
type: Sequelize.BIGINT
|
||
|
},
|
||
|
userId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
blockedUserId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
createdAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
},
|
||
|
updatedAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
}
|
||
|
})
|
||
|
await queryInterface.createTable("MutedChats", {
|
||
|
id: {
|
||
|
allowNull: false,
|
||
|
autoIncrement: true,
|
||
|
primaryKey: true,
|
||
|
type: Sequelize.BIGINT
|
||
|
},
|
||
|
userId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
chatId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
createdAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
},
|
||
|
updatedAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
}
|
||
|
})
|
||
|
await queryInterface.addColumn("users", "privacy", {
|
||
|
type: Sequelize.JSON,
|
||
|
defaultValue: {
|
||
|
communications: {
|
||
|
enabled: false,
|
||
|
outsideTenant: false,
|
||
|
directMessages: "friendsOnly",
|
||
|
friendRequests: true
|
||
|
}
|
||
|
},
|
||
|
allowNull: false
|
||
|
})
|
||
|
await queryInterface.createTable("friends", {
|
||
|
id: {
|
||
|
allowNull: false,
|
||
|
autoIncrement: true,
|
||
|
primaryKey: true,
|
||
|
type: Sequelize.BIGINT
|
||
|
},
|
||
|
userId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
friendId: {
|
||
|
type: Sequelize.BIGINT,
|
||
|
allowNull: false
|
||
|
},
|
||
|
createdAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
},
|
||
|
updatedAt: {
|
||
|
allowNull: false,
|
||
|
type: Sequelize.DATE
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
|
||
|
down: async (queryInterface, Sequelize) => {
|
||
|
/**
|
||
|
* Add reverting commands here.
|
||
|
*
|
||
|
* Example:
|
||
|
* await queryInterface.dropTable('users');
|
||
|
*/
|
||
|
}
|
||
|
}
|