223 lines
5.3 KiB
TypeScript
223 lines
5.3 KiB
TypeScript
|
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from "typeorm";
|
||
|
|
||
|
export class MemberBaseData1725435669492 implements MigrationInterface {
|
||
|
name = "MemberBaseData1725435669492";
|
||
|
|
||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||
|
await queryRunner.createTable(
|
||
|
new Table({
|
||
|
name: "award",
|
||
|
columns: [
|
||
|
{
|
||
|
name: "id",
|
||
|
type: "int",
|
||
|
isPrimary: true,
|
||
|
isNullable: false,
|
||
|
isGenerated: true,
|
||
|
generationStrategy: "increment",
|
||
|
},
|
||
|
{
|
||
|
name: "award",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
],
|
||
|
}),
|
||
|
true
|
||
|
);
|
||
|
|
||
|
await queryRunner.createTable(
|
||
|
new Table({
|
||
|
name: "communication_type",
|
||
|
columns: [
|
||
|
{
|
||
|
name: "id",
|
||
|
type: "int",
|
||
|
isPrimary: true,
|
||
|
isNullable: false,
|
||
|
isGenerated: true,
|
||
|
generationStrategy: "increment",
|
||
|
},
|
||
|
{
|
||
|
name: "type",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
{
|
||
|
name: "useColumns",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
default: "''",
|
||
|
},
|
||
|
],
|
||
|
}),
|
||
|
true
|
||
|
);
|
||
|
|
||
|
await queryRunner.createTable(
|
||
|
new Table({
|
||
|
name: "communication",
|
||
|
columns: [
|
||
|
{
|
||
|
name: "id",
|
||
|
type: "int",
|
||
|
isPrimary: true,
|
||
|
isNullable: false,
|
||
|
isGenerated: true,
|
||
|
generationStrategy: "increment",
|
||
|
},
|
||
|
{
|
||
|
name: "preffered",
|
||
|
type: "tinyint",
|
||
|
isNullable: false,
|
||
|
default: 0,
|
||
|
},
|
||
|
{
|
||
|
name: "mobile",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
{
|
||
|
name: "email",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
{
|
||
|
name: "city",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
{
|
||
|
name: "street",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
{
|
||
|
name: "streetNumber",
|
||
|
type: "int",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
{
|
||
|
name: "streetNumberAddition",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
{
|
||
|
name: "typeId",
|
||
|
type: "int",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
],
|
||
|
}),
|
||
|
true
|
||
|
);
|
||
|
|
||
|
await queryRunner.createTable(
|
||
|
new Table({
|
||
|
name: "executive_position",
|
||
|
columns: [
|
||
|
{
|
||
|
name: "id",
|
||
|
type: "int",
|
||
|
isPrimary: true,
|
||
|
isNullable: false,
|
||
|
isGenerated: true,
|
||
|
generationStrategy: "increment",
|
||
|
},
|
||
|
{
|
||
|
name: "position",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
],
|
||
|
}),
|
||
|
true
|
||
|
);
|
||
|
|
||
|
await queryRunner.createTable(
|
||
|
new Table({
|
||
|
name: "membership_status",
|
||
|
columns: [
|
||
|
{
|
||
|
name: "id",
|
||
|
type: "int",
|
||
|
isPrimary: true,
|
||
|
isNullable: false,
|
||
|
isGenerated: true,
|
||
|
generationStrategy: "increment",
|
||
|
},
|
||
|
{
|
||
|
name: "status",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
],
|
||
|
}),
|
||
|
true
|
||
|
);
|
||
|
|
||
|
await queryRunner.createTable(
|
||
|
new Table({
|
||
|
name: "qualification",
|
||
|
columns: [
|
||
|
{
|
||
|
name: "id",
|
||
|
type: "int",
|
||
|
isPrimary: true,
|
||
|
isNullable: false,
|
||
|
isGenerated: true,
|
||
|
generationStrategy: "increment",
|
||
|
},
|
||
|
{
|
||
|
name: "qualification",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: false,
|
||
|
},
|
||
|
{
|
||
|
name: "description",
|
||
|
type: "varchar",
|
||
|
length: "255",
|
||
|
isNullable: true,
|
||
|
default: null,
|
||
|
},
|
||
|
],
|
||
|
}),
|
||
|
true
|
||
|
);
|
||
|
|
||
|
await queryRunner.createForeignKey(
|
||
|
"communication",
|
||
|
new TableForeignKey({
|
||
|
columnNames: ["typeId"],
|
||
|
referencedColumnNames: ["id"],
|
||
|
referencedTableName: "communication_type",
|
||
|
onDelete: "RESTRICT",
|
||
|
})
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||
|
const communication = await queryRunner.getTable("communication");
|
||
|
const foreignKey = communication.foreignKeys.find((fk) => fk.columnNames.indexOf("typeId") !== -1);
|
||
|
await queryRunner.dropForeignKey("communication", foreignKey);
|
||
|
|
||
|
await queryRunner.dropTable("qualification");
|
||
|
await queryRunner.dropTable("membership_status");
|
||
|
await queryRunner.dropTable("executive_position");
|
||
|
await queryRunner.dropTable("communication");
|
||
|
await queryRunner.dropTable("communication_type");
|
||
|
await queryRunner.dropTable("award");
|
||
|
}
|
||
|
}
|