mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
fix: use create if not exists clause for indexes (#20728)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
9c8c52874a
commit
f1c494ef97
10 changed files with 9 additions and 4 deletions
BIN
mobile/drift_schemas/main/drift_schema_v7.json
generated
BIN
mobile/drift_schemas/main/drift_schema_v7.json
generated
Binary file not shown.
|
|
@ -95,7 +95,7 @@ class ExifInfo {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TableIndex(name: 'idx_lat_lng', columns: {#latitude, #longitude})
|
@TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)')
|
||||||
class RemoteExifEntity extends Table with DriftDefaultsMixin {
|
class RemoteExifEntity extends Table with DriftDefaultsMixin {
|
||||||
const RemoteExifEntity();
|
const RemoteExifEntity();
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -4,7 +4,7 @@ import 'package:immich_mobile/infrastructure/entities/local_asset.entity.drift.d
|
||||||
import 'package:immich_mobile/infrastructure/utils/asset.mixin.dart';
|
import 'package:immich_mobile/infrastructure/utils/asset.mixin.dart';
|
||||||
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
||||||
|
|
||||||
@TableIndex(name: 'idx_local_asset_checksum', columns: {#checksum})
|
@TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_local_asset_checksum ON local_asset_entity (checksum)')
|
||||||
class LocalAssetEntity extends Table with DriftDefaultsMixin, AssetEntityMixin {
|
class LocalAssetEntity extends Table with DriftDefaultsMixin, AssetEntityMixin {
|
||||||
const LocalAssetEntity();
|
const LocalAssetEntity();
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -5,7 +5,9 @@ import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
||||||
import 'package:immich_mobile/infrastructure/utils/asset.mixin.dart';
|
import 'package:immich_mobile/infrastructure/utils/asset.mixin.dart';
|
||||||
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
||||||
|
|
||||||
@TableIndex(name: 'idx_remote_asset_owner_checksum', columns: {#ownerId, #checksum})
|
@TableIndex.sql(
|
||||||
|
'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)',
|
||||||
|
)
|
||||||
@TableIndex.sql('''
|
@TableIndex.sql('''
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum
|
CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_checksum
|
||||||
ON remote_asset_entity (owner_id, checksum)
|
ON remote_asset_entity (owner_id, checksum)
|
||||||
|
|
@ -16,7 +18,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_library_checksum
|
||||||
ON remote_asset_entity (owner_id, library_id, checksum)
|
ON remote_asset_entity (owner_id, library_id, checksum)
|
||||||
WHERE (library_id IS NOT NULL);
|
WHERE (library_id IS NOT NULL);
|
||||||
''')
|
''')
|
||||||
@TableIndex(name: 'idx_remote_asset_checksum', columns: {#checksum})
|
@TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)')
|
||||||
class RemoteAssetEntity extends Table with DriftDefaultsMixin, AssetEntityMixin {
|
class RemoteAssetEntity extends Table with DriftDefaultsMixin, AssetEntityMixin {
|
||||||
const RemoteAssetEntity();
|
const RemoteAssetEntity();
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -106,10 +106,13 @@ class Drift extends $Drift implements IDatabaseRepository {
|
||||||
from5To6: (m, v6) async {
|
from5To6: (m, v6) async {
|
||||||
// Drops the (checksum, ownerId) and adds it back as (ownerId, checksum)
|
// Drops the (checksum, ownerId) and adds it back as (ownerId, checksum)
|
||||||
await customStatement('DROP INDEX IF EXISTS UQ_remote_asset_owner_checksum');
|
await customStatement('DROP INDEX IF EXISTS UQ_remote_asset_owner_checksum');
|
||||||
|
await m.drop(v6.idxRemoteAssetOwnerChecksum);
|
||||||
await m.create(v6.idxRemoteAssetOwnerChecksum);
|
await m.create(v6.idxRemoteAssetOwnerChecksum);
|
||||||
// Adds libraryId to remote_asset_entity
|
// Adds libraryId to remote_asset_entity
|
||||||
await m.addColumn(v6.remoteAssetEntity, v6.remoteAssetEntity.libraryId);
|
await m.addColumn(v6.remoteAssetEntity, v6.remoteAssetEntity.libraryId);
|
||||||
|
await m.drop(v6.uQRemoteAssetsOwnerChecksum);
|
||||||
await m.create(v6.uQRemoteAssetsOwnerChecksum);
|
await m.create(v6.uQRemoteAssetsOwnerChecksum);
|
||||||
|
await m.drop(v6.uQRemoteAssetsOwnerLibraryChecksum);
|
||||||
await m.create(v6.uQRemoteAssetsOwnerLibraryChecksum);
|
await m.create(v6.uQRemoteAssetsOwnerLibraryChecksum);
|
||||||
},
|
},
|
||||||
from6To7: (m, v7) async {
|
from6To7: (m, v7) async {
|
||||||
|
|
|
||||||
Binary file not shown.
BIN
mobile/test/drift/main/generated/schema_v7.dart
generated
BIN
mobile/test/drift/main/generated/schema_v7.dart
generated
Binary file not shown.
Loading…
Reference in a new issue