add database migrations

This commit is contained in:
Xymorot 2019-06-23 03:33:48 +02:00
parent 74f76a83fb
commit f2d30d00f6
4 changed files with 422 additions and 1 deletions

View File

@ -7,6 +7,20 @@
- `npm run webpack` for frontend
- `npm dev`
### Database Migrations
Migrations are stored in [src/main/migrations](src/main/migrations) and handled by typeorm.
To auto-generate a migration:
`node_modules/.bin/typeorm migration:generate -c <connection name>`
To create an empty creation which can be filled with custom migration code:
`node_modules/.bin/typeorm migration:create -c <connection name>`
To run migrations:
`node_modules/.bin/typeorm migration:run -c <connection name>`
This is also pre-defined in the npm script `typeorm:migrate`.
## Donations
| | |

View File

@ -3,3 +3,7 @@ library:
database: ./database/library.db
entities:
- ./dist/main/entities/*.js
migrations:
- ./dist/main/migrations/library/*.js
cli:
migrationsDir: ./src/main/migrations/library

View File

@ -6,10 +6,11 @@
"author": "Xymorot",
"main": "dist/main.js",
"scripts": {
"postinstall": "npm run rebuild",
"postinstall": "npm run rebuild && npm run typeorm:migrate",
"start": "electron .",
"dev": "electron . --enable-logging",
"rebuild": "electron-rebuild -f -b -t prod,dev,optional",
"typeorm:migrate": "typeorm migration:run -c library",
"tsc": "tsc --watch",
"webpack": "webpack --watch",
"eslint-check": "eslint --print-config . | eslint-config-prettier-check",

View File

@ -0,0 +1,402 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
// tslint:disable-next-line: class-name
export class initialMigration1561252345968 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(
`CREATE TABLE "copy_type" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "type" integer NOT NULL, "comment" varchar, "copyId" integer NOT NULL)`
);
await queryRunner.query(
`CREATE TABLE "language" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "code" varchar NOT NULL, CONSTRAINT "UQ_465b3173cdddf0ac2d3fe73a33c" UNIQUE ("code"))`
);
await queryRunner.query(
`CREATE TABLE "site" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "nameCanonical" varchar NOT NULL, "names" text NOT NULL)`
);
await queryRunner.query(
`CREATE TABLE "source" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "uri" varchar NOT NULL, "siteId" integer NOT NULL, CONSTRAINT "UQ_028f4c3a05a9bfcddb95a4916b9" UNIQUE ("uri"))`
);
await queryRunner.query(
`CREATE TABLE "translator" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "nameCanonical" varchar NOT NULL, "names" text NOT NULL)`
);
await queryRunner.query(
`CREATE TABLE "copy" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "favorites" boolean NOT NULL DEFAULT (0), "isDigital" boolean, "originalId" integer NOT NULL)`
);
await queryRunner.query(
`CREATE TABLE "intellectual_property" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "nameCanonical" varchar NOT NULL, "names" text NOT NULL)`
);
await queryRunner.query(
`CREATE TABLE "tag" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "nameCanonical" varchar NOT NULL, "names" text NOT NULL)`
);
await queryRunner.query(
`CREATE TABLE "book" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "nameCanonical" varchar NOT NULL, "names" text NOT NULL)`
);
await queryRunner.query(
`CREATE TABLE "author" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "nameCanonical" varchar NOT NULL, "names" text NOT NULL)`
);
await queryRunner.query(
`CREATE TABLE "copy_sources_source" ("copyId" integer NOT NULL, "sourceId" integer NOT NULL, PRIMARY KEY ("copyId", "sourceId"))`
);
await queryRunner.query(
`CREATE INDEX "IDX_653c33c5db26b8736e592ff3f6" ON "copy_sources_source" ("copyId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_946af3644f779b7cc7e7eb04eb" ON "copy_sources_source" ("sourceId") `
);
await queryRunner.query(
`CREATE TABLE "copy_languages_language" ("copyId" integer NOT NULL, "languageId" integer NOT NULL, PRIMARY KEY ("copyId", "languageId"))`
);
await queryRunner.query(
`CREATE INDEX "IDX_056de447bd9e4b2efdf5eafe49" ON "copy_languages_language" ("copyId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_c6adacfab107dc725d4fb5864b" ON "copy_languages_language" ("languageId") `
);
await queryRunner.query(
`CREATE TABLE "copy_translators_translator" ("copyId" integer NOT NULL, "translatorId" integer NOT NULL, PRIMARY KEY ("copyId", "translatorId"))`
);
await queryRunner.query(
`CREATE INDEX "IDX_2a20d8eaf28ebc28438271899f" ON "copy_translators_translator" ("copyId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_e19e5193f168ce07f52f15be06" ON "copy_translators_translator" ("translatorId") `
);
await queryRunner.query(
`CREATE TABLE "book_authors_author" ("bookId" integer NOT NULL, "authorId" integer NOT NULL, PRIMARY KEY ("bookId", "authorId"))`
);
await queryRunner.query(
`CREATE INDEX "IDX_9bf58ffb2a12a8609a738ee8ca" ON "book_authors_author" ("bookId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_a4cafdf2ec9974524a5321c751" ON "book_authors_author" ("authorId") `
);
await queryRunner.query(
`CREATE TABLE "book_intellectual_properties_intellectual_property" ("bookId" integer NOT NULL, "intellectualPropertyId" integer NOT NULL, PRIMARY KEY ("bookId", "intellectualPropertyId"))`
);
await queryRunner.query(
`CREATE INDEX "IDX_e9c020c583e45df7d34114e894" ON "book_intellectual_properties_intellectual_property" ("bookId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_fe535d19fd50189cbeda0f92fd" ON "book_intellectual_properties_intellectual_property" ("intellectualPropertyId") `
);
await queryRunner.query(
`CREATE TABLE "book_tags_tag" ("bookId" integer NOT NULL, "tagId" integer NOT NULL, PRIMARY KEY ("bookId", "tagId"))`
);
await queryRunner.query(
`CREATE INDEX "IDX_918a7b7552fe5fd66f328d4fe8" ON "book_tags_tag" ("bookId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_5274aca0a1468ed55afdfaba24" ON "book_tags_tag" ("tagId") `
);
await queryRunner.query(
`CREATE TABLE "temporary_copy_type" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "type" integer NOT NULL, "comment" varchar, "copyId" integer NOT NULL, CONSTRAINT "FK_156b15213d57b5dbbbc33e94050" FOREIGN KEY ("copyId") REFERENCES "copy" ("id") ON DELETE CASCADE ON UPDATE CASCADE)`
);
await queryRunner.query(
`INSERT INTO "temporary_copy_type"("id", "type", "comment", "copyId") SELECT "id", "type", "comment", "copyId" FROM "copy_type"`
);
await queryRunner.query(`DROP TABLE "copy_type"`);
await queryRunner.query(
`ALTER TABLE "temporary_copy_type" RENAME TO "copy_type"`
);
await queryRunner.query(
`CREATE TABLE "temporary_source" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "uri" varchar NOT NULL, "siteId" integer NOT NULL, CONSTRAINT "UQ_028f4c3a05a9bfcddb95a4916b9" UNIQUE ("uri"), CONSTRAINT "FK_73b253e679f350d140bdb104e49" FOREIGN KEY ("siteId") REFERENCES "site" ("id") ON DELETE CASCADE ON UPDATE CASCADE)`
);
await queryRunner.query(
`INSERT INTO "temporary_source"("id", "uri", "siteId") SELECT "id", "uri", "siteId" FROM "source"`
);
await queryRunner.query(`DROP TABLE "source"`);
await queryRunner.query(
`ALTER TABLE "temporary_source" RENAME TO "source"`
);
await queryRunner.query(
`CREATE TABLE "temporary_copy" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "favorites" boolean NOT NULL DEFAULT (0), "isDigital" boolean, "originalId" integer NOT NULL, CONSTRAINT "FK_e8ce0011cf0a8b9fdc8ad908a44" FOREIGN KEY ("originalId") REFERENCES "book" ("id") ON DELETE CASCADE ON UPDATE CASCADE)`
);
await queryRunner.query(
`INSERT INTO "temporary_copy"("id", "favorites", "isDigital", "originalId") SELECT "id", "favorites", "isDigital", "originalId" FROM "copy"`
);
await queryRunner.query(`DROP TABLE "copy"`);
await queryRunner.query(`ALTER TABLE "temporary_copy" RENAME TO "copy"`);
await queryRunner.query(`DROP INDEX "IDX_653c33c5db26b8736e592ff3f6"`);
await queryRunner.query(`DROP INDEX "IDX_946af3644f779b7cc7e7eb04eb"`);
await queryRunner.query(
`CREATE TABLE "temporary_copy_sources_source" ("copyId" integer NOT NULL, "sourceId" integer NOT NULL, CONSTRAINT "FK_653c33c5db26b8736e592ff3f65" FOREIGN KEY ("copyId") REFERENCES "copy" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_946af3644f779b7cc7e7eb04eb7" FOREIGN KEY ("sourceId") REFERENCES "source" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY ("copyId", "sourceId"))`
);
await queryRunner.query(
`INSERT INTO "temporary_copy_sources_source"("copyId", "sourceId") SELECT "copyId", "sourceId" FROM "copy_sources_source"`
);
await queryRunner.query(`DROP TABLE "copy_sources_source"`);
await queryRunner.query(
`ALTER TABLE "temporary_copy_sources_source" RENAME TO "copy_sources_source"`
);
await queryRunner.query(
`CREATE INDEX "IDX_653c33c5db26b8736e592ff3f6" ON "copy_sources_source" ("copyId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_946af3644f779b7cc7e7eb04eb" ON "copy_sources_source" ("sourceId") `
);
await queryRunner.query(`DROP INDEX "IDX_056de447bd9e4b2efdf5eafe49"`);
await queryRunner.query(`DROP INDEX "IDX_c6adacfab107dc725d4fb5864b"`);
await queryRunner.query(
`CREATE TABLE "temporary_copy_languages_language" ("copyId" integer NOT NULL, "languageId" integer NOT NULL, CONSTRAINT "FK_056de447bd9e4b2efdf5eafe497" FOREIGN KEY ("copyId") REFERENCES "copy" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_c6adacfab107dc725d4fb5864be" FOREIGN KEY ("languageId") REFERENCES "language" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY ("copyId", "languageId"))`
);
await queryRunner.query(
`INSERT INTO "temporary_copy_languages_language"("copyId", "languageId") SELECT "copyId", "languageId" FROM "copy_languages_language"`
);
await queryRunner.query(`DROP TABLE "copy_languages_language"`);
await queryRunner.query(
`ALTER TABLE "temporary_copy_languages_language" RENAME TO "copy_languages_language"`
);
await queryRunner.query(
`CREATE INDEX "IDX_056de447bd9e4b2efdf5eafe49" ON "copy_languages_language" ("copyId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_c6adacfab107dc725d4fb5864b" ON "copy_languages_language" ("languageId") `
);
await queryRunner.query(`DROP INDEX "IDX_2a20d8eaf28ebc28438271899f"`);
await queryRunner.query(`DROP INDEX "IDX_e19e5193f168ce07f52f15be06"`);
await queryRunner.query(
`CREATE TABLE "temporary_copy_translators_translator" ("copyId" integer NOT NULL, "translatorId" integer NOT NULL, CONSTRAINT "FK_2a20d8eaf28ebc28438271899f5" FOREIGN KEY ("copyId") REFERENCES "copy" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_e19e5193f168ce07f52f15be068" FOREIGN KEY ("translatorId") REFERENCES "translator" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY ("copyId", "translatorId"))`
);
await queryRunner.query(
`INSERT INTO "temporary_copy_translators_translator"("copyId", "translatorId") SELECT "copyId", "translatorId" FROM "copy_translators_translator"`
);
await queryRunner.query(`DROP TABLE "copy_translators_translator"`);
await queryRunner.query(
`ALTER TABLE "temporary_copy_translators_translator" RENAME TO "copy_translators_translator"`
);
await queryRunner.query(
`CREATE INDEX "IDX_2a20d8eaf28ebc28438271899f" ON "copy_translators_translator" ("copyId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_e19e5193f168ce07f52f15be06" ON "copy_translators_translator" ("translatorId") `
);
await queryRunner.query(`DROP INDEX "IDX_9bf58ffb2a12a8609a738ee8ca"`);
await queryRunner.query(`DROP INDEX "IDX_a4cafdf2ec9974524a5321c751"`);
await queryRunner.query(
`CREATE TABLE "temporary_book_authors_author" ("bookId" integer NOT NULL, "authorId" integer NOT NULL, CONSTRAINT "FK_9bf58ffb2a12a8609a738ee8cae" FOREIGN KEY ("bookId") REFERENCES "book" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_a4cafdf2ec9974524a5321c7516" FOREIGN KEY ("authorId") REFERENCES "author" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY ("bookId", "authorId"))`
);
await queryRunner.query(
`INSERT INTO "temporary_book_authors_author"("bookId", "authorId") SELECT "bookId", "authorId" FROM "book_authors_author"`
);
await queryRunner.query(`DROP TABLE "book_authors_author"`);
await queryRunner.query(
`ALTER TABLE "temporary_book_authors_author" RENAME TO "book_authors_author"`
);
await queryRunner.query(
`CREATE INDEX "IDX_9bf58ffb2a12a8609a738ee8ca" ON "book_authors_author" ("bookId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_a4cafdf2ec9974524a5321c751" ON "book_authors_author" ("authorId") `
);
await queryRunner.query(`DROP INDEX "IDX_e9c020c583e45df7d34114e894"`);
await queryRunner.query(`DROP INDEX "IDX_fe535d19fd50189cbeda0f92fd"`);
await queryRunner.query(
`CREATE TABLE "temporary_book_intellectual_properties_intellectual_property" ("bookId" integer NOT NULL, "intellectualPropertyId" integer NOT NULL, CONSTRAINT "FK_e9c020c583e45df7d34114e8945" FOREIGN KEY ("bookId") REFERENCES "book" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_fe535d19fd50189cbeda0f92fda" FOREIGN KEY ("intellectualPropertyId") REFERENCES "intellectual_property" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY ("bookId", "intellectualPropertyId"))`
);
await queryRunner.query(
`INSERT INTO "temporary_book_intellectual_properties_intellectual_property"("bookId", "intellectualPropertyId") SELECT "bookId", "intellectualPropertyId" FROM "book_intellectual_properties_intellectual_property"`
);
await queryRunner.query(
`DROP TABLE "book_intellectual_properties_intellectual_property"`
);
await queryRunner.query(
`ALTER TABLE "temporary_book_intellectual_properties_intellectual_property" RENAME TO "book_intellectual_properties_intellectual_property"`
);
await queryRunner.query(
`CREATE INDEX "IDX_e9c020c583e45df7d34114e894" ON "book_intellectual_properties_intellectual_property" ("bookId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_fe535d19fd50189cbeda0f92fd" ON "book_intellectual_properties_intellectual_property" ("intellectualPropertyId") `
);
await queryRunner.query(`DROP INDEX "IDX_918a7b7552fe5fd66f328d4fe8"`);
await queryRunner.query(`DROP INDEX "IDX_5274aca0a1468ed55afdfaba24"`);
await queryRunner.query(
`CREATE TABLE "temporary_book_tags_tag" ("bookId" integer NOT NULL, "tagId" integer NOT NULL, CONSTRAINT "FK_918a7b7552fe5fd66f328d4fe84" FOREIGN KEY ("bookId") REFERENCES "book" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_5274aca0a1468ed55afdfaba244" FOREIGN KEY ("tagId") REFERENCES "tag" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, PRIMARY KEY ("bookId", "tagId"))`
);
await queryRunner.query(
`INSERT INTO "temporary_book_tags_tag"("bookId", "tagId") SELECT "bookId", "tagId" FROM "book_tags_tag"`
);
await queryRunner.query(`DROP TABLE "book_tags_tag"`);
await queryRunner.query(
`ALTER TABLE "temporary_book_tags_tag" RENAME TO "book_tags_tag"`
);
await queryRunner.query(
`CREATE INDEX "IDX_918a7b7552fe5fd66f328d4fe8" ON "book_tags_tag" ("bookId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_5274aca0a1468ed55afdfaba24" ON "book_tags_tag" ("tagId") `
);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`DROP INDEX "IDX_5274aca0a1468ed55afdfaba24"`);
await queryRunner.query(`DROP INDEX "IDX_918a7b7552fe5fd66f328d4fe8"`);
await queryRunner.query(
`ALTER TABLE "book_tags_tag" RENAME TO "temporary_book_tags_tag"`
);
await queryRunner.query(
`CREATE TABLE "book_tags_tag" ("bookId" integer NOT NULL, "tagId" integer NOT NULL, PRIMARY KEY ("bookId", "tagId"))`
);
await queryRunner.query(
`INSERT INTO "book_tags_tag"("bookId", "tagId") SELECT "bookId", "tagId" FROM "temporary_book_tags_tag"`
);
await queryRunner.query(`DROP TABLE "temporary_book_tags_tag"`);
await queryRunner.query(
`CREATE INDEX "IDX_5274aca0a1468ed55afdfaba24" ON "book_tags_tag" ("tagId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_918a7b7552fe5fd66f328d4fe8" ON "book_tags_tag" ("bookId") `
);
await queryRunner.query(`DROP INDEX "IDX_fe535d19fd50189cbeda0f92fd"`);
await queryRunner.query(`DROP INDEX "IDX_e9c020c583e45df7d34114e894"`);
await queryRunner.query(
`ALTER TABLE "book_intellectual_properties_intellectual_property" RENAME TO "temporary_book_intellectual_properties_intellectual_property"`
);
await queryRunner.query(
`CREATE TABLE "book_intellectual_properties_intellectual_property" ("bookId" integer NOT NULL, "intellectualPropertyId" integer NOT NULL, PRIMARY KEY ("bookId", "intellectualPropertyId"))`
);
await queryRunner.query(
`INSERT INTO "book_intellectual_properties_intellectual_property"("bookId", "intellectualPropertyId") SELECT "bookId", "intellectualPropertyId" FROM "temporary_book_intellectual_properties_intellectual_property"`
);
await queryRunner.query(
`DROP TABLE "temporary_book_intellectual_properties_intellectual_property"`
);
await queryRunner.query(
`CREATE INDEX "IDX_fe535d19fd50189cbeda0f92fd" ON "book_intellectual_properties_intellectual_property" ("intellectualPropertyId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_e9c020c583e45df7d34114e894" ON "book_intellectual_properties_intellectual_property" ("bookId") `
);
await queryRunner.query(`DROP INDEX "IDX_a4cafdf2ec9974524a5321c751"`);
await queryRunner.query(`DROP INDEX "IDX_9bf58ffb2a12a8609a738ee8ca"`);
await queryRunner.query(
`ALTER TABLE "book_authors_author" RENAME TO "temporary_book_authors_author"`
);
await queryRunner.query(
`CREATE TABLE "book_authors_author" ("bookId" integer NOT NULL, "authorId" integer NOT NULL, PRIMARY KEY ("bookId", "authorId"))`
);
await queryRunner.query(
`INSERT INTO "book_authors_author"("bookId", "authorId") SELECT "bookId", "authorId" FROM "temporary_book_authors_author"`
);
await queryRunner.query(`DROP TABLE "temporary_book_authors_author"`);
await queryRunner.query(
`CREATE INDEX "IDX_a4cafdf2ec9974524a5321c751" ON "book_authors_author" ("authorId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_9bf58ffb2a12a8609a738ee8ca" ON "book_authors_author" ("bookId") `
);
await queryRunner.query(`DROP INDEX "IDX_e19e5193f168ce07f52f15be06"`);
await queryRunner.query(`DROP INDEX "IDX_2a20d8eaf28ebc28438271899f"`);
await queryRunner.query(
`ALTER TABLE "copy_translators_translator" RENAME TO "temporary_copy_translators_translator"`
);
await queryRunner.query(
`CREATE TABLE "copy_translators_translator" ("copyId" integer NOT NULL, "translatorId" integer NOT NULL, PRIMARY KEY ("copyId", "translatorId"))`
);
await queryRunner.query(
`INSERT INTO "copy_translators_translator"("copyId", "translatorId") SELECT "copyId", "translatorId" FROM "temporary_copy_translators_translator"`
);
await queryRunner.query(
`DROP TABLE "temporary_copy_translators_translator"`
);
await queryRunner.query(
`CREATE INDEX "IDX_e19e5193f168ce07f52f15be06" ON "copy_translators_translator" ("translatorId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_2a20d8eaf28ebc28438271899f" ON "copy_translators_translator" ("copyId") `
);
await queryRunner.query(`DROP INDEX "IDX_c6adacfab107dc725d4fb5864b"`);
await queryRunner.query(`DROP INDEX "IDX_056de447bd9e4b2efdf5eafe49"`);
await queryRunner.query(
`ALTER TABLE "copy_languages_language" RENAME TO "temporary_copy_languages_language"`
);
await queryRunner.query(
`CREATE TABLE "copy_languages_language" ("copyId" integer NOT NULL, "languageId" integer NOT NULL, PRIMARY KEY ("copyId", "languageId"))`
);
await queryRunner.query(
`INSERT INTO "copy_languages_language"("copyId", "languageId") SELECT "copyId", "languageId" FROM "temporary_copy_languages_language"`
);
await queryRunner.query(`DROP TABLE "temporary_copy_languages_language"`);
await queryRunner.query(
`CREATE INDEX "IDX_c6adacfab107dc725d4fb5864b" ON "copy_languages_language" ("languageId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_056de447bd9e4b2efdf5eafe49" ON "copy_languages_language" ("copyId") `
);
await queryRunner.query(`DROP INDEX "IDX_946af3644f779b7cc7e7eb04eb"`);
await queryRunner.query(`DROP INDEX "IDX_653c33c5db26b8736e592ff3f6"`);
await queryRunner.query(
`ALTER TABLE "copy_sources_source" RENAME TO "temporary_copy_sources_source"`
);
await queryRunner.query(
`CREATE TABLE "copy_sources_source" ("copyId" integer NOT NULL, "sourceId" integer NOT NULL, PRIMARY KEY ("copyId", "sourceId"))`
);
await queryRunner.query(
`INSERT INTO "copy_sources_source"("copyId", "sourceId") SELECT "copyId", "sourceId" FROM "temporary_copy_sources_source"`
);
await queryRunner.query(`DROP TABLE "temporary_copy_sources_source"`);
await queryRunner.query(
`CREATE INDEX "IDX_946af3644f779b7cc7e7eb04eb" ON "copy_sources_source" ("sourceId") `
);
await queryRunner.query(
`CREATE INDEX "IDX_653c33c5db26b8736e592ff3f6" ON "copy_sources_source" ("copyId") `
);
await queryRunner.query(`ALTER TABLE "copy" RENAME TO "temporary_copy"`);
await queryRunner.query(
`CREATE TABLE "copy" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "favorites" boolean NOT NULL DEFAULT (0), "isDigital" boolean, "originalId" integer NOT NULL)`
);
await queryRunner.query(
`INSERT INTO "copy"("id", "favorites", "isDigital", "originalId") SELECT "id", "favorites", "isDigital", "originalId" FROM "temporary_copy"`
);
await queryRunner.query(`DROP TABLE "temporary_copy"`);
await queryRunner.query(
`ALTER TABLE "source" RENAME TO "temporary_source"`
);
await queryRunner.query(
`CREATE TABLE "source" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "uri" varchar NOT NULL, "siteId" integer NOT NULL, CONSTRAINT "UQ_028f4c3a05a9bfcddb95a4916b9" UNIQUE ("uri"))`
);
await queryRunner.query(
`INSERT INTO "source"("id", "uri", "siteId") SELECT "id", "uri", "siteId" FROM "temporary_source"`
);
await queryRunner.query(`DROP TABLE "temporary_source"`);
await queryRunner.query(
`ALTER TABLE "copy_type" RENAME TO "temporary_copy_type"`
);
await queryRunner.query(
`CREATE TABLE "copy_type" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "type" integer NOT NULL, "comment" varchar, "copyId" integer NOT NULL)`
);
await queryRunner.query(
`INSERT INTO "copy_type"("id", "type", "comment", "copyId") SELECT "id", "type", "comment", "copyId" FROM "temporary_copy_type"`
);
await queryRunner.query(`DROP TABLE "temporary_copy_type"`);
await queryRunner.query(`DROP INDEX "IDX_5274aca0a1468ed55afdfaba24"`);
await queryRunner.query(`DROP INDEX "IDX_918a7b7552fe5fd66f328d4fe8"`);
await queryRunner.query(`DROP TABLE "book_tags_tag"`);
await queryRunner.query(`DROP INDEX "IDX_fe535d19fd50189cbeda0f92fd"`);
await queryRunner.query(`DROP INDEX "IDX_e9c020c583e45df7d34114e894"`);
await queryRunner.query(
`DROP TABLE "book_intellectual_properties_intellectual_property"`
);
await queryRunner.query(`DROP INDEX "IDX_a4cafdf2ec9974524a5321c751"`);
await queryRunner.query(`DROP INDEX "IDX_9bf58ffb2a12a8609a738ee8ca"`);
await queryRunner.query(`DROP TABLE "book_authors_author"`);
await queryRunner.query(`DROP INDEX "IDX_e19e5193f168ce07f52f15be06"`);
await queryRunner.query(`DROP INDEX "IDX_2a20d8eaf28ebc28438271899f"`);
await queryRunner.query(`DROP TABLE "copy_translators_translator"`);
await queryRunner.query(`DROP INDEX "IDX_c6adacfab107dc725d4fb5864b"`);
await queryRunner.query(`DROP INDEX "IDX_056de447bd9e4b2efdf5eafe49"`);
await queryRunner.query(`DROP TABLE "copy_languages_language"`);
await queryRunner.query(`DROP INDEX "IDX_946af3644f779b7cc7e7eb04eb"`);
await queryRunner.query(`DROP INDEX "IDX_653c33c5db26b8736e592ff3f6"`);
await queryRunner.query(`DROP TABLE "copy_sources_source"`);
await queryRunner.query(`DROP TABLE "author"`);
await queryRunner.query(`DROP TABLE "book"`);
await queryRunner.query(`DROP TABLE "tag"`);
await queryRunner.query(`DROP TABLE "intellectual_property"`);
await queryRunner.query(`DROP TABLE "copy"`);
await queryRunner.query(`DROP TABLE "translator"`);
await queryRunner.query(`DROP TABLE "source"`);
await queryRunner.query(`DROP TABLE "site"`);
await queryRunner.query(`DROP TABLE "language"`);
await queryRunner.query(`DROP TABLE "copy_type"`);
}
}