Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RdbmsSchemaBuilder

Creates complete tables schemas in the database based on the entity metadatas.

Steps how schema is being built:

  1. load list of all tables with complete column and keys information from the db
  2. drop all (old) foreign keys that exist in the table, but does not exist in the metadata
  3. create new tables that does not exist in the db, but exist in the metadata
  4. drop all columns exist (left old) in the db table, but does not exist in the metadata
  5. add columns from metadata which does not exist in the table
  6. update all exist columns which metadata has changed
  7. update primary keys - update old and create new primary key from changed columns
  8. create foreign keys which does not exist in the table yet
  9. create indices which are missing in db yet, and drops indices which exist in the db, but does not exist in the metadata anymore

Hierarchy

  • RdbmsSchemaBuilder

Implements

Index

Constructors

constructor

Properties

Protected connection

connection: Connection

Protected queryRunner

queryRunner: QueryRunner

Used to execute schema creation queries in a single connection.

Accessors

Protected entityToSyncMetadatas

Protected viewEntityToSyncMetadatas

Methods

Protected addNewColumns

  • addNewColumns(): Promise<void>

build

  • build(): Promise<void>

Protected createCompositeUniqueConstraints

  • createCompositeUniqueConstraints(): Promise<void>

Protected createForeignKeys

  • createForeignKeys(): Promise<void>

Protected createNewChecks

  • createNewChecks(): Promise<void>

Protected createNewExclusions

  • createNewExclusions(): Promise<void>

Protected createNewIndices

  • createNewIndices(): Promise<void>

Protected createNewTables

  • createNewTables(): Promise<void>
  • Creates tables that do not exist in the database yet. New tables are created without foreign and primary keys. Primary key only can be created in conclusion with auto generated column.

    Returns Promise<void>

Protected createTypeormMetadataTable

  • createTypeormMetadataTable(): Promise<void>

Protected createViews

  • createViews(): Promise<void>

Protected dropColumnCompositeIndices

  • dropColumnCompositeIndices(tablePath: string, columnName: string): Promise<void>

Protected dropColumnCompositeUniques

  • dropColumnCompositeUniques(tablePath: string, columnName: string): Promise<void>

Protected dropColumnReferencedForeignKeys

  • dropColumnReferencedForeignKeys(tablePath: string, columnName: string): Promise<void>

Protected dropCompositeUniqueConstraints

  • dropCompositeUniqueConstraints(): Promise<void>

Protected dropOldChecks

  • dropOldChecks(): Promise<void>

Protected dropOldExclusions

  • dropOldExclusions(): Promise<void>

Protected dropOldForeignKeys

  • dropOldForeignKeys(): Promise<void>

Protected dropOldIndices

  • dropOldIndices(): Promise<void>

Protected dropOldViews

  • dropOldViews(): Promise<void>

Protected dropRemovedColumns

  • dropRemovedColumns(): Promise<void>
  • Drops all columns that exist in the table, but does not exist in the metadata (left old). We drop their keys too, since it should be safe.

    Returns Promise<void>

Protected executeSchemaSyncOperationsInProperOrder

  • executeSchemaSyncOperationsInProperOrder(): Promise<void>

log

Protected metadataColumnsToTableColumnOptions

Protected renameColumns

  • renameColumns(): Promise<void>
  • Renames columns. Works if only one column per table was changed. Changes only column name. If something besides name was changed, these changes will be ignored.

    Returns Promise<void>

Protected renameTables

  • renameTables(): Promise<void>

Protected updateExistColumns

  • updateExistColumns(): Promise<void>
  • Update all exist columns which metadata has changed. Still don't create keys. Also we don't touch foreign keys of the changed columns.

    Returns Promise<void>

Protected updatePrimaryKeys

  • updatePrimaryKeys(): Promise<void>

Generated using TypeDoc