mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +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 22 additions and 17 deletions
|
|
@ -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 {
|
||||
const RemoteExifEntity();
|
||||
|
||||
|
|
|
|||
|
|
@ -701,7 +701,7 @@ typedef $$RemoteExifEntityTableProcessedTableManager =
|
|||
>;
|
||||
i0.Index get idxLatLng => i0.Index(
|
||||
'idx_lat_lng',
|
||||
'CREATE INDEX idx_lat_lng ON remote_exif_entity (latitude, longitude)',
|
||||
'CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)',
|
||||
);
|
||||
|
||||
class $RemoteExifEntityTable extends i2.RemoteExifEntity
|
||||
|
|
|
|||
|
|
@ -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/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 {
|
||||
const LocalAssetEntity();
|
||||
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ typedef $$LocalAssetEntityTableProcessedTableManager =
|
|||
>;
|
||||
i0.Index get idxLocalAssetChecksum => i0.Index(
|
||||
'idx_local_asset_checksum',
|
||||
'CREATE INDEX idx_local_asset_checksum ON local_asset_entity (checksum)',
|
||||
'CREATE INDEX IF NOT EXISTS idx_local_asset_checksum ON local_asset_entity (checksum)',
|
||||
);
|
||||
|
||||
class $LocalAssetEntityTable extends i3.LocalAssetEntity
|
||||
|
|
|
|||
|
|
@ -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/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('''
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS UQ_remote_assets_owner_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)
|
||||
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 {
|
||||
const RemoteAssetEntity();
|
||||
|
||||
|
|
|
|||
|
|
@ -628,7 +628,7 @@ typedef $$RemoteAssetEntityTableProcessedTableManager =
|
|||
>;
|
||||
i0.Index get idxRemoteAssetOwnerChecksum => i0.Index(
|
||||
'idx_remote_asset_owner_checksum',
|
||||
'CREATE INDEX idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)',
|
||||
'CREATE INDEX IF NOT EXISTS idx_remote_asset_owner_checksum ON remote_asset_entity (owner_id, checksum)',
|
||||
);
|
||||
|
||||
class $RemoteAssetEntityTable extends i3.RemoteAssetEntity
|
||||
|
|
@ -1641,5 +1641,5 @@ i0.Index get uQRemoteAssetsOwnerLibraryChecksum => i0.Index(
|
|||
);
|
||||
i0.Index get idxRemoteAssetChecksum => i0.Index(
|
||||
'idx_remote_asset_checksum',
|
||||
'CREATE INDEX idx_remote_asset_checksum ON remote_asset_entity (checksum)',
|
||||
'CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)',
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue