diff --git a/app/gen-server/entity/ServiceAccount.ts b/app/gen-server/entity/ServiceAccount.ts new file mode 100644 index 0000000000..daf07cc64e --- /dev/null +++ b/app/gen-server/entity/ServiceAccount.ts @@ -0,0 +1,24 @@ +import {BaseEntity, Column, Entity, JoinTable, ManyToOne, PrimaryGeneratedColumn} from "typeorm"; +import { User } from './User'; + +@Entity({name: 'service_accounts'}) +export class ServiceAccount extends BaseEntity { + + @PrimaryGeneratedColumn() + public id: number; + + + @Column({type: String}) + public description: string; + + @Column({type: Date, default: Date.now()}) + public endOfLife: string; + + @ManyToOne(type => User) + @JoinTable({ + name: 'service_account_user', + joinColumn: {name: 'service_account_id'}, + inverseJoinColumn: {name: 'user_id'} + }) + public service_account_owner: User; +} diff --git a/app/gen-server/entity/User.ts b/app/gen-server/entity/User.ts index 46fb54f5e0..3f1110c4bb 100644 --- a/app/gen-server/entity/User.ts +++ b/app/gen-server/entity/User.ts @@ -9,6 +9,7 @@ import {Group} from "./Group"; import {Login} from "./Login"; import {Organization} from "./Organization"; import {Pref} from './Pref'; +import {ServiceAccount} from './ServiceAccount'; @Entity({name: 'users'}) export class User extends BaseEntity { @@ -59,6 +60,13 @@ export class User extends BaseEntity { @Column({name: 'connect_id', type: String, nullable: true}) public connectId: string | null; + @OneToMany(type => User, user => user.serviceAccounts) + @JoinTable({ + name: 'service_account_user', + joinColumn: {name: 'user_id'}, + inverseJoinColumn: {name: 'service_account_id'} + }) + public serviceAccounts: ServiceAccount[]; /** * Unique reference for this user. Primarily used as an ownership key in a cell metadata (comments). */