migrations relations cleanup and formatting

This commit is contained in:
Julian Krauser 2024-09-14 11:33:13 +02:00
parent 10db9a40f4
commit a0321905ce
12 changed files with 90 additions and 270 deletions

View file

@ -8,32 +8,10 @@ export class Initial1724317398939 implements MigrationInterface {
new Table({
name: "user",
columns: [
{
name: "id",
type: "int",
isPrimary: true,
isNullable: false,
isGenerated: true,
generationStrategy: "increment",
},
{
name: "mail",
type: "varchar",
length: "255",
isNullable: false,
},
{
name: "username",
type: "varchar",
length: "255",
isNullable: false,
},
{
name: "secret",
type: "varchar",
length: "255",
isNullable: false,
},
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "mail", type: "varchar", length: "255", isNullable: false },
{ name: "username", type: "varchar", length: "255", isNullable: false },
{ name: "secret", type: "varchar", length: "255", isNullable: false },
],
}),
true
@ -43,30 +21,10 @@ export class Initial1724317398939 implements MigrationInterface {
new Table({
name: "refresh",
columns: [
{
name: "id",
type: "int",
isPrimary: true,
isNullable: false,
isGenerated: true,
generationStrategy: "increment",
},
{
name: "token",
type: "varchar",
length: "255",
isNullable: false,
},
{
name: "expiry",
type: "datetime",
isNullable: false,
},
{
name: "userId",
type: "int",
isNullable: true,
},
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "token", type: "varchar", length: "255", isNullable: false },
{ name: "expiry", type: "datetime", isNullable: false },
{ name: "userId", type: "int", isNullable: false },
],
}),
true
@ -79,6 +37,7 @@ export class Initial1724317398939 implements MigrationInterface {
referencedColumnNames: ["id"],
referencedTableName: "user",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
);
}

View file

@ -8,43 +8,12 @@ export class Invite1724579024939 implements MigrationInterface {
new Table({
name: "invite",
columns: [
{
name: "mail",
type: "varchar",
length: "255",
isPrimary: true,
isNullable: false,
},
{
name: "token",
type: "varchar",
length: "255",
isNullable: false,
},
{
name: "username",
type: "varchar",
length: "255",
isNullable: false,
},
{
name: "firstname",
type: "varchar",
length: "255",
isNullable: false,
},
{
name: "lastname",
type: "varchar",
length: "255",
isNullable: false,
},
{
name: "secret",
type: "varchar",
length: "255",
isNullable: false,
},
{ name: "mail", type: "varchar", length: "255", isPrimary: true, isNullable: false },
{ name: "token", type: "varchar", length: "255", isNullable: false },
{ name: "username", type: "varchar", length: "255", isNullable: false },
{ name: "firstname", type: "varchar", length: "255", isNullable: false },
{ name: "lastname", type: "varchar", length: "255", isNullable: false },
{ name: "secret", type: "varchar", length: "255", isNullable: false },
],
}),
true

View file

@ -15,12 +15,7 @@ export class Permissions1724661484664 implements MigrationInterface {
isPrimary: true,
isNullable: false,
},
{
name: "userId",
type: "int",
isPrimary: true,
isNullable: false,
},
{ name: "userId", type: "int", isPrimary: true, isNullable: false },
],
}),
true
@ -33,6 +28,7 @@ export class Permissions1724661484664 implements MigrationInterface {
referencedColumnNames: ["id"],
referencedTableName: "user",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
);
}

View file

@ -1,4 +1,4 @@
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from "typeorm";
import { MigrationInterface, QueryRunner, Table, TableForeignKey, TableIndex } from "typeorm";
export class RolePermission1724771491085 implements MigrationInterface {
name = "RolePermission1724771491085";
@ -8,20 +8,8 @@ export class RolePermission1724771491085 implements MigrationInterface {
new Table({
name: "role",
columns: [
{
name: "id",
type: "int",
isPrimary: true,
isNullable: false,
isGenerated: true,
generationStrategy: "increment",
},
{
name: "role",
type: "varchar",
length: "255",
isNullable: false,
},
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "role", type: "varchar", length: "255", isNullable: false },
],
}),
true
@ -38,12 +26,7 @@ export class RolePermission1724771491085 implements MigrationInterface {
isPrimary: true,
isNullable: false,
},
{
name: "roleId",
type: "int",
isPrimary: true,
isNullable: false,
},
{ name: "roleId", type: "int", isPrimary: true, isNullable: false },
],
}),
true
@ -55,18 +38,8 @@ export class RolePermission1724771491085 implements MigrationInterface {
new Table({
name: "user_roles",
columns: [
{
name: "userId",
type: "int",
isPrimary: true,
isNullable: false,
},
{
name: "roleId",
type: "int",
isPrimary: true,
isNullable: false,
},
{ name: "userId", type: "int", isPrimary: true, isNullable: false },
{ name: "roleId", type: "int", isPrimary: true, isNullable: false },
],
}),
true
@ -79,6 +52,7 @@ export class RolePermission1724771491085 implements MigrationInterface {
referencedColumnNames: ["id"],
referencedTableName: "role",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
);
@ -89,6 +63,7 @@ export class RolePermission1724771491085 implements MigrationInterface {
referencedColumnNames: ["id"],
referencedTableName: "user",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
);
@ -99,6 +74,21 @@ export class RolePermission1724771491085 implements MigrationInterface {
referencedColumnNames: ["id"],
referencedTableName: "role",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
);
await queryRunner.createIndex(
"user_roles",
new TableIndex({
columnNames: ["userId"],
})
);
await queryRunner.createIndex(
"user_roles",
new TableIndex({
columnNames: ["roleId"],
})
);
}

View file

@ -8,20 +8,8 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
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,
},
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "award", type: "varchar", length: "255", isNullable: false },
],
}),
true
@ -31,27 +19,9 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
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: "''",
},
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "type", type: "varchar", length: "255", isNullable: false },
{ name: "useColumns", type: "varchar", length: "255", isNullable: false, default: "''" },
],
}),
true
@ -61,60 +31,15 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
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,
},
{ name: "id", type: "int", isPrimary: true, 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
@ -124,20 +49,8 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
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,
},
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "position", type: "varchar", length: "255", isNullable: false },
],
}),
true
@ -147,20 +60,8 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
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,
},
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "status", type: "varchar", length: "255", isNullable: false },
],
}),
true
@ -170,27 +71,9 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
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,
},
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "qualification", type: "varchar", length: "255", isNullable: false },
{ name: "description", type: "varchar", length: "255", isNullable: true },
],
}),
true
@ -203,6 +86,7 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
referencedColumnNames: ["id"],
referencedTableName: "communication_type",
onDelete: "RESTRICT",
onUpdate: "RESTRICT",
})
);
}