mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-20 04:39:20 +00:00
✨ add user association with whatsapps
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
import { QueryInterface, DataTypes } from "sequelize";
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface: QueryInterface) => {
|
||||||
|
return queryInterface.addColumn("Users", "whatsappId", {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
references: { model: "Whatsapps", key: "id" },
|
||||||
|
onUpdate: "CASCADE",
|
||||||
|
onDelete: "SET NULL",
|
||||||
|
allowNull: true
|
||||||
|
},);
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface: QueryInterface) => {
|
||||||
|
return queryInterface.removeColumn("Users", "whatsappId");
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -11,12 +11,15 @@ import {
|
|||||||
AutoIncrement,
|
AutoIncrement,
|
||||||
Default,
|
Default,
|
||||||
HasMany,
|
HasMany,
|
||||||
BelongsToMany
|
BelongsToMany,
|
||||||
|
ForeignKey,
|
||||||
|
BelongsTo
|
||||||
} from "sequelize-typescript";
|
} from "sequelize-typescript";
|
||||||
import { hash, compare } from "bcryptjs";
|
import { hash, compare } from "bcryptjs";
|
||||||
import Ticket from "./Ticket";
|
import Ticket from "./Ticket";
|
||||||
import Queue from "./Queue";
|
import Queue from "./Queue";
|
||||||
import UserQueue from "./UserQueue";
|
import UserQueue from "./UserQueue";
|
||||||
|
import Whatsapp from "./Whatsapp";
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
class User extends Model<User> {
|
class User extends Model<User> {
|
||||||
@@ -45,6 +48,13 @@ class User extends Model<User> {
|
|||||||
@Column
|
@Column
|
||||||
profile: string;
|
profile: string;
|
||||||
|
|
||||||
|
@ForeignKey(() => Whatsapp)
|
||||||
|
@Column
|
||||||
|
whatsappId: number;
|
||||||
|
|
||||||
|
@BelongsTo(() => Whatsapp)
|
||||||
|
whatsapp: Whatsapp;
|
||||||
|
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user