mirror of
https://github.com/outline/outline.git
synced 2026-11-22 05:51:43 +03:00
migration
This commit is contained in:
1 parent
1b913054e8
commit
eebf5bd9e2
2 files changed
+82
No files matched your search
@@ -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,
|
||||
user: true,
|
||||
});
|
||||
});
|
||||
},
|
||||
down: async (queryInterface) => {
|
||||
return queryInterface.dropTable("team_domains");
|
||||
},
|
||||
};
|
||||
@@ -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;
|
||||
Reference in new issue
Block a user