mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat: show stacks in asset viewer (#19935)
* feat: show stacks in asset viewer * fix: global key issue and flash on stack asset change * feat(mobile): stack and unstack action (#19941) * feat(mobile): stack and unstack action * add custom model * use stackId from ActionSource * Update mobile/lib/providers/infrastructure/action.provider.dart Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> --------- Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> * fix: lint * fix: bad merge * fix: test --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com> Co-authored-by: Daimolean <92239625+wuzihao051119@users.noreply.github.com> Co-authored-by: wuzihao051119 <wuzihao051119@outlook.com>
This commit is contained in:
parent
546f841b2c
commit
f32cd74232
41 changed files with 1568 additions and 802 deletions
|
|
@ -416,6 +416,9 @@ class RemoteAssetEntity extends Table
|
|||
late final GeneratedColumn<int> visibility = GeneratedColumn<int>(
|
||||
'visibility', aliasedName, false,
|
||||
type: DriftSqlType.int, requiredDuringInsert: true);
|
||||
late final GeneratedColumn<String> stackId = GeneratedColumn<String>(
|
||||
'stack_id', aliasedName, true,
|
||||
type: DriftSqlType.string, requiredDuringInsert: false);
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [
|
||||
name,
|
||||
|
|
@ -433,7 +436,8 @@ class RemoteAssetEntity extends Table
|
|||
thumbHash,
|
||||
deletedAt,
|
||||
livePhotoVideoId,
|
||||
visibility
|
||||
visibility,
|
||||
stackId
|
||||
];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
|
|
@ -478,6 +482,8 @@ class RemoteAssetEntity extends Table
|
|||
DriftSqlType.string, data['${effectivePrefix}live_photo_video_id']),
|
||||
visibility: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}visibility'])!,
|
||||
stackId: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}stack_id']),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -510,6 +516,7 @@ class RemoteAssetEntityData extends DataClass
|
|||
final DateTime? deletedAt;
|
||||
final String? livePhotoVideoId;
|
||||
final int visibility;
|
||||
final String? stackId;
|
||||
const RemoteAssetEntityData(
|
||||
{required this.name,
|
||||
required this.type,
|
||||
|
|
@ -526,7 +533,8 @@ class RemoteAssetEntityData extends DataClass
|
|||
this.thumbHash,
|
||||
this.deletedAt,
|
||||
this.livePhotoVideoId,
|
||||
required this.visibility});
|
||||
required this.visibility,
|
||||
this.stackId});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
|
|
@ -560,6 +568,9 @@ class RemoteAssetEntityData extends DataClass
|
|||
map['live_photo_video_id'] = Variable<String>(livePhotoVideoId);
|
||||
}
|
||||
map['visibility'] = Variable<int>(visibility);
|
||||
if (!nullToAbsent || stackId != null) {
|
||||
map['stack_id'] = Variable<String>(stackId);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
@ -583,6 +594,7 @@ class RemoteAssetEntityData extends DataClass
|
|||
deletedAt: serializer.fromJson<DateTime?>(json['deletedAt']),
|
||||
livePhotoVideoId: serializer.fromJson<String?>(json['livePhotoVideoId']),
|
||||
visibility: serializer.fromJson<int>(json['visibility']),
|
||||
stackId: serializer.fromJson<String?>(json['stackId']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
|
|
@ -605,6 +617,7 @@ class RemoteAssetEntityData extends DataClass
|
|||
'deletedAt': serializer.toJson<DateTime?>(deletedAt),
|
||||
'livePhotoVideoId': serializer.toJson<String?>(livePhotoVideoId),
|
||||
'visibility': serializer.toJson<int>(visibility),
|
||||
'stackId': serializer.toJson<String?>(stackId),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -624,7 +637,8 @@ class RemoteAssetEntityData extends DataClass
|
|||
Value<String?> thumbHash = const Value.absent(),
|
||||
Value<DateTime?> deletedAt = const Value.absent(),
|
||||
Value<String?> livePhotoVideoId = const Value.absent(),
|
||||
int? visibility}) =>
|
||||
int? visibility,
|
||||
Value<String?> stackId = const Value.absent()}) =>
|
||||
RemoteAssetEntityData(
|
||||
name: name ?? this.name,
|
||||
type: type ?? this.type,
|
||||
|
|
@ -647,6 +661,7 @@ class RemoteAssetEntityData extends DataClass
|
|||
? livePhotoVideoId.value
|
||||
: this.livePhotoVideoId,
|
||||
visibility: visibility ?? this.visibility,
|
||||
stackId: stackId.present ? stackId.value : this.stackId,
|
||||
);
|
||||
RemoteAssetEntityData copyWithCompanion(RemoteAssetEntityCompanion data) {
|
||||
return RemoteAssetEntityData(
|
||||
|
|
@ -674,6 +689,7 @@ class RemoteAssetEntityData extends DataClass
|
|||
: this.livePhotoVideoId,
|
||||
visibility:
|
||||
data.visibility.present ? data.visibility.value : this.visibility,
|
||||
stackId: data.stackId.present ? data.stackId.value : this.stackId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -695,7 +711,8 @@ class RemoteAssetEntityData extends DataClass
|
|||
..write('thumbHash: $thumbHash, ')
|
||||
..write('deletedAt: $deletedAt, ')
|
||||
..write('livePhotoVideoId: $livePhotoVideoId, ')
|
||||
..write('visibility: $visibility')
|
||||
..write('visibility: $visibility, ')
|
||||
..write('stackId: $stackId')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
|
@ -717,7 +734,8 @@ class RemoteAssetEntityData extends DataClass
|
|||
thumbHash,
|
||||
deletedAt,
|
||||
livePhotoVideoId,
|
||||
visibility);
|
||||
visibility,
|
||||
stackId);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
|
|
@ -737,7 +755,8 @@ class RemoteAssetEntityData extends DataClass
|
|||
other.thumbHash == this.thumbHash &&
|
||||
other.deletedAt == this.deletedAt &&
|
||||
other.livePhotoVideoId == this.livePhotoVideoId &&
|
||||
other.visibility == this.visibility);
|
||||
other.visibility == this.visibility &&
|
||||
other.stackId == this.stackId);
|
||||
}
|
||||
|
||||
class RemoteAssetEntityCompanion
|
||||
|
|
@ -758,6 +777,7 @@ class RemoteAssetEntityCompanion
|
|||
final Value<DateTime?> deletedAt;
|
||||
final Value<String?> livePhotoVideoId;
|
||||
final Value<int> visibility;
|
||||
final Value<String?> stackId;
|
||||
const RemoteAssetEntityCompanion({
|
||||
this.name = const Value.absent(),
|
||||
this.type = const Value.absent(),
|
||||
|
|
@ -775,6 +795,7 @@ class RemoteAssetEntityCompanion
|
|||
this.deletedAt = const Value.absent(),
|
||||
this.livePhotoVideoId = const Value.absent(),
|
||||
this.visibility = const Value.absent(),
|
||||
this.stackId = const Value.absent(),
|
||||
});
|
||||
RemoteAssetEntityCompanion.insert({
|
||||
required String name,
|
||||
|
|
@ -793,6 +814,7 @@ class RemoteAssetEntityCompanion
|
|||
this.deletedAt = const Value.absent(),
|
||||
this.livePhotoVideoId = const Value.absent(),
|
||||
required int visibility,
|
||||
this.stackId = const Value.absent(),
|
||||
}) : name = Value(name),
|
||||
type = Value(type),
|
||||
id = Value(id),
|
||||
|
|
@ -816,6 +838,7 @@ class RemoteAssetEntityCompanion
|
|||
Expression<DateTime>? deletedAt,
|
||||
Expression<String>? livePhotoVideoId,
|
||||
Expression<int>? visibility,
|
||||
Expression<String>? stackId,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (name != null) 'name': name,
|
||||
|
|
@ -834,6 +857,7 @@ class RemoteAssetEntityCompanion
|
|||
if (deletedAt != null) 'deleted_at': deletedAt,
|
||||
if (livePhotoVideoId != null) 'live_photo_video_id': livePhotoVideoId,
|
||||
if (visibility != null) 'visibility': visibility,
|
||||
if (stackId != null) 'stack_id': stackId,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -853,7 +877,8 @@ class RemoteAssetEntityCompanion
|
|||
Value<String?>? thumbHash,
|
||||
Value<DateTime?>? deletedAt,
|
||||
Value<String?>? livePhotoVideoId,
|
||||
Value<int>? visibility}) {
|
||||
Value<int>? visibility,
|
||||
Value<String?>? stackId}) {
|
||||
return RemoteAssetEntityCompanion(
|
||||
name: name ?? this.name,
|
||||
type: type ?? this.type,
|
||||
|
|
@ -871,6 +896,7 @@ class RemoteAssetEntityCompanion
|
|||
deletedAt: deletedAt ?? this.deletedAt,
|
||||
livePhotoVideoId: livePhotoVideoId ?? this.livePhotoVideoId,
|
||||
visibility: visibility ?? this.visibility,
|
||||
stackId: stackId ?? this.stackId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -925,6 +951,9 @@ class RemoteAssetEntityCompanion
|
|||
if (visibility.present) {
|
||||
map['visibility'] = Variable<int>(visibility.value);
|
||||
}
|
||||
if (stackId.present) {
|
||||
map['stack_id'] = Variable<String>(stackId.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
@ -946,7 +975,8 @@ class RemoteAssetEntityCompanion
|
|||
..write('thumbHash: $thumbHash, ')
|
||||
..write('deletedAt: $deletedAt, ')
|
||||
..write('livePhotoVideoId: $livePhotoVideoId, ')
|
||||
..write('visibility: $visibility')
|
||||
..write('visibility: $visibility, ')
|
||||
..write('stackId: $stackId')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
|
@ -1385,6 +1415,258 @@ class LocalAssetEntityCompanion extends UpdateCompanion<LocalAssetEntityData> {
|
|||
}
|
||||
}
|
||||
|
||||
class StackEntity extends Table with TableInfo<StackEntity, StackEntityData> {
|
||||
@override
|
||||
final GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
StackEntity(this.attachedDatabase, [this._alias]);
|
||||
late final GeneratedColumn<String> id = GeneratedColumn<String>(
|
||||
'id', aliasedName, false,
|
||||
type: DriftSqlType.string, requiredDuringInsert: true);
|
||||
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
||||
'created_at', aliasedName, false,
|
||||
type: DriftSqlType.dateTime,
|
||||
requiredDuringInsert: false,
|
||||
defaultValue: const CustomExpression('CURRENT_TIMESTAMP'));
|
||||
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
||||
'updated_at', aliasedName, false,
|
||||
type: DriftSqlType.dateTime,
|
||||
requiredDuringInsert: false,
|
||||
defaultValue: const CustomExpression('CURRENT_TIMESTAMP'));
|
||||
late final GeneratedColumn<String> ownerId = GeneratedColumn<String>(
|
||||
'owner_id', aliasedName, false,
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: true,
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES user_entity (id) ON DELETE CASCADE'));
|
||||
late final GeneratedColumn<String> primaryAssetId = GeneratedColumn<String>(
|
||||
'primary_asset_id', aliasedName, false,
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: true,
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES remote_asset_entity (id)'));
|
||||
@override
|
||||
List<GeneratedColumn> get $columns =>
|
||||
[id, createdAt, updatedAt, ownerId, primaryAssetId];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'stack_entity';
|
||||
@override
|
||||
Set<GeneratedColumn> get $primaryKey => {id};
|
||||
@override
|
||||
StackEntityData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return StackEntityData(
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}id'])!,
|
||||
createdAt: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
||||
updatedAt: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
||||
ownerId: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}owner_id'])!,
|
||||
primaryAssetId: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string, data['${effectivePrefix}primary_asset_id'])!,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
StackEntity createAlias(String alias) {
|
||||
return StackEntity(attachedDatabase, alias);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get withoutRowId => true;
|
||||
@override
|
||||
bool get isStrict => true;
|
||||
}
|
||||
|
||||
class StackEntityData extends DataClass implements Insertable<StackEntityData> {
|
||||
final String id;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final String ownerId;
|
||||
final String primaryAssetId;
|
||||
const StackEntityData(
|
||||
{required this.id,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.ownerId,
|
||||
required this.primaryAssetId});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<String>(id);
|
||||
map['created_at'] = Variable<DateTime>(createdAt);
|
||||
map['updated_at'] = Variable<DateTime>(updatedAt);
|
||||
map['owner_id'] = Variable<String>(ownerId);
|
||||
map['primary_asset_id'] = Variable<String>(primaryAssetId);
|
||||
return map;
|
||||
}
|
||||
|
||||
factory StackEntityData.fromJson(Map<String, dynamic> json,
|
||||
{ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return StackEntityData(
|
||||
id: serializer.fromJson<String>(json['id']),
|
||||
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
||||
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
||||
ownerId: serializer.fromJson<String>(json['ownerId']),
|
||||
primaryAssetId: serializer.fromJson<String>(json['primaryAssetId']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<String>(id),
|
||||
'createdAt': serializer.toJson<DateTime>(createdAt),
|
||||
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
||||
'ownerId': serializer.toJson<String>(ownerId),
|
||||
'primaryAssetId': serializer.toJson<String>(primaryAssetId),
|
||||
};
|
||||
}
|
||||
|
||||
StackEntityData copyWith(
|
||||
{String? id,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
String? ownerId,
|
||||
String? primaryAssetId}) =>
|
||||
StackEntityData(
|
||||
id: id ?? this.id,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
ownerId: ownerId ?? this.ownerId,
|
||||
primaryAssetId: primaryAssetId ?? this.primaryAssetId,
|
||||
);
|
||||
StackEntityData copyWithCompanion(StackEntityCompanion data) {
|
||||
return StackEntityData(
|
||||
id: data.id.present ? data.id.value : this.id,
|
||||
createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt,
|
||||
updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt,
|
||||
ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId,
|
||||
primaryAssetId: data.primaryAssetId.present
|
||||
? data.primaryAssetId.value
|
||||
: this.primaryAssetId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('StackEntityData(')
|
||||
..write('id: $id, ')
|
||||
..write('createdAt: $createdAt, ')
|
||||
..write('updatedAt: $updatedAt, ')
|
||||
..write('ownerId: $ownerId, ')
|
||||
..write('primaryAssetId: $primaryAssetId')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(id, createdAt, updatedAt, ownerId, primaryAssetId);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is StackEntityData &&
|
||||
other.id == this.id &&
|
||||
other.createdAt == this.createdAt &&
|
||||
other.updatedAt == this.updatedAt &&
|
||||
other.ownerId == this.ownerId &&
|
||||
other.primaryAssetId == this.primaryAssetId);
|
||||
}
|
||||
|
||||
class StackEntityCompanion extends UpdateCompanion<StackEntityData> {
|
||||
final Value<String> id;
|
||||
final Value<DateTime> createdAt;
|
||||
final Value<DateTime> updatedAt;
|
||||
final Value<String> ownerId;
|
||||
final Value<String> primaryAssetId;
|
||||
const StackEntityCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.createdAt = const Value.absent(),
|
||||
this.updatedAt = const Value.absent(),
|
||||
this.ownerId = const Value.absent(),
|
||||
this.primaryAssetId = const Value.absent(),
|
||||
});
|
||||
StackEntityCompanion.insert({
|
||||
required String id,
|
||||
this.createdAt = const Value.absent(),
|
||||
this.updatedAt = const Value.absent(),
|
||||
required String ownerId,
|
||||
required String primaryAssetId,
|
||||
}) : id = Value(id),
|
||||
ownerId = Value(ownerId),
|
||||
primaryAssetId = Value(primaryAssetId);
|
||||
static Insertable<StackEntityData> custom({
|
||||
Expression<String>? id,
|
||||
Expression<DateTime>? createdAt,
|
||||
Expression<DateTime>? updatedAt,
|
||||
Expression<String>? ownerId,
|
||||
Expression<String>? primaryAssetId,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (createdAt != null) 'created_at': createdAt,
|
||||
if (updatedAt != null) 'updated_at': updatedAt,
|
||||
if (ownerId != null) 'owner_id': ownerId,
|
||||
if (primaryAssetId != null) 'primary_asset_id': primaryAssetId,
|
||||
});
|
||||
}
|
||||
|
||||
StackEntityCompanion copyWith(
|
||||
{Value<String>? id,
|
||||
Value<DateTime>? createdAt,
|
||||
Value<DateTime>? updatedAt,
|
||||
Value<String>? ownerId,
|
||||
Value<String>? primaryAssetId}) {
|
||||
return StackEntityCompanion(
|
||||
id: id ?? this.id,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
ownerId: ownerId ?? this.ownerId,
|
||||
primaryAssetId: primaryAssetId ?? this.primaryAssetId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
if (id.present) {
|
||||
map['id'] = Variable<String>(id.value);
|
||||
}
|
||||
if (createdAt.present) {
|
||||
map['created_at'] = Variable<DateTime>(createdAt.value);
|
||||
}
|
||||
if (updatedAt.present) {
|
||||
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
||||
}
|
||||
if (ownerId.present) {
|
||||
map['owner_id'] = Variable<String>(ownerId.value);
|
||||
}
|
||||
if (primaryAssetId.present) {
|
||||
map['primary_asset_id'] = Variable<String>(primaryAssetId.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('StackEntityCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('createdAt: $createdAt, ')
|
||||
..write('updatedAt: $updatedAt, ')
|
||||
..write('ownerId: $ownerId, ')
|
||||
..write('primaryAssetId: $primaryAssetId')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class UserMetadataEntity extends Table
|
||||
with TableInfo<UserMetadataEntity, UserMetadataEntityData> {
|
||||
@override
|
||||
|
|
@ -4363,263 +4645,12 @@ class MemoryAssetEntityCompanion
|
|||
}
|
||||
}
|
||||
|
||||
class StackEntity extends Table with TableInfo<StackEntity, StackEntityData> {
|
||||
@override
|
||||
final GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
StackEntity(this.attachedDatabase, [this._alias]);
|
||||
late final GeneratedColumn<String> id = GeneratedColumn<String>(
|
||||
'id', aliasedName, false,
|
||||
type: DriftSqlType.string, requiredDuringInsert: true);
|
||||
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
||||
'created_at', aliasedName, false,
|
||||
type: DriftSqlType.dateTime,
|
||||
requiredDuringInsert: false,
|
||||
defaultValue: const CustomExpression('CURRENT_TIMESTAMP'));
|
||||
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
||||
'updated_at', aliasedName, false,
|
||||
type: DriftSqlType.dateTime,
|
||||
requiredDuringInsert: false,
|
||||
defaultValue: const CustomExpression('CURRENT_TIMESTAMP'));
|
||||
late final GeneratedColumn<String> ownerId = GeneratedColumn<String>(
|
||||
'owner_id', aliasedName, false,
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: true,
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES user_entity (id) ON DELETE CASCADE'));
|
||||
late final GeneratedColumn<String> primaryAssetId = GeneratedColumn<String>(
|
||||
'primary_asset_id', aliasedName, false,
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: true,
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES remote_asset_entity (id)'));
|
||||
@override
|
||||
List<GeneratedColumn> get $columns =>
|
||||
[id, createdAt, updatedAt, ownerId, primaryAssetId];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'stack_entity';
|
||||
@override
|
||||
Set<GeneratedColumn> get $primaryKey => {id};
|
||||
@override
|
||||
StackEntityData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return StackEntityData(
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}id'])!,
|
||||
createdAt: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
||||
updatedAt: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
||||
ownerId: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}owner_id'])!,
|
||||
primaryAssetId: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string, data['${effectivePrefix}primary_asset_id'])!,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
StackEntity createAlias(String alias) {
|
||||
return StackEntity(attachedDatabase, alias);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get withoutRowId => true;
|
||||
@override
|
||||
bool get isStrict => true;
|
||||
}
|
||||
|
||||
class StackEntityData extends DataClass implements Insertable<StackEntityData> {
|
||||
final String id;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final String ownerId;
|
||||
final String primaryAssetId;
|
||||
const StackEntityData(
|
||||
{required this.id,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.ownerId,
|
||||
required this.primaryAssetId});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<String>(id);
|
||||
map['created_at'] = Variable<DateTime>(createdAt);
|
||||
map['updated_at'] = Variable<DateTime>(updatedAt);
|
||||
map['owner_id'] = Variable<String>(ownerId);
|
||||
map['primary_asset_id'] = Variable<String>(primaryAssetId);
|
||||
return map;
|
||||
}
|
||||
|
||||
factory StackEntityData.fromJson(Map<String, dynamic> json,
|
||||
{ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return StackEntityData(
|
||||
id: serializer.fromJson<String>(json['id']),
|
||||
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
||||
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
||||
ownerId: serializer.fromJson<String>(json['ownerId']),
|
||||
primaryAssetId: serializer.fromJson<String>(json['primaryAssetId']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<String>(id),
|
||||
'createdAt': serializer.toJson<DateTime>(createdAt),
|
||||
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
||||
'ownerId': serializer.toJson<String>(ownerId),
|
||||
'primaryAssetId': serializer.toJson<String>(primaryAssetId),
|
||||
};
|
||||
}
|
||||
|
||||
StackEntityData copyWith(
|
||||
{String? id,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
String? ownerId,
|
||||
String? primaryAssetId}) =>
|
||||
StackEntityData(
|
||||
id: id ?? this.id,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
ownerId: ownerId ?? this.ownerId,
|
||||
primaryAssetId: primaryAssetId ?? this.primaryAssetId,
|
||||
);
|
||||
StackEntityData copyWithCompanion(StackEntityCompanion data) {
|
||||
return StackEntityData(
|
||||
id: data.id.present ? data.id.value : this.id,
|
||||
createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt,
|
||||
updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt,
|
||||
ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId,
|
||||
primaryAssetId: data.primaryAssetId.present
|
||||
? data.primaryAssetId.value
|
||||
: this.primaryAssetId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('StackEntityData(')
|
||||
..write('id: $id, ')
|
||||
..write('createdAt: $createdAt, ')
|
||||
..write('updatedAt: $updatedAt, ')
|
||||
..write('ownerId: $ownerId, ')
|
||||
..write('primaryAssetId: $primaryAssetId')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(id, createdAt, updatedAt, ownerId, primaryAssetId);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is StackEntityData &&
|
||||
other.id == this.id &&
|
||||
other.createdAt == this.createdAt &&
|
||||
other.updatedAt == this.updatedAt &&
|
||||
other.ownerId == this.ownerId &&
|
||||
other.primaryAssetId == this.primaryAssetId);
|
||||
}
|
||||
|
||||
class StackEntityCompanion extends UpdateCompanion<StackEntityData> {
|
||||
final Value<String> id;
|
||||
final Value<DateTime> createdAt;
|
||||
final Value<DateTime> updatedAt;
|
||||
final Value<String> ownerId;
|
||||
final Value<String> primaryAssetId;
|
||||
const StackEntityCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.createdAt = const Value.absent(),
|
||||
this.updatedAt = const Value.absent(),
|
||||
this.ownerId = const Value.absent(),
|
||||
this.primaryAssetId = const Value.absent(),
|
||||
});
|
||||
StackEntityCompanion.insert({
|
||||
required String id,
|
||||
this.createdAt = const Value.absent(),
|
||||
this.updatedAt = const Value.absent(),
|
||||
required String ownerId,
|
||||
required String primaryAssetId,
|
||||
}) : id = Value(id),
|
||||
ownerId = Value(ownerId),
|
||||
primaryAssetId = Value(primaryAssetId);
|
||||
static Insertable<StackEntityData> custom({
|
||||
Expression<String>? id,
|
||||
Expression<DateTime>? createdAt,
|
||||
Expression<DateTime>? updatedAt,
|
||||
Expression<String>? ownerId,
|
||||
Expression<String>? primaryAssetId,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (createdAt != null) 'created_at': createdAt,
|
||||
if (updatedAt != null) 'updated_at': updatedAt,
|
||||
if (ownerId != null) 'owner_id': ownerId,
|
||||
if (primaryAssetId != null) 'primary_asset_id': primaryAssetId,
|
||||
});
|
||||
}
|
||||
|
||||
StackEntityCompanion copyWith(
|
||||
{Value<String>? id,
|
||||
Value<DateTime>? createdAt,
|
||||
Value<DateTime>? updatedAt,
|
||||
Value<String>? ownerId,
|
||||
Value<String>? primaryAssetId}) {
|
||||
return StackEntityCompanion(
|
||||
id: id ?? this.id,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
ownerId: ownerId ?? this.ownerId,
|
||||
primaryAssetId: primaryAssetId ?? this.primaryAssetId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
if (id.present) {
|
||||
map['id'] = Variable<String>(id.value);
|
||||
}
|
||||
if (createdAt.present) {
|
||||
map['created_at'] = Variable<DateTime>(createdAt.value);
|
||||
}
|
||||
if (updatedAt.present) {
|
||||
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
||||
}
|
||||
if (ownerId.present) {
|
||||
map['owner_id'] = Variable<String>(ownerId.value);
|
||||
}
|
||||
if (primaryAssetId.present) {
|
||||
map['primary_asset_id'] = Variable<String>(primaryAssetId.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('StackEntityCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('createdAt: $createdAt, ')
|
||||
..write('updatedAt: $updatedAt, ')
|
||||
..write('ownerId: $ownerId, ')
|
||||
..write('primaryAssetId: $primaryAssetId')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class DatabaseAtV2 extends GeneratedDatabase {
|
||||
DatabaseAtV2(QueryExecutor e) : super(e);
|
||||
late final UserEntity userEntity = UserEntity(this);
|
||||
late final RemoteAssetEntity remoteAssetEntity = RemoteAssetEntity(this);
|
||||
late final LocalAssetEntity localAssetEntity = LocalAssetEntity(this);
|
||||
late final StackEntity stackEntity = StackEntity(this);
|
||||
late final Index idxLocalAssetChecksum = Index('idx_local_asset_checksum',
|
||||
'CREATE INDEX idx_local_asset_checksum ON local_asset_entity (checksum)');
|
||||
late final Index uQRemoteAssetOwnerChecksum = Index(
|
||||
|
|
@ -4640,7 +4671,6 @@ class DatabaseAtV2 extends GeneratedDatabase {
|
|||
RemoteAlbumUserEntity(this);
|
||||
late final MemoryEntity memoryEntity = MemoryEntity(this);
|
||||
late final MemoryAssetEntity memoryAssetEntity = MemoryAssetEntity(this);
|
||||
late final StackEntity stackEntity = StackEntity(this);
|
||||
@override
|
||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||
|
|
@ -4649,6 +4679,7 @@ class DatabaseAtV2 extends GeneratedDatabase {
|
|||
userEntity,
|
||||
remoteAssetEntity,
|
||||
localAssetEntity,
|
||||
stackEntity,
|
||||
idxLocalAssetChecksum,
|
||||
uQRemoteAssetOwnerChecksum,
|
||||
idxRemoteAssetChecksum,
|
||||
|
|
@ -4661,8 +4692,7 @@ class DatabaseAtV2 extends GeneratedDatabase {
|
|||
remoteAlbumAssetEntity,
|
||||
remoteAlbumUserEntity,
|
||||
memoryEntity,
|
||||
memoryAssetEntity,
|
||||
stackEntity
|
||||
memoryAssetEntity
|
||||
];
|
||||
@override
|
||||
int get schemaVersion => 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue