update DriftChatDatabase version.

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2023-04-20 19:05:54 +05:30
committed by xsahil03x
parent fc05a9a4cf
commit 3b0cc225eb
10 changed files with 52 additions and 11 deletions
@@ -4,6 +4,7 @@ part of 'member_dao.dart';
// ignore_for_file: type=lint
mixin _$MemberDaoMixin on DatabaseAccessor<DriftChatDatabase> {
$ChannelsTable get channels => attachedDatabase.channels;
$MembersTable get members => attachedDatabase.members;
$UsersTable get users => attachedDatabase.users;
}
@@ -4,6 +4,8 @@ part of 'pinned_message_reaction_dao.dart';
// ignore_for_file: type=lint
mixin _$PinnedMessageReactionDaoMixin on DatabaseAccessor<DriftChatDatabase> {
$ChannelsTable get channels => attachedDatabase.channels;
$PinnedMessagesTable get pinnedMessages => attachedDatabase.pinnedMessages;
$PinnedMessageReactionsTable get pinnedMessageReactions =>
attachedDatabase.pinnedMessageReactions;
$UsersTable get users => attachedDatabase.users;
@@ -4,6 +4,8 @@ part of 'reaction_dao.dart';
// ignore_for_file: type=lint
mixin _$ReactionDaoMixin on DatabaseAccessor<DriftChatDatabase> {
$ChannelsTable get channels => attachedDatabase.channels;
$MessagesTable get messages => attachedDatabase.messages;
$ReactionsTable get reactions => attachedDatabase.reactions;
$UsersTable get users => attachedDatabase.users;
}
@@ -4,6 +4,7 @@ part of 'read_dao.dart';
// ignore_for_file: type=lint
mixin _$ReadDaoMixin on DatabaseAccessor<DriftChatDatabase> {
$ChannelsTable get channels => attachedDatabase.channels;
$ReadsTable get reads => attachedDatabase.reads;
$UsersTable get users => attachedDatabase.users;
}
@@ -49,7 +49,7 @@ class DriftChatDatabase extends _$DriftChatDatabase {
// you should bump this number whenever you change or add a table definition.
@override
int get schemaVersion => 9;
int get schemaVersion => 10;
@override
MigrationStrategy get migration => MigrationStrategy(
@@ -2958,7 +2958,8 @@ class $PinnedMessageReactionsTable extends PinnedMessageReactions
'message_id', aliasedName, false,
type: DriftSqlType.string,
requiredDuringInsert: true,
$customConstraints: 'REFERENCES pinned_messages(id) ON DELETE CASCADE');
defaultConstraints: GeneratedColumn.constraintIsAlways(
'REFERENCES pinned_messages (id) ON DELETE CASCADE'));
static const VerificationMeta _typeMeta = const VerificationMeta('type');
@override
late final GeneratedColumn<String> type = GeneratedColumn<String>(
@@ -3302,7 +3303,8 @@ class $ReactionsTable extends Reactions
'message_id', aliasedName, false,
type: DriftSqlType.string,
requiredDuringInsert: true,
$customConstraints: 'REFERENCES messages(id) ON DELETE CASCADE');
defaultConstraints: GeneratedColumn.constraintIsAlways(
'REFERENCES messages (id) ON DELETE CASCADE'));
static const VerificationMeta _typeMeta = const VerificationMeta('type');
@override
late final GeneratedColumn<String> type = GeneratedColumn<String>(
@@ -4102,7 +4104,8 @@ class $MembersTable extends Members
'channel_cid', aliasedName, false,
type: DriftSqlType.string,
requiredDuringInsert: true,
$customConstraints: 'REFERENCES channels(cid) ON DELETE CASCADE');
defaultConstraints: GeneratedColumn.constraintIsAlways(
'REFERENCES channels (cid) ON DELETE CASCADE'));
static const VerificationMeta _channelRoleMeta =
const VerificationMeta('channelRole');
@override
@@ -4679,7 +4682,8 @@ class $ReadsTable extends Reads with TableInfo<$ReadsTable, ReadEntity> {
'channel_cid', aliasedName, false,
type: DriftSqlType.string,
requiredDuringInsert: true,
$customConstraints: 'REFERENCES channels(cid) ON DELETE CASCADE');
defaultConstraints: GeneratedColumn.constraintIsAlways(
'REFERENCES channels (cid) ON DELETE CASCADE'));
static const VerificationMeta _unreadMessagesMeta =
const VerificationMeta('unreadMessages');
@override
@@ -5547,6 +5551,34 @@ abstract class _$DriftChatDatabase extends GeneratedDatabase {
TableUpdate('pinned_messages', kind: UpdateKind.delete),
],
),
WritePropagation(
on: TableUpdateQuery.onTableName('pinned_messages',
limitUpdateKind: UpdateKind.delete),
result: [
TableUpdate('pinned_message_reactions', kind: UpdateKind.delete),
],
),
WritePropagation(
on: TableUpdateQuery.onTableName('messages',
limitUpdateKind: UpdateKind.delete),
result: [
TableUpdate('reactions', kind: UpdateKind.delete),
],
),
WritePropagation(
on: TableUpdateQuery.onTableName('channels',
limitUpdateKind: UpdateKind.delete),
result: [
TableUpdate('members', kind: UpdateKind.delete),
],
),
WritePropagation(
on: TableUpdateQuery.onTableName('channels',
limitUpdateKind: UpdateKind.delete),
result: [
TableUpdate('reads', kind: UpdateKind.delete),
],
),
],
);
}
@@ -1,5 +1,6 @@
// coverage:ignore-file
import 'package:drift/drift.dart';
import 'package:stream_chat_persistence/src/entity/channels.dart';
/// Represents a [Members] table in [MoorChatDatabase].
@DataClassName('MemberEntity')
@@ -9,7 +10,7 @@ class Members extends Table {
/// The channel cid of which this user is part of
TextColumn get channelCid =>
text().customConstraint('REFERENCES channels(cid) ON DELETE CASCADE')();
text().references(Channels, #cid, onDelete: KeyAction.cascade)();
/// The role of the user in the channel
TextColumn get channelRole => text().nullable()();
@@ -1,6 +1,6 @@
// coverage:ignore-file
import 'package:drift/drift.dart';
import 'package:stream_chat_persistence/src/entity/pinned_messages.dart';
import 'package:stream_chat_persistence/src/entity/reactions.dart';
/// Represents a [PinnedMessageReactions] table in [MoorChatDatabase].
@@ -8,6 +8,6 @@ import 'package:stream_chat_persistence/src/entity/reactions.dart';
class PinnedMessageReactions extends Reactions {
/// The messageId to which the reaction belongs
@override
TextColumn get messageId => text()
.customConstraint('REFERENCES pinned_messages(id) ON DELETE CASCADE')();
TextColumn get messageId =>
text().references(PinnedMessages, #id, onDelete: KeyAction.cascade)();
}
@@ -1,6 +1,7 @@
// coverage:ignore-file
import 'package:drift/drift.dart';
import 'package:stream_chat_persistence/src/converter/map_converter.dart';
import 'package:stream_chat_persistence/src/entity/messages.dart';
/// Represents a [Reactions] table in [MoorChatDatabase].
@DataClassName('ReactionEntity')
@@ -10,7 +11,7 @@ class Reactions extends Table {
/// The messageId to which the reaction belongs
TextColumn get messageId =>
text().customConstraint('REFERENCES messages(id) ON DELETE CASCADE')();
text().references(Messages, #id, onDelete: KeyAction.cascade)();
/// The type of the reaction
TextColumn get type => text()();
@@ -1,5 +1,6 @@
// coverage:ignore-file
import 'package:drift/drift.dart';
import 'package:stream_chat_persistence/src/entity/channels.dart';
/// Represents a [Reads] table in [MoorChatDatabase].
@DataClassName('ReadEntity')
@@ -12,7 +13,7 @@ class Reads extends Table {
/// The channel cid of which this read belongs
TextColumn get channelCid =>
text().customConstraint('REFERENCES channels(cid) ON DELETE CASCADE')();
text().references(Channels, #cid, onDelete: KeyAction.cascade)();
/// Number of unread messages
IntColumn get unreadMessages => integer().withDefault(const Constant(0))();