import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, Unique, } from "typeorm"; import { SnippetEntity } from "./snippet.entity"; /** * Immutable snapshot of a snippet at one version. The `snippets` table always * holds the latest version. Step code pins a version with * `runSnippet("alias@")`. */ @Entity("snippet_versions") @Unique(["snippetId", "version"]) export class SnippetVersionEntity { @PrimaryGeneratedColumn("uuid") id: string; @Column("text") snippetId: string; @ManyToOne(() => SnippetEntity, { onDelete: "CASCADE" }) @JoinColumn({ name: "snippetId" }) snippet: SnippetEntity; @Column({ type: "int" }) version: number; @Column() alias: string; @Column({ default: "" }) title: string; @Column("text", { nullable: true }) description: string | null; @Column("text") code: string; @CreateDateColumn() createdAt: Date; }