self defined value tables
This commit is contained in:
parent
6286add31c
commit
c85f23ed73
8 changed files with 382 additions and 3 deletions
222
src/migrations/1725435669492-member_base_data.ts
Normal file
222
src/migrations/1725435669492-member_base_data.ts
Normal file
|
@ -0,0 +1,222 @@
|
|||
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");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue