feature/#22-API-Tokens #49

Merged
jkeffects merged 8 commits from feature/#22-API-Tokens into develop 2025-01-22 10:59:46 +00:00
3 changed files with 14 additions and 9 deletions
Showing only changes of commit ca6dbafaf1 - Show all commits

View file

@ -2,7 +2,10 @@ import { Column, CreateDateColumn, Entity, PrimaryColumn } from "typeorm";
@Entity()
export class api {
@PrimaryColumn({ type: "varchar", length: 255 })
@PrimaryColumn({ generated: "increment", type: "int" })
id: number;
@Column({ type: "varchar", length: 255, unique: true, select: false })
token: string;
@Column({ type: "varchar", length: 255 })

View file

@ -5,7 +5,7 @@ import { api } from "./api";
@Entity()
export class apiPermission {
@PrimaryColumn({ type: "int" })
apiToken: number;
apiId: number;
@PrimaryColumn({ type: "varchar", length: 255 })
permission: PermissionString;

View file

@ -11,11 +11,12 @@ export class AddApiTokens1737453096674 implements MigrationInterface {
new Table({
name: "api",
columns: [
{ name: "token", type: "varchar", length: "255", isPrimary: true, isNullable: false },
{ name: "id", type: variableType_int, isPrimary: true, isNullable: false },
{ name: "token", type: "varchar", length: "255", isUnique: true, isNullable: false },
{ name: "title", type: "varchar", length: "255", isNullable: false },
{ name: "createdAt", type: "datetime", default: "CURRENT_TIMESTAMP(6)", isNullable: false },
{ name: "lastUsage", type: "datetime", isNullable: true },
{ name: "expiry", type: "datetime", isNullable: true },
{ name: "lastUsage", type: "datetime", isNullable: true, default: null },
{ name: "expiry", type: "datetime", isNullable: true, default: null },
],
}),
true
@ -25,17 +26,18 @@ export class AddApiTokens1737453096674 implements MigrationInterface {
new Table({
name: "api_permission",
columns: [
{ name: "apiToken", type: "varchar", length: "255", isPrimary: true, isNullable: false },
{ name: "apiId", type: variableType_int, isPrimary: true, isNullable: false },
{ name: "permission", type: "varchar", length: "255", isPrimary: true, isNullable: false },
],
})
}),
true
);
await queryRunner.createForeignKey(
"api_permission",
new TableForeignKey({
columnNames: ["apiToken"],
referencedColumnNames: ["token"],
columnNames: ["apiId"],
referencedColumnNames: ["id"],
referencedTableName: "api",
onDelete: "CASCADE",
onUpdate: "RESTRICT",