| | 1 | | using Jellyfin.Database.Implementations; |
| | 2 | | using Jellyfin.Database.Implementations.Locking; |
| | 3 | | using Microsoft.EntityFrameworkCore; |
| | 4 | | using Microsoft.EntityFrameworkCore.Design; |
| | 5 | | using Microsoft.Extensions.Logging.Abstractions; |
| | 6 | |
|
| | 7 | | namespace Jellyfin.Database.Providers.Sqlite.Migrations |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// The design time factory for <see cref="JellyfinDbContext"/>. |
| | 11 | | /// This is only used for the creation of migrations and not during runtime. |
| | 12 | | /// </summary> |
| | 13 | | internal sealed class SqliteDesignTimeJellyfinDbFactory : IDesignTimeDbContextFactory<JellyfinDbContext> |
| | 14 | | { |
| | 15 | | public JellyfinDbContext CreateDbContext(string[] args) |
| | 16 | | { |
| 1 | 17 | | var optionsBuilder = new DbContextOptionsBuilder<JellyfinDbContext>(); |
| 1 | 18 | | optionsBuilder.UseSqlite("Data Source=jellyfin.db", f => f.MigrationsAssembly(GetType().Assembly)); |
| | 19 | |
|
| 1 | 20 | | return new JellyfinDbContext( |
| 1 | 21 | | optionsBuilder.Options, |
| 1 | 22 | | NullLogger<JellyfinDbContext>.Instance, |
| 1 | 23 | | new SqliteDatabaseProvider(null!, NullLogger<SqliteDatabaseProvider>.Instance), |
| 1 | 24 | | new NoLockBehavior(NullLogger<NoLockBehavior>.Instance)); |
| | 25 | | } |
| | 26 | | } |
| | 27 | | } |