mirror of
https://github.com/chrisbenincasa/tunarr.git
synced 2026-04-18 09:03:35 -04:00
This commit includes a huge amount of changes, including support for adding Jellyfin servers as media sources and streaming content from them. These are breaking changes and touch almost every corner of the code, but also pave the way for a lot more flexibility on the backend for addinng different sources. The commit also includes performance improvements to the inline modal, lots of code cleanup, and a few bug fixes I found along the way. Fixes #24
90 lines
6.6 KiB
TypeScript
90 lines
6.6 KiB
TypeScript
import { Migration } from '@mikro-orm/migrations';
|
|
|
|
export class Migration20240805185042 extends Migration {
|
|
async up(): Promise<void> {
|
|
this.addSql('pragma foreign_keys = off;');
|
|
this.addSql(
|
|
'create table `program_grouping__temp_alter` (`uuid` text not null, `created_at` datetime not null, `updated_at` datetime not null, `type` ProgramGroupingType not null, `title` text not null, `summary` text null, `icon` text null, `year` integer null, `index` integer null, `show_uuid` text null, `artist_uuid` text null, constraint `program_grouping_show_uuid_foreign` foreign key(`show_uuid`) references `program_grouping`(`uuid`) on delete set null on update cascade, constraint `program_grouping_artist_uuid_foreign` foreign key(`artist_uuid`) references `program_grouping`(`uuid`) on delete set null on update cascade, primary key (`uuid`));',
|
|
);
|
|
this.addSql(
|
|
'insert into `program_grouping__temp_alter` select * from `program_grouping`;',
|
|
);
|
|
this.addSql('drop table `program_grouping`;');
|
|
this.addSql(
|
|
'alter table `program_grouping__temp_alter` rename to `program_grouping`;',
|
|
);
|
|
this.addSql(
|
|
'create index `program_grouping_show_uuid_index` on `program_grouping` (`show_uuid`);',
|
|
);
|
|
this.addSql(
|
|
'create index `program_grouping_artist_uuid_index` on `program_grouping` (`artist_uuid`);',
|
|
);
|
|
this.addSql('pragma foreign_keys = on;');
|
|
this.addSql('pragma foreign_keys = off;');
|
|
this.addSql(
|
|
"create table `program__temp_alter` (`uuid` text not null, `created_at` datetime not null, `updated_at` datetime not null, `source_type` text check (`source_type` in ('plex', 'jellyfin')) not null, `original_air_date` text null, `duration` integer not null, `episode` integer null, `episode_icon` text null, `file_path` text null, `icon` text null, `external_source_id` text not null, `external_key` text not null, `plex_rating_key` text null, `plex_file_path` text null, `parent_external_key` text null, `grandparent_external_key` text null, `rating` text null, `season_number` integer null, `season_icon` text null, `show_icon` text null, `show_title` text null, `summary` text null, `title` text not null, `type` text check (`type` in ('movie', 'episode', 'track')) not null, `year` integer null, `artist_name` text null, `album_name` text null, `season_uuid` text null, `tv_show_uuid` text null, `album_uuid` text null, `artist_uuid` text null, constraint `program_season_uuid_foreign` foreign key(`season_uuid`) references `program_grouping`(`uuid`) on delete set null, constraint `program_tv_show_uuid_foreign` foreign key(`tv_show_uuid`) references `program_grouping`(`uuid`) on delete set null, constraint `program_album_uuid_foreign` foreign key(`album_uuid`) references `program_grouping`(`uuid`) on delete set null, constraint `program_artist_uuid_foreign` foreign key(`artist_uuid`) references `program_grouping`(`uuid`) on delete set null, primary key (`uuid`));",
|
|
);
|
|
this.addSql('insert into `program__temp_alter` select * from `program`;');
|
|
this.addSql('drop table `program`;');
|
|
this.addSql('alter table `program__temp_alter` rename to `program`;');
|
|
this.addSql(
|
|
'create index `program_season_uuid_index` on `program` (`season_uuid`);',
|
|
);
|
|
this.addSql(
|
|
'create index `program_tv_show_uuid_index` on `program` (`tv_show_uuid`);',
|
|
);
|
|
this.addSql(
|
|
'create index `program_album_uuid_index` on `program` (`album_uuid`);',
|
|
);
|
|
this.addSql(
|
|
'create index `program_artist_uuid_index` on `program` (`artist_uuid`);',
|
|
);
|
|
this.addSql(
|
|
'create index `program_source_type_external_source_id_plex_rating_key_index` on `program` (`source_type`, `external_source_id`, `plex_rating_key`);',
|
|
);
|
|
this.addSql(
|
|
'create unique index `program_source_type_external_source_id_external_key_unique` on `program` (`source_type`, `external_source_id`, `external_key`);',
|
|
);
|
|
this.addSql('pragma foreign_keys = on;');
|
|
this.addSql('pragma foreign_keys = off;');
|
|
this.addSql(
|
|
"create table `program_external_id__temp_alter` (`uuid` text not null, `created_at` datetime not null, `updated_at` datetime not null, `source_type` text check (`source_type` in ('plex', 'plex-guid', 'tmdb', 'imdb', 'tvdb', 'jellyfin')) not null, `external_source_id` text null, `external_key` text not null, `external_file_path` text null, `direct_file_path` text null, `program_uuid` text not null, constraint `program_external_id_program_uuid_foreign` foreign key(`program_uuid`) references `program`(`uuid`) on update cascade, primary key (`uuid`));",
|
|
);
|
|
this.addSql(
|
|
'insert into `program_external_id__temp_alter` select * from `program_external_id`;',
|
|
);
|
|
this.addSql('drop table `program_external_id`;');
|
|
this.addSql(
|
|
'alter table `program_external_id__temp_alter` rename to `program_external_id`;',
|
|
);
|
|
this.addSql(
|
|
'create index `program_external_id_program_uuid_index` on `program_external_id` (`program_uuid`);',
|
|
);
|
|
this.addSql(
|
|
'create unique index `unique_program_multiple_external_id` on `program_external_id` (`program_uuid`, `source_type`, `external_source_id`) WHERE `external_source_id` IS NOT NULL;',
|
|
);
|
|
this.addSql(
|
|
'create unique index `unique_program_single_external_id` on `program_external_id` (`program_uuid`, `source_type`) WHERE `external_source_id` IS NULL;',
|
|
);
|
|
this.addSql('pragma foreign_keys = on;');
|
|
this.addSql('pragma foreign_keys = off;');
|
|
this.addSql(
|
|
"create table `program_grouping_external_id__temp_alter` (`uuid` text not null, `created_at` datetime not null, `updated_at` datetime not null, `source_type` text check (`source_type` in ('plex', 'plex-guid', 'tmdb', 'imdb', 'tvdb', 'jellyfin')) not null, `external_source_id` text null, `external_key` text not null, `external_file_path` text null, `group_uuid` text not null, constraint `program_grouping_external_id_group_uuid_foreign` foreign key(`group_uuid`) references `program_grouping`(`uuid`) on update cascade, primary key (`uuid`));",
|
|
);
|
|
this.addSql(
|
|
'insert into `program_grouping_external_id__temp_alter` select * from `program_grouping_external_id`;',
|
|
);
|
|
this.addSql('drop table `program_grouping_external_id`;');
|
|
this.addSql(
|
|
'alter table `program_grouping_external_id__temp_alter` rename to `program_grouping_external_id`;',
|
|
);
|
|
this.addSql(
|
|
'create index `program_grouping_external_id_group_uuid_index` on `program_grouping_external_id` (`group_uuid`);',
|
|
);
|
|
this.addSql(
|
|
'create unique index `program_grouping_external_id_uuid_source_type_unique` on `program_grouping_external_id` (`uuid`, `source_type`);',
|
|
);
|
|
this.addSql('pragma foreign_keys = on;');
|
|
}
|
|
}
|