remove: remove rateable trait from book entity
This commit is contained in:
parent
cdae3160df
commit
d83660ee30
|
@ -2,14 +2,13 @@ import { Entity, JoinTable, ManyToMany, OneToMany } from 'typeorm';
|
|||
import { BaseEntity } from '../base-entity';
|
||||
import { Author } from './author';
|
||||
import { MultiName, MultiNamed } from './base/multi-named';
|
||||
import { Rateable } from './base/rateable';
|
||||
import { Character } from './character';
|
||||
import { Copy } from './copy';
|
||||
import { Fiction } from './fiction';
|
||||
import { Tag } from './tag';
|
||||
|
||||
@Entity()
|
||||
export class Book extends Rateable(MultiNamed(BaseEntity, 'BookMultiName')) {
|
||||
export class Book extends MultiNamed(BaseEntity, 'BookMultiName') {
|
||||
@OneToMany(
|
||||
() => Copy,
|
||||
(copy: Copy) => copy.original
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class makeBooksUnrateable1575209413511 implements MigrationInterface {
|
||||
name = 'makeBooksUnrateable1575209413511';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<any> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "temporary_book" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "nameCanonical" varchar NOT NULL, "rating" integer, CONSTRAINT "CHK_bbef8dbd3571ec559f7a980fc5" CHECK ((LENGTH(nameCanonical) > 0)))`,
|
||||
undefined
|
||||
);
|
||||
await queryRunner.query(
|
||||
`INSERT INTO "temporary_book"("id", "nameCanonical", "rating") SELECT "id", "nameCanonical", "rating" FROM "book"`,
|
||||
undefined
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "book"`, undefined);
|
||||
await queryRunner.query(`ALTER TABLE "temporary_book" RENAME TO "book"`, undefined);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "temporary_book" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "nameCanonical" varchar NOT NULL, CONSTRAINT "CHK_bbef8dbd3571ec559f7a980fc5" CHECK ((LENGTH(nameCanonical) > 0)))`,
|
||||
undefined
|
||||
);
|
||||
await queryRunner.query(
|
||||
`INSERT INTO "temporary_book"("id", "nameCanonical") SELECT "id", "nameCanonical" FROM "book"`,
|
||||
undefined
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "book"`, undefined);
|
||||
await queryRunner.query(`ALTER TABLE "temporary_book" RENAME TO "book"`, undefined);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<any> {
|
||||
await queryRunner.query(`ALTER TABLE "book" RENAME TO "temporary_book"`, undefined);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "book" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "nameCanonical" varchar NOT NULL, "rating" integer, CONSTRAINT "CHK_bbef8dbd3571ec559f7a980fc5" CHECK ((LENGTH(nameCanonical) > 0)))`,
|
||||
undefined
|
||||
);
|
||||
await queryRunner.query(
|
||||
`INSERT INTO "book"("id", "nameCanonical") SELECT "id", "nameCanonical" FROM "temporary_book"`,
|
||||
undefined
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "temporary_book"`, undefined);
|
||||
await queryRunner.query(`ALTER TABLE "book" RENAME TO "temporary_book"`, undefined);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "book" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "nameCanonical" varchar NOT NULL, "rating" integer, CONSTRAINT "CHK_bbef8dbd3571ec559f7a980fc5" CHECK ((LENGTH(nameCanonical) > 0)), CONSTRAINT "CHK_62ebe0be1f2d31406118960aa5" CHECK ((rating >= 0 AND rating <= 9007199254740991)))`,
|
||||
undefined
|
||||
);
|
||||
await queryRunner.query(
|
||||
`INSERT INTO "book"("id", "nameCanonical", "rating") SELECT "id", "nameCanonical", "rating" FROM "temporary_book"`,
|
||||
undefined
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "temporary_book"`, undefined);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue