Jellyfin.Database.Providers.Postgres
Extension methods for optimized bulk operations on PostgreSQL.
These methods help reduce dead tuple generation during media library scans by batching
operations and using more efficient transaction patterns.
Gets the recommended batch size for bulk operations based on the data size.
PostgreSQL works best with smaller batches to reduce dead tuples during scans.
The total number of entities to process.
The recommended batch size.
Saves changes in batches to reduce dead tuple generation during bulk operations.
This is especially useful during media library scans where many items are created/updated/deleted.
The database context.
The batch size for SaveChanges calls. If 0 or negative, uses automatic sizing.
Cancellation token.
Total number of changes saved.
Deletes entities in batches using raw SQL for better performance.
This reduces dead tuple generation compared to loading and deleting entities individually.
The database context.
The PostgreSQL schema name.
The table name.
Optional WHERE clause (without WHERE keyword). If null, all rows are deleted.
Cancellation token.
The number of rows deleted.
Truncates a table completely, which is much faster than DELETE for large tables.
Note: This cannot be used if there are foreign key references.
The database context.
The PostgreSQL schema name.
The table name.
If true, will CASCADE delete related rows. Use with caution.
Cancellation token.
A task representing the asynchronous operation.
Adds a large collection of entities to the context in batches to avoid memory issues.
The entity type.
The database context.
The entities to add.
The batch size for adding entities.
Whether to save changes after each batch.
Cancellation token.
Total number of entities saved.
Updates entities in batches to reduce dead tuple generation.
The entity type.
The database context.
The entities to update.
The batch size for updates.
Cancellation token.
Total number of entities updated.
Removes entities in batches to reduce dead tuple generation.
The entity type.
The database context.
The entities to remove.
The batch size for removals.
Cancellation token.
Total number of entities removed.
Executes VACUUM ANALYZE on a specific table to reclaim dead tuples and update statistics.
This is useful to call after bulk deletion operations.
The database context.
The PostgreSQL schema name.
The table name.
Cancellation token.
A task representing the asynchronous operation.
Helper class for managing transactions during bulk operations to reduce dead tuple generation.
Initializes a new instance of the class.
The database context.
Gets a value indicating whether the transaction has been committed.
Begins a new transaction with isolation level optimized for bulk operations.
Cancellation token.
A task representing the asynchronous operation.
Commits the transaction.
Cancellation token.
A task representing the asynchronous operation.
Rolls back the transaction.
Cancellation token.
A task representing the asynchronous operation.
Disposes the transaction if not already committed.
Disposes the transaction asynchronously if not already committed.
A task representing the asynchronous operation.
Extension methods for managing bulk operation transactions.
Executes a bulk operation within a transaction.
The database context.
The bulk operation to execute.
Cancellation token.
A task representing the asynchronous operation.
Executes a bulk operation within a transaction and returns a result.
The type of result returned by the operation.
The database context.
The bulk operation to execute.
Cancellation token.
The result of the operation.
Exception thrown when there is a version mismatch between PostgreSQL server and client tools (pg_dump/pg_restore).
Initializes a new instance of the class.
The PostgreSQL server version.
The pg_dump/pg_restore client version.
Initializes a new instance of the class.
The PostgreSQL server version.
The pg_dump/pg_restore client version.
The inner exception.
Gets the PostgreSQL server version.
Gets the pg_dump/pg_restore client version.
Removes the 17 flat extension columns from library.BaseItems now that all data has been
migrated to the BaseItemTvExtras, BaseItemLiveTvExtras, and BaseItemAudioExtras tables.
Must run AFTER SplitBaseItemExtras (20260503000000).
The design time factory for .
This is only used for the creation of migrations and not during runtime.
Model builder extensions for PostgreSQL.
Specify value converter for the object type.
The model builder.
The .
The type to convert.
The modified .
Specify the default .
The model builder to extend.
The to specify.
Service for creating and restoring PostgreSQL database backups using pg_dump/pg_restore.
Initializes a new instance of the class.
The logger.
The configuration manager.
Creates a backup of the PostgreSQL database.
The directory to save the backup file.
Cancellation token.
The path to the created backup file.
Restores a PostgreSQL database from a backup file.
The path to the backup file.
Cancellation token.
A task representing the restore operation.
Parses PostgreSQL version mismatch error message to extract server and client versions.
The error message from pg_dump.
A tuple containing server version and client version.
Configures Jellyfin to use a PostgreSQL database.
Initializes a new instance of the class.
Service to construct the fallback when the old data path configuration is used.
A logger.
The configuration manager (optional, for backup support).
Schema names mapping to legacy database files.
Schema for activity log tables (legacy: activitylog.db).
Schema for authentication tables (legacy: authentication.db).
Schema for display preferences tables (legacy: displaypreferences.db).
Schema for library tables (legacy: library.db).
Schema for user tables (legacy: users.db).
Gets all schema names.
Ensures the PostgreSQL database exists, creating it if necessary.
The database configuration.
Cancellation token.
A task representing the asynchronous operation.
Ensures all required schemas exist in the PostgreSQL database.
Ensures all required database tables exist by applying pending migrations.
Cancellation token.
A task representing the asynchronous operation.
Assigns entities to PostgreSQL schemas based on their legacy database origin.
The model builder.
Registers read-only keyless view projections for PostgreSQL.
Each view lives in the library schema and is mapped with
HasNoKey().ToView() so EF Core never tries to create a table or migration for it.
The model builder.
Determines if the given host is localhost.
The host to check.
True if the host is localhost or 127.0.0.1, false otherwise.
EF Core convention that maps all entity property names to snake_case column names.
Applied only by the PostgreSQL provider so SQLite is unaffected.
Converts a PascalCase identifier to snake_case.
The identifier to convert.
The snake_case representation of the identifier.
ValueConverter to specify DateTime kind for PostgreSQL.
Initializes a new instance of the class.
The kind to specify.
The mapping hints.