Compare commits

...

2 Commits

Author SHA1 Message Date
Tom Moor acc75770a1 fix 2022-04-23 15:35:28 -07:00
Tom Moor eebf5bd9e2 migration 2022-04-23 15:33:01 -07:00
2 changed files with 82 additions and 0 deletions
@@ -0,0 +1,52 @@
"use strict";
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.createTable("team_domains", {
id: {
type: Sequelize.UUID,
allowNull: false,
primaryKey: true,
},
teamId: {
type: Sequelize.UUID,
allowNull: false,
onDelete: "cascade",
references: {
model: "teams",
},
},
createdById: {
type: Sequelize.UUID,
allowNull: false,
references: {
model: "users",
},
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
}, {
transaction
});
await queryInterface.addIndex("team_domains", ["teamId", "name"], {
transaction,
unique: true,
});
});
},
down: async (queryInterface) => {
return queryInterface.dropTable("team_domains");
},
};
+30
View File
@@ -0,0 +1,30 @@
import { Column, Table, BelongsTo, ForeignKey } from "sequelize-typescript";
import Team from "./Team";
import User from "./User";
import BaseModel from "./base/BaseModel";
import Fix from "./decorators/Fix";
@Table({ tableName: "team_domains", modelName: "team_domain" })
@Fix
class TeamDomain extends BaseModel {
@Column
name: string;
// associations
@BelongsTo(() => Team, "teamId")
team: Team;
@ForeignKey(() => Team)
@Column
teamId: string;
@BelongsTo(() => User, "createdById")
createdBy: User;
@ForeignKey(() => User)
@Column
createdById: string;
}
export default TeamDomain;