Commit b3c7fabe authored by nanahira's avatar nanahira

small fix of model

parent 66a7d29a
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Build } from './Build.entity'; import { Build } from './Build.entity';
import { Index } from 'typeorm/browser';
export enum ArchiveType { export enum ArchiveType {
Full = 'full', Full = 'full',
Update = 'update', Update = 'update',
Part = 'part' Part = 'part',
} }
@Entity() @Entity()
...@@ -15,13 +16,11 @@ export class Archive { ...@@ -15,13 +16,11 @@ export class Archive {
@Column('varchar', { length: 256, array: true }) @Column('varchar', { length: 256, array: true })
files: string[]; files: string[];
@Column('varchar', { length: 64 }) @Index()
@Column('varchar', { length: 140 })
path: string; path: string;
@Column({ type: 'bytea', length: 64 }) @ManyToOne((type) => Build, (build) => build.archives)
checksum: Buffer;
@ManyToOne(type => Build, build => build.archives)
build: Build; build: Build;
@Column({ type: 'enum', enum: ArchiveType }) @Column({ type: 'enum', enum: ArchiveType })
......
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { Depot } from './Depot.entity'; import { Depot } from './Depot.entity';
import { Archive } from './Archive.entity'; import { Archive } from './Archive.entity';
import { Index } from 'typeorm/browser';
@Entity() @Entity()
export class Build { export class Build {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;
@Index()
@Column() @Column()
version: string; version: string;
@ManyToOne(type => Depot, depot => depot.builds) @ManyToOne((type) => Depot, (depot) => depot.builds)
depot: Depot; depot: Depot;
@OneToMany(type => Archive, archive => archive.build) @OneToMany((type) => Archive, (archive) => archive.build)
archives: Archive[]; archives: Archive[];
@Column({ type: 'hstore', hstoreType: 'object' }) @Column({ type: 'hstore', hstoreType: 'object' })
......
...@@ -2,24 +2,27 @@ import { Column, Entity, Index, ManyToOne, OneToMany, PrimaryGeneratedColumn } f ...@@ -2,24 +2,27 @@ import { Column, Entity, Index, ManyToOne, OneToMany, PrimaryGeneratedColumn } f
import { App } from './App.entity'; import { App } from './App.entity';
import { Build } from './Build.entity'; import { Build } from './Build.entity';
@Index(d => [d.app, d.locale, d.platform.d.arch], { unique: true }) @Index((d) => [d.app, d.locale, d.platform.d.arch], { unique: true })
@Entity() @Entity()
export class Depot { export class Depot {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;
@Index()
@Column({ default: 'generic' }) @Column({ default: 'generic' })
locale: string; locale: string;
@Index()
@Column({ default: 'generic' }) @Column({ default: 'generic' })
platform: string; platform: string;
@Index()
@Column({ default: 'generic' }) @Column({ default: 'generic' })
arch: string; arch: string;
@ManyToOne(type => App, app => app.depots) @ManyToOne((type) => App, (app) => app.depots)
app: App; app: App;
@OneToMany(() => Build, build => build.depot) @OneToMany(() => Build, (build) => build.depot)
builds: Build[]; 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