mirror of
https://github.com/immich-app/immich.git
synced 2025-07-31 15:08:44 -04:00
fix: remove foreign constraint on stack.primaryAssetId (#20052)
* fix: remove foreign constraint in stack.primaryAssetId * fix migration --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
5fc4393e7a
commit
1dc62fce5f
1
mobile/drift_schemas/main/drift_schema_v3.json
generated
Normal file
1
mobile/drift_schemas/main/drift_schema_v3.json
generated
Normal file
File diff suppressed because one or more lines are too long
@ -1,5 +1,4 @@
|
|||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart';
|
|
||||||
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
||||||
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ class StackEntity extends Table with DriftDefaultsMixin {
|
|||||||
TextColumn get ownerId =>
|
TextColumn get ownerId =>
|
||||||
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
|
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
|
||||||
|
|
||||||
TextColumn get primaryAssetId => text().references(RemoteAssetEntity, #id)();
|
TextColumn get primaryAssetId => text()();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Set<Column> get primaryKey => {id};
|
Set<Column> get primaryKey => {id};
|
||||||
|
@ -8,8 +8,6 @@ import 'package:drift/src/runtime/query_builder/query_builder.dart' as i3;
|
|||||||
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart'
|
||||||
as i4;
|
as i4;
|
||||||
import 'package:drift/internal/modular.dart' as i5;
|
import 'package:drift/internal/modular.dart' as i5;
|
||||||
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.dart'
|
|
||||||
as i6;
|
|
||||||
|
|
||||||
typedef $$StackEntityTableCreateCompanionBuilder = i1.StackEntityCompanion
|
typedef $$StackEntityTableCreateCompanionBuilder = i1.StackEntityCompanion
|
||||||
Function({
|
Function({
|
||||||
@ -57,33 +55,6 @@ final class $$StackEntityTableReferences extends i0.BaseReferences<
|
|||||||
return i0.ProcessedTableManager(
|
return i0.ProcessedTableManager(
|
||||||
manager.$state.copyWith(prefetchedData: [item]));
|
manager.$state.copyWith(prefetchedData: [item]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static i6.$RemoteAssetEntityTable _primaryAssetIdTable(
|
|
||||||
i0.GeneratedDatabase db) =>
|
|
||||||
i5.ReadDatabaseContainer(db)
|
|
||||||
.resultSet<i6.$RemoteAssetEntityTable>('remote_asset_entity')
|
|
||||||
.createAlias(i0.$_aliasNameGenerator(
|
|
||||||
i5.ReadDatabaseContainer(db)
|
|
||||||
.resultSet<i1.$StackEntityTable>('stack_entity')
|
|
||||||
.primaryAssetId,
|
|
||||||
i5.ReadDatabaseContainer(db)
|
|
||||||
.resultSet<i6.$RemoteAssetEntityTable>('remote_asset_entity')
|
|
||||||
.id));
|
|
||||||
|
|
||||||
i6.$$RemoteAssetEntityTableProcessedTableManager get primaryAssetId {
|
|
||||||
final $_column = $_itemColumn<String>('primary_asset_id')!;
|
|
||||||
|
|
||||||
final manager = i6
|
|
||||||
.$$RemoteAssetEntityTableTableManager(
|
|
||||||
$_db,
|
|
||||||
i5.ReadDatabaseContainer($_db)
|
|
||||||
.resultSet<i6.$RemoteAssetEntityTable>('remote_asset_entity'))
|
|
||||||
.filter((f) => f.id.sqlEquals($_column));
|
|
||||||
final item = $_typedResult.readTableOrNull(_primaryAssetIdTable($_db));
|
|
||||||
if (item == null) return manager;
|
|
||||||
return i0.ProcessedTableManager(
|
|
||||||
manager.$state.copyWith(prefetchedData: [item]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$StackEntityTableFilterComposer
|
class $$StackEntityTableFilterComposer
|
||||||
@ -104,6 +75,10 @@ class $$StackEntityTableFilterComposer
|
|||||||
i0.ColumnFilters<DateTime> get updatedAt => $composableBuilder(
|
i0.ColumnFilters<DateTime> get updatedAt => $composableBuilder(
|
||||||
column: $table.updatedAt, builder: (column) => i0.ColumnFilters(column));
|
column: $table.updatedAt, builder: (column) => i0.ColumnFilters(column));
|
||||||
|
|
||||||
|
i0.ColumnFilters<String> get primaryAssetId => $composableBuilder(
|
||||||
|
column: $table.primaryAssetId,
|
||||||
|
builder: (column) => i0.ColumnFilters(column));
|
||||||
|
|
||||||
i4.$$UserEntityTableFilterComposer get ownerId {
|
i4.$$UserEntityTableFilterComposer get ownerId {
|
||||||
final i4.$$UserEntityTableFilterComposer composer = $composerBuilder(
|
final i4.$$UserEntityTableFilterComposer composer = $composerBuilder(
|
||||||
composer: this,
|
composer: this,
|
||||||
@ -125,28 +100,6 @@ class $$StackEntityTableFilterComposer
|
|||||||
));
|
));
|
||||||
return composer;
|
return composer;
|
||||||
}
|
}
|
||||||
|
|
||||||
i6.$$RemoteAssetEntityTableFilterComposer get primaryAssetId {
|
|
||||||
final i6.$$RemoteAssetEntityTableFilterComposer composer = $composerBuilder(
|
|
||||||
composer: this,
|
|
||||||
getCurrentColumn: (t) => t.primaryAssetId,
|
|
||||||
referencedTable: i5.ReadDatabaseContainer($db)
|
|
||||||
.resultSet<i6.$RemoteAssetEntityTable>('remote_asset_entity'),
|
|
||||||
getReferencedColumn: (t) => t.id,
|
|
||||||
builder: (joinBuilder,
|
|
||||||
{$addJoinBuilderToRootComposer,
|
|
||||||
$removeJoinBuilderFromRootComposer}) =>
|
|
||||||
i6.$$RemoteAssetEntityTableFilterComposer(
|
|
||||||
$db: $db,
|
|
||||||
$table: i5.ReadDatabaseContainer($db)
|
|
||||||
.resultSet<i6.$RemoteAssetEntityTable>('remote_asset_entity'),
|
|
||||||
$addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer,
|
|
||||||
joinBuilder: joinBuilder,
|
|
||||||
$removeJoinBuilderFromRootComposer:
|
|
||||||
$removeJoinBuilderFromRootComposer,
|
|
||||||
));
|
|
||||||
return composer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$StackEntityTableOrderingComposer
|
class $$StackEntityTableOrderingComposer
|
||||||
@ -169,6 +122,10 @@ class $$StackEntityTableOrderingComposer
|
|||||||
column: $table.updatedAt,
|
column: $table.updatedAt,
|
||||||
builder: (column) => i0.ColumnOrderings(column));
|
builder: (column) => i0.ColumnOrderings(column));
|
||||||
|
|
||||||
|
i0.ColumnOrderings<String> get primaryAssetId => $composableBuilder(
|
||||||
|
column: $table.primaryAssetId,
|
||||||
|
builder: (column) => i0.ColumnOrderings(column));
|
||||||
|
|
||||||
i4.$$UserEntityTableOrderingComposer get ownerId {
|
i4.$$UserEntityTableOrderingComposer get ownerId {
|
||||||
final i4.$$UserEntityTableOrderingComposer composer = $composerBuilder(
|
final i4.$$UserEntityTableOrderingComposer composer = $composerBuilder(
|
||||||
composer: this,
|
composer: this,
|
||||||
@ -190,30 +147,6 @@ class $$StackEntityTableOrderingComposer
|
|||||||
));
|
));
|
||||||
return composer;
|
return composer;
|
||||||
}
|
}
|
||||||
|
|
||||||
i6.$$RemoteAssetEntityTableOrderingComposer get primaryAssetId {
|
|
||||||
final i6.$$RemoteAssetEntityTableOrderingComposer composer =
|
|
||||||
$composerBuilder(
|
|
||||||
composer: this,
|
|
||||||
getCurrentColumn: (t) => t.primaryAssetId,
|
|
||||||
referencedTable: i5.ReadDatabaseContainer($db)
|
|
||||||
.resultSet<i6.$RemoteAssetEntityTable>('remote_asset_entity'),
|
|
||||||
getReferencedColumn: (t) => t.id,
|
|
||||||
builder: (joinBuilder,
|
|
||||||
{$addJoinBuilderToRootComposer,
|
|
||||||
$removeJoinBuilderFromRootComposer}) =>
|
|
||||||
i6.$$RemoteAssetEntityTableOrderingComposer(
|
|
||||||
$db: $db,
|
|
||||||
$table: i5.ReadDatabaseContainer($db)
|
|
||||||
.resultSet<i6.$RemoteAssetEntityTable>(
|
|
||||||
'remote_asset_entity'),
|
|
||||||
$addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer,
|
|
||||||
joinBuilder: joinBuilder,
|
|
||||||
$removeJoinBuilderFromRootComposer:
|
|
||||||
$removeJoinBuilderFromRootComposer,
|
|
||||||
));
|
|
||||||
return composer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$StackEntityTableAnnotationComposer
|
class $$StackEntityTableAnnotationComposer
|
||||||
@ -234,6 +167,9 @@ class $$StackEntityTableAnnotationComposer
|
|||||||
i0.GeneratedColumn<DateTime> get updatedAt =>
|
i0.GeneratedColumn<DateTime> get updatedAt =>
|
||||||
$composableBuilder(column: $table.updatedAt, builder: (column) => column);
|
$composableBuilder(column: $table.updatedAt, builder: (column) => column);
|
||||||
|
|
||||||
|
i0.GeneratedColumn<String> get primaryAssetId => $composableBuilder(
|
||||||
|
column: $table.primaryAssetId, builder: (column) => column);
|
||||||
|
|
||||||
i4.$$UserEntityTableAnnotationComposer get ownerId {
|
i4.$$UserEntityTableAnnotationComposer get ownerId {
|
||||||
final i4.$$UserEntityTableAnnotationComposer composer = $composerBuilder(
|
final i4.$$UserEntityTableAnnotationComposer composer = $composerBuilder(
|
||||||
composer: this,
|
composer: this,
|
||||||
@ -255,30 +191,6 @@ class $$StackEntityTableAnnotationComposer
|
|||||||
));
|
));
|
||||||
return composer;
|
return composer;
|
||||||
}
|
}
|
||||||
|
|
||||||
i6.$$RemoteAssetEntityTableAnnotationComposer get primaryAssetId {
|
|
||||||
final i6.$$RemoteAssetEntityTableAnnotationComposer composer =
|
|
||||||
$composerBuilder(
|
|
||||||
composer: this,
|
|
||||||
getCurrentColumn: (t) => t.primaryAssetId,
|
|
||||||
referencedTable: i5.ReadDatabaseContainer($db)
|
|
||||||
.resultSet<i6.$RemoteAssetEntityTable>('remote_asset_entity'),
|
|
||||||
getReferencedColumn: (t) => t.id,
|
|
||||||
builder: (joinBuilder,
|
|
||||||
{$addJoinBuilderToRootComposer,
|
|
||||||
$removeJoinBuilderFromRootComposer}) =>
|
|
||||||
i6.$$RemoteAssetEntityTableAnnotationComposer(
|
|
||||||
$db: $db,
|
|
||||||
$table: i5.ReadDatabaseContainer($db)
|
|
||||||
.resultSet<i6.$RemoteAssetEntityTable>(
|
|
||||||
'remote_asset_entity'),
|
|
||||||
$addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer,
|
|
||||||
joinBuilder: joinBuilder,
|
|
||||||
$removeJoinBuilderFromRootComposer:
|
|
||||||
$removeJoinBuilderFromRootComposer,
|
|
||||||
));
|
|
||||||
return composer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$StackEntityTableTableManager extends i0.RootTableManager<
|
class $$StackEntityTableTableManager extends i0.RootTableManager<
|
||||||
@ -292,7 +204,7 @@ class $$StackEntityTableTableManager extends i0.RootTableManager<
|
|||||||
$$StackEntityTableUpdateCompanionBuilder,
|
$$StackEntityTableUpdateCompanionBuilder,
|
||||||
(i1.StackEntityData, i1.$$StackEntityTableReferences),
|
(i1.StackEntityData, i1.$$StackEntityTableReferences),
|
||||||
i1.StackEntityData,
|
i1.StackEntityData,
|
||||||
i0.PrefetchHooks Function({bool ownerId, bool primaryAssetId})> {
|
i0.PrefetchHooks Function({bool ownerId})> {
|
||||||
$$StackEntityTableTableManager(
|
$$StackEntityTableTableManager(
|
||||||
i0.GeneratedDatabase db, i1.$StackEntityTable table)
|
i0.GeneratedDatabase db, i1.$StackEntityTable table)
|
||||||
: super(i0.TableManagerState(
|
: super(i0.TableManagerState(
|
||||||
@ -338,7 +250,7 @@ class $$StackEntityTableTableManager extends i0.RootTableManager<
|
|||||||
i1.$$StackEntityTableReferences(db, table, e)
|
i1.$$StackEntityTableReferences(db, table, e)
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
prefetchHooksCallback: ({ownerId = false, primaryAssetId = false}) {
|
prefetchHooksCallback: ({ownerId = false}) {
|
||||||
return i0.PrefetchHooks(
|
return i0.PrefetchHooks(
|
||||||
db: db,
|
db: db,
|
||||||
explicitlyWatchedTables: [],
|
explicitlyWatchedTables: [],
|
||||||
@ -365,17 +277,6 @@ class $$StackEntityTableTableManager extends i0.RootTableManager<
|
|||||||
i1.$$StackEntityTableReferences._ownerIdTable(db).id,
|
i1.$$StackEntityTableReferences._ownerIdTable(db).id,
|
||||||
) as T;
|
) as T;
|
||||||
}
|
}
|
||||||
if (primaryAssetId) {
|
|
||||||
state = state.withJoin(
|
|
||||||
currentTable: table,
|
|
||||||
currentColumn: table.primaryAssetId,
|
|
||||||
referencedTable: i1.$$StackEntityTableReferences
|
|
||||||
._primaryAssetIdTable(db),
|
|
||||||
referencedColumn: i1.$$StackEntityTableReferences
|
|
||||||
._primaryAssetIdTable(db)
|
|
||||||
.id,
|
|
||||||
) as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
},
|
},
|
||||||
@ -398,7 +299,7 @@ typedef $$StackEntityTableProcessedTableManager = i0.ProcessedTableManager<
|
|||||||
$$StackEntityTableUpdateCompanionBuilder,
|
$$StackEntityTableUpdateCompanionBuilder,
|
||||||
(i1.StackEntityData, i1.$$StackEntityTableReferences),
|
(i1.StackEntityData, i1.$$StackEntityTableReferences),
|
||||||
i1.StackEntityData,
|
i1.StackEntityData,
|
||||||
i0.PrefetchHooks Function({bool ownerId, bool primaryAssetId})>;
|
i0.PrefetchHooks Function({bool ownerId})>;
|
||||||
|
|
||||||
class $StackEntityTable extends i2.StackEntity
|
class $StackEntityTable extends i2.StackEntity
|
||||||
with i0.TableInfo<$StackEntityTable, i1.StackEntityData> {
|
with i0.TableInfo<$StackEntityTable, i1.StackEntityData> {
|
||||||
@ -440,12 +341,8 @@ class $StackEntityTable extends i2.StackEntity
|
|||||||
const i0.VerificationMeta('primaryAssetId');
|
const i0.VerificationMeta('primaryAssetId');
|
||||||
@override
|
@override
|
||||||
late final i0.GeneratedColumn<String> primaryAssetId =
|
late final i0.GeneratedColumn<String> primaryAssetId =
|
||||||
i0.GeneratedColumn<String>(
|
i0.GeneratedColumn<String>('primary_asset_id', aliasedName, false,
|
||||||
'primary_asset_id', aliasedName, false,
|
type: i0.DriftSqlType.string, requiredDuringInsert: true);
|
||||||
type: i0.DriftSqlType.string,
|
|
||||||
requiredDuringInsert: true,
|
|
||||||
defaultConstraints: i0.GeneratedColumn.constraintIsAlways(
|
|
||||||
'REFERENCES remote_asset_entity (id)'));
|
|
||||||
@override
|
@override
|
||||||
List<i0.GeneratedColumn> get $columns =>
|
List<i0.GeneratedColumn> get $columns =>
|
||||||
[id, createdAt, updatedAt, ownerId, primaryAssetId];
|
[id, createdAt, updatedAt, ownerId, primaryAssetId];
|
||||||
|
@ -72,7 +72,7 @@ class Drift extends $Drift implements IDatabaseRepository {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get schemaVersion => 2;
|
int get schemaVersion => 3;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
MigrationStrategy get migration => MigrationStrategy(
|
MigrationStrategy get migration => MigrationStrategy(
|
||||||
@ -84,12 +84,16 @@ class Drift extends $Drift implements IDatabaseRepository {
|
|||||||
from: from,
|
from: from,
|
||||||
to: to,
|
to: to,
|
||||||
steps: migrationSteps(
|
steps: migrationSteps(
|
||||||
from1To2: (m, _) async {
|
from1To2: (m, v2) async {
|
||||||
for (final entity in allSchemaEntities) {
|
for (final entity in v2.entities) {
|
||||||
await m.drop(entity);
|
await m.drop(entity);
|
||||||
await m.create(entity);
|
await m.create(entity);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
from2To3: (m, v3) async {
|
||||||
|
// Removed foreign key constraint on stack.primaryAssetId
|
||||||
|
await m.alterTable(TableMigration(v3.stackEntity));
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -919,8 +919,356 @@ i1.GeneratedColumn<String> _column_73(String aliasedName) =>
|
|||||||
i1.GeneratedColumn<DateTime> _column_74(String aliasedName) =>
|
i1.GeneratedColumn<DateTime> _column_74(String aliasedName) =>
|
||||||
i1.GeneratedColumn<DateTime>('birth_date', aliasedName, true,
|
i1.GeneratedColumn<DateTime>('birth_date', aliasedName, true,
|
||||||
type: i1.DriftSqlType.dateTime);
|
type: i1.DriftSqlType.dateTime);
|
||||||
|
|
||||||
|
final class Schema3 extends i0.VersionedSchema {
|
||||||
|
Schema3({required super.database}) : super(version: 3);
|
||||||
|
@override
|
||||||
|
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||||
|
userEntity,
|
||||||
|
remoteAssetEntity,
|
||||||
|
localAssetEntity,
|
||||||
|
stackEntity,
|
||||||
|
idxLocalAssetChecksum,
|
||||||
|
uQRemoteAssetOwnerChecksum,
|
||||||
|
idxRemoteAssetChecksum,
|
||||||
|
userMetadataEntity,
|
||||||
|
partnerEntity,
|
||||||
|
localAlbumEntity,
|
||||||
|
localAlbumAssetEntity,
|
||||||
|
remoteExifEntity,
|
||||||
|
remoteAlbumEntity,
|
||||||
|
remoteAlbumAssetEntity,
|
||||||
|
remoteAlbumUserEntity,
|
||||||
|
memoryEntity,
|
||||||
|
memoryAssetEntity,
|
||||||
|
personEntity,
|
||||||
|
];
|
||||||
|
late final Shape0 userEntity = Shape0(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'user_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_1,
|
||||||
|
_column_2,
|
||||||
|
_column_3,
|
||||||
|
_column_4,
|
||||||
|
_column_5,
|
||||||
|
_column_6,
|
||||||
|
_column_7,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape1 remoteAssetEntity = Shape1(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'remote_asset_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_1,
|
||||||
|
_column_8,
|
||||||
|
_column_9,
|
||||||
|
_column_5,
|
||||||
|
_column_10,
|
||||||
|
_column_11,
|
||||||
|
_column_12,
|
||||||
|
_column_0,
|
||||||
|
_column_13,
|
||||||
|
_column_14,
|
||||||
|
_column_15,
|
||||||
|
_column_16,
|
||||||
|
_column_17,
|
||||||
|
_column_18,
|
||||||
|
_column_19,
|
||||||
|
_column_20,
|
||||||
|
_column_21,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape2 localAssetEntity = Shape2(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'local_asset_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_1,
|
||||||
|
_column_8,
|
||||||
|
_column_9,
|
||||||
|
_column_5,
|
||||||
|
_column_10,
|
||||||
|
_column_11,
|
||||||
|
_column_12,
|
||||||
|
_column_0,
|
||||||
|
_column_22,
|
||||||
|
_column_14,
|
||||||
|
_column_23,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape3 stackEntity = Shape3(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'stack_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_9,
|
||||||
|
_column_5,
|
||||||
|
_column_15,
|
||||||
|
_column_75,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
final i1.Index idxLocalAssetChecksum = i1.Index('idx_local_asset_checksum',
|
||||||
|
'CREATE INDEX idx_local_asset_checksum ON local_asset_entity (checksum)');
|
||||||
|
final i1.Index uQRemoteAssetOwnerChecksum = i1.Index(
|
||||||
|
'UQ_remote_asset_owner_checksum',
|
||||||
|
'CREATE UNIQUE INDEX UQ_remote_asset_owner_checksum ON remote_asset_entity (checksum, owner_id)');
|
||||||
|
final i1.Index idxRemoteAssetChecksum = i1.Index('idx_remote_asset_checksum',
|
||||||
|
'CREATE INDEX idx_remote_asset_checksum ON remote_asset_entity (checksum)');
|
||||||
|
late final Shape4 userMetadataEntity = Shape4(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'user_metadata_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(user_id, "key")',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_25,
|
||||||
|
_column_26,
|
||||||
|
_column_27,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape5 partnerEntity = Shape5(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'partner_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(shared_by_id, shared_with_id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_28,
|
||||||
|
_column_29,
|
||||||
|
_column_30,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape6 localAlbumEntity = Shape6(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'local_album_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_1,
|
||||||
|
_column_5,
|
||||||
|
_column_31,
|
||||||
|
_column_32,
|
||||||
|
_column_33,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape7 localAlbumAssetEntity = Shape7(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'local_album_asset_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(asset_id, album_id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_34,
|
||||||
|
_column_35,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape8 remoteExifEntity = Shape8(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'remote_exif_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(asset_id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_36,
|
||||||
|
_column_37,
|
||||||
|
_column_38,
|
||||||
|
_column_39,
|
||||||
|
_column_40,
|
||||||
|
_column_41,
|
||||||
|
_column_11,
|
||||||
|
_column_10,
|
||||||
|
_column_42,
|
||||||
|
_column_43,
|
||||||
|
_column_44,
|
||||||
|
_column_45,
|
||||||
|
_column_46,
|
||||||
|
_column_47,
|
||||||
|
_column_48,
|
||||||
|
_column_49,
|
||||||
|
_column_50,
|
||||||
|
_column_51,
|
||||||
|
_column_52,
|
||||||
|
_column_53,
|
||||||
|
_column_54,
|
||||||
|
_column_55,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape9 remoteAlbumEntity = Shape9(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'remote_album_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_1,
|
||||||
|
_column_56,
|
||||||
|
_column_9,
|
||||||
|
_column_5,
|
||||||
|
_column_15,
|
||||||
|
_column_57,
|
||||||
|
_column_58,
|
||||||
|
_column_59,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape7 remoteAlbumAssetEntity = Shape7(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'remote_album_asset_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(asset_id, album_id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_36,
|
||||||
|
_column_60,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape10 remoteAlbumUserEntity = Shape10(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'remote_album_user_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(album_id, user_id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_60,
|
||||||
|
_column_25,
|
||||||
|
_column_61,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape11 memoryEntity = Shape11(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'memory_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_9,
|
||||||
|
_column_5,
|
||||||
|
_column_18,
|
||||||
|
_column_15,
|
||||||
|
_column_8,
|
||||||
|
_column_62,
|
||||||
|
_column_63,
|
||||||
|
_column_64,
|
||||||
|
_column_65,
|
||||||
|
_column_66,
|
||||||
|
_column_67,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape12 memoryAssetEntity = Shape12(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'memory_asset_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(asset_id, memory_id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_36,
|
||||||
|
_column_68,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape13 personEntity = Shape13(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'person_entity',
|
||||||
|
withoutRowId: true,
|
||||||
|
isStrict: true,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_9,
|
||||||
|
_column_5,
|
||||||
|
_column_15,
|
||||||
|
_column_1,
|
||||||
|
_column_69,
|
||||||
|
_column_70,
|
||||||
|
_column_71,
|
||||||
|
_column_72,
|
||||||
|
_column_73,
|
||||||
|
_column_74,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<String> _column_75(String aliasedName) =>
|
||||||
|
i1.GeneratedColumn<String>('primary_asset_id', aliasedName, false,
|
||||||
|
type: i1.DriftSqlType.string);
|
||||||
i0.MigrationStepWithVersion migrationSteps({
|
i0.MigrationStepWithVersion migrationSteps({
|
||||||
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
||||||
|
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
|
||||||
}) {
|
}) {
|
||||||
return (currentVersion, database) async {
|
return (currentVersion, database) async {
|
||||||
switch (currentVersion) {
|
switch (currentVersion) {
|
||||||
@ -929,6 +1277,11 @@ i0.MigrationStepWithVersion migrationSteps({
|
|||||||
final migrator = i1.Migrator(database, schema);
|
final migrator = i1.Migrator(database, schema);
|
||||||
await from1To2(migrator, schema);
|
await from1To2(migrator, schema);
|
||||||
return 2;
|
return 2;
|
||||||
|
case 2:
|
||||||
|
final schema = Schema3(database: database);
|
||||||
|
final migrator = i1.Migrator(database, schema);
|
||||||
|
await from2To3(migrator, schema);
|
||||||
|
return 3;
|
||||||
default:
|
default:
|
||||||
throw ArgumentError.value('Unknown migration from $currentVersion');
|
throw ArgumentError.value('Unknown migration from $currentVersion');
|
||||||
}
|
}
|
||||||
@ -937,8 +1290,10 @@ i0.MigrationStepWithVersion migrationSteps({
|
|||||||
|
|
||||||
i1.OnUpgrade stepByStep({
|
i1.OnUpgrade stepByStep({
|
||||||
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
||||||
|
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
|
||||||
}) =>
|
}) =>
|
||||||
i0.VersionedSchema.stepByStepHelper(
|
i0.VersionedSchema.stepByStepHelper(
|
||||||
step: migrationSteps(
|
step: migrationSteps(
|
||||||
from1To2: from1To2,
|
from1To2: from1To2,
|
||||||
|
from2To3: from2To3,
|
||||||
));
|
));
|
||||||
|
@ -193,7 +193,7 @@ class RemoteAssetRepository extends DriftDatabaseRepository {
|
|||||||
Future<void> stack(String userId, StackResponse stack) {
|
Future<void> stack(String userId, StackResponse stack) {
|
||||||
return _db.transaction(() async {
|
return _db.transaction(() async {
|
||||||
final stackIds = await _db.managers.stackEntity
|
final stackIds = await _db.managers.stackEntity
|
||||||
.filter((row) => row.primaryAssetId.id.isIn(stack.assetIds))
|
.filter((row) => row.primaryAssetId.isIn(stack.assetIds))
|
||||||
.map((row) => row.id)
|
.map((row) => row.id)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import 'package:drift/drift.dart';
|
|||||||
import 'package:drift/internal/migrations.dart';
|
import 'package:drift/internal/migrations.dart';
|
||||||
import 'schema_v1.dart' as v1;
|
import 'schema_v1.dart' as v1;
|
||||||
import 'schema_v2.dart' as v2;
|
import 'schema_v2.dart' as v2;
|
||||||
|
import 'schema_v3.dart' as v3;
|
||||||
|
|
||||||
class GeneratedHelper implements SchemaInstantiationHelper {
|
class GeneratedHelper implements SchemaInstantiationHelper {
|
||||||
@override
|
@override
|
||||||
@ -14,10 +15,12 @@ class GeneratedHelper implements SchemaInstantiationHelper {
|
|||||||
return v1.DatabaseAtV1(db);
|
return v1.DatabaseAtV1(db);
|
||||||
case 2:
|
case 2:
|
||||||
return v2.DatabaseAtV2(db);
|
return v2.DatabaseAtV2(db);
|
||||||
|
case 3:
|
||||||
|
return v3.DatabaseAtV3(db);
|
||||||
default:
|
default:
|
||||||
throw MissingSchemaException(version, versions);
|
throw MissingSchemaException(version, versions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const versions = const [1, 2];
|
static const versions = const [1, 2, 3];
|
||||||
}
|
}
|
||||||
|
5136
mobile/test/drift/main/generated/schema_v3.dart
Normal file
5136
mobile/test/drift/main/generated/schema_v3.dart
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user