Skip to content

Commit

Permalink
feat: create new entity Service Account
Browse files Browse the repository at this point in the history
creating a join table with users and modify Users accordingly\n add a type column to user table
  • Loading branch information
hexaltation committed Nov 19, 2024
1 parent 3a8b265 commit 66b5aad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/gen-server/entity/ServiceAccount.ts
Original file line number Diff line number Diff line change
@@ -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;
}
8 changes: 8 additions & 0 deletions app/gen-server/entity/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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).
*/
Expand Down

0 comments on commit 66b5aad

Please sign in to comment.