Create a new TypeORM entity
Please create a new TypeORM entity in the `services/control-plane/src/db/entity` directory. Please follow these guidelines:
- Use the @Entity decorator on the class
- Always include the generated UUID id column and the timestamp column
- Use class-validator decorators wherever appropriate on columns, for example @IsDate, @IsString, etc.
- Use TypeORM decorators to describe the column's data type, whether it is nullable, max length, and other important properties like cascade relationships
- For references to other tables, you should use ManyToMany, ManyToOne, or OneToMany where appropriate. Make sure to wrap other tables' types in Relation<...>.
- If you add a relation, make sure to update the entity file for that other table
- Once you are done, you should also add the entity to `services/control-plane/src/db/dataSource.ts`
- Lastly, run `cd services/control-plane && npm run typeorm migration:generate -- ./src/db/migrations/<ENTITY_NAME>` in order to generate a migration
If you need to view any existing tables, you can look into the contents of `services/control-plane/src/db/entity` and read any of the relevant files.
This is an example entity file:
```OrgProxyKey.ts
import {
Column,
CreateDateColumn,
Entity,
ManyToOne,
PrimaryColumn,
type Relation,
} from "typeorm";
import {
IsDate,
IsOptional,
IsString,
IsUUID,
Length,
ValidateNested,
} from "class-validator";
import { Organization } from "../Organization.js";
@Entity()
export class OrgProxyKey {
@IsUUID(4)
@PrimaryColumn("uuid", { generated: "uuid" })
id: string;
@IsDate()
@CreateDateColumn()
timestamp: Date;
@IsString()
@Length(64, 64)
@Column({ unique: true, length: 64 })
key: string;
@IsOptional()
@IsDate()
@Column({ nullable: true })
lastConnected: Date;
@ValidateNested()
@ManyToOne(() => Organization, (org) => org.proxyKeys)
organization: Relation<Organization>;
}
```
Please create an entity with the following description: