Commit 9a0a394d authored by 神楽坂玲奈's avatar 神楽坂玲奈

数据结构

parent 20676c71
......@@ -5,6 +5,7 @@ import { AppBase } from './AppBase.entity';
import { AppHistory } from './AppHistory.entity';
import moment from 'moment';
import { join } from 'path';
import { Depot } from './Depot.entity';
@Entity()
export class App extends AppBase {
......@@ -21,6 +22,9 @@ export class App extends AppBase {
@Column('varchar', { length: 128, nullable: true })
packagePrefix: string;
@OneToMany(() => Depot, depot => depot.app)
depots: Depot[];
get packageFullPath() {
if (this.packagePrefix && this.packagePrefix.length) {
return join(this.id, this.packagePrefix);
......
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Build } from './Build.entity';
export enum ArchiveType {
Full = 'full',
Update = 'update',
Part = 'part'
}
@Entity()
export class Archive {
@PrimaryGeneratedColumn()
id: number;
@Column('varchar', { length: 256, array: true })
files: string[];
@Column('varchar', { length: 64 })
path: string;
@Column({ type: 'bytea', length: 64 })
checksum: Buffer;
@ManyToOne(type => Build, build => build.archives)
build: Build;
@Column({ type: 'enum', enum: ArchiveType })
role: ArchiveType;
}
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { Depot } from './Depot.entity';
import { Archive } from './Archive.entity';
@Entity()
export class Build {
@PrimaryGeneratedColumn()
id: number;
@Column()
version: string;
@ManyToOne(type => Depot, depot => depot.builds)
depot: Depot;
@OneToMany(type => Archive, archive => archive.build)
archives: Archive[];
@Column({ type: 'hstore', hstoreType: 'object' })
checksum: Record<string, string>;
}
import { Column, Entity, Index, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { App } from './App.entity';
import { Build } from './Build.entity';
@Index(d => [d.app, d.locale, d.platform.d.arch], { unique: true })
@Entity()
export class Depot {
@PrimaryGeneratedColumn()
id: number;
@Column({ default: 'generic' })
locale: string;
@Column({ default: 'generic' })
platform: string;
@Column({ default: 'generic' })
arch: string;
@ManyToOne(type => App, app => app.depots)
app: App;
@OneToMany(() => Build, build => build.depot)
builds: Build[];
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment