1689672099829-add-shared-vault-and-key-system-associations.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { MigrationInterface, QueryRunner } from 'typeorm'
  2. export class AddSharedVaultAndKeySystemAssociations1689672099829 implements MigrationInterface {
  3. name = 'AddSharedVaultAndKeySystemAssociations1689672099829'
  4. public async up(queryRunner: QueryRunner): Promise<void> {
  5. await queryRunner.query(
  6. 'CREATE TABLE "shared_vault_associations" ("uuid" varchar PRIMARY KEY NOT NULL, "shared_vault_uuid" varchar(36) NOT NULL, "item_uuid" varchar(36) NOT NULL, "last_edited_by" varchar(36) NOT NULL, "created_at_timestamp" bigint NOT NULL, "updated_at_timestamp" bigint NOT NULL)',
  7. )
  8. await queryRunner.query(
  9. 'CREATE INDEX "shared_vault_uuid_on_shared_vault_associations" ON "shared_vault_associations" ("shared_vault_uuid") ',
  10. )
  11. await queryRunner.query(
  12. 'CREATE INDEX "item_uuid_on_shared_vault_associations" ON "shared_vault_associations" ("item_uuid") ',
  13. )
  14. await queryRunner.query(
  15. 'CREATE TABLE "key_system_associations" ("uuid" varchar PRIMARY KEY NOT NULL, "key_system_uuid" varchar(36) NOT NULL, "item_uuid" varchar(36) NOT NULL, "created_at_timestamp" bigint NOT NULL, "updated_at_timestamp" bigint NOT NULL)',
  16. )
  17. await queryRunner.query(
  18. 'CREATE INDEX "key_system_uuid_on_key_system_associations" ON "key_system_associations" ("key_system_uuid") ',
  19. )
  20. await queryRunner.query(
  21. 'CREATE INDEX "item_uuid_on_key_system_associations" ON "key_system_associations" ("item_uuid") ',
  22. )
  23. }
  24. public async down(queryRunner: QueryRunner): Promise<void> {
  25. await queryRunner.query('DROP INDEX "item_uuid_on_key_system_associations"')
  26. await queryRunner.query('DROP INDEX "key_system_uuid_on_key_system_associations"')
  27. await queryRunner.query('DROP TABLE "key_system_associations"')
  28. await queryRunner.query('DROP INDEX "item_uuid_on_shared_vault_associations"')
  29. await queryRunner.query('DROP INDEX "shared_vault_uuid_on_shared_vault_associations"')
  30. await queryRunner.query('DROP TABLE "shared_vault_associations"')
  31. }
  32. }