SQLMigratorclass

new SQLMigrator<T>()
Return
SQLMigrator<T>
Shared SQL migration logic that diffs collection schemas against live tables to produce migration statements.

Shared SQL migration logic that diffs collection schemas against live tables to produce migration statements.

  • Subclasses implement backend-specific schema inspection and column definitions (e.g. SQLite, PostgreSQL).

Examples

const migrator = new SQLiteMigrator(provider);
 await migrator.migrate(users, posts);

Methods

Go

SQLMigrator.migrate()method

Bring the provider's tables into line with the given collection schemas by running the generated migrations.

migrate(...collections: Collections<number>): Promise<void>
Go

SQLMigrator.getMigrations()method

Compute the SQL statements needed to bring the tables into line with the given collection schemas, without executing them.

getMigrations(...collections: Collections<number>): Promise<readonly string[]>
Go

SQLMigrator.getCreateTableQuery()method

Build the CREATE TABLE statement for a collection, including its ID, data, and generated columns.

getCreateTableQuery(collection: Collection<string, number, T>): string
Go

SQLMigrator.getCreateTableColumns()method

Get the full set of columns for a collection's table: the ID column, data column, and generated columns.

getCreateTableColumns(collection: Collection<string, number, T>): readonly SQLTableColumn[]
Go

SQLMigrator.getGeneratedTableColumns()method

Get the generated (computed) columns for a collection's table, derived from its schema's scalar properties.

getGeneratedTableColumns(collection: Collection<string, number, T>): readonly SQLTableColumn[]