mirror of https://github.com/AMT-Cheif/drift.git
Fix migration code for virtual tables (#1988)
This commit is contained in:
parent
41d305a2d4
commit
9011137c8e
|
@ -270,6 +270,11 @@ class SchemaReader {
|
||||||
final sqlName = content['name'] as String;
|
final sqlName = content['name'] as String;
|
||||||
final isVirtual = content['is_virtual'] as bool;
|
final isVirtual = content['is_virtual'] as bool;
|
||||||
final withoutRowId = content['without_rowid'] as bool?;
|
final withoutRowId = content['without_rowid'] as bool?;
|
||||||
|
final pascalCase = ReCase(sqlName).pascalCase;
|
||||||
|
final columns = [
|
||||||
|
for (final rawColumn in content['columns'] as List)
|
||||||
|
_readColumn(rawColumn as Map<String, dynamic>)
|
||||||
|
];
|
||||||
|
|
||||||
if (isVirtual) {
|
if (isVirtual) {
|
||||||
final create = content['create_virtual_stmt'] as String;
|
final create = content['create_virtual_stmt'] as String;
|
||||||
|
@ -278,19 +283,15 @@ class SchemaReader {
|
||||||
|
|
||||||
return DriftTable(
|
return DriftTable(
|
||||||
sqlName: sqlName,
|
sqlName: sqlName,
|
||||||
dartTypeName: sqlName,
|
dartTypeName: '${pascalCase}Data',
|
||||||
overriddenName: sqlName,
|
overriddenName: pascalCase,
|
||||||
declaration: CustomVirtualTableDeclaration(parsed),
|
declaration: CustomVirtualTableDeclaration(parsed),
|
||||||
overrideWithoutRowId: withoutRowId,
|
overrideWithoutRowId: withoutRowId,
|
||||||
overrideDontWriteConstraints: true,
|
overrideDontWriteConstraints: true,
|
||||||
|
columns: columns,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final columns = [
|
|
||||||
for (final rawColumn in content['columns'] as List)
|
|
||||||
_readColumn(rawColumn as Map<String, dynamic>)
|
|
||||||
];
|
|
||||||
|
|
||||||
List<String>? tableConstraints;
|
List<String>? tableConstraints;
|
||||||
if (content.containsKey('constraints')) {
|
if (content.containsKey('constraints')) {
|
||||||
tableConstraints = (content['constraints'] as List<dynamic>).cast();
|
tableConstraints = (content['constraints'] as List<dynamic>).cast();
|
||||||
|
@ -304,8 +305,6 @@ class SchemaReader {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
final pascalCase = ReCase(sqlName).pascalCase;
|
|
||||||
|
|
||||||
return DriftTable(
|
return DriftTable(
|
||||||
sqlName: sqlName,
|
sqlName: sqlName,
|
||||||
overriddenName: pascalCase,
|
overriddenName: pascalCase,
|
||||||
|
|
|
@ -5,3 +5,7 @@ targets:
|
||||||
options:
|
options:
|
||||||
generate_connect_constructor: true
|
generate_connect_constructor: true
|
||||||
store_date_time_values_as_text: true
|
store_date_time_values_as_text: true
|
||||||
|
sql:
|
||||||
|
dialect: sqlite
|
||||||
|
options:
|
||||||
|
modules: [fts5]
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.0.0"},"options":{"store_date_time_values_as_text":true},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"users","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"ColumnType.integer","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment","primary-key"]},{"name":"name","getter_name":"name","moor_type":"ColumnType.text","nullable":false,"customConstraints":null,"default_dart":"const Constant('name')","default_client_dart":null,"dsl_features":[]},{"name":"birthday","getter_name":"birthday","moor_type":"ColumnType.datetime","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"next_user","getter_name":"nextUser","moor_type":"ColumnType.integer","nullable":true,"customConstraints":null,"defaultConstraints":"REFERENCES users (id)","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false}},{"id":1,"references":[0],"type":"table","data":{"name":"groups","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"ColumnType.integer","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"title","getter_name":"title","moor_type":"ColumnType.text","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"deleted","getter_name":"deleted","moor_type":"ColumnType.boolean","nullable":true,"customConstraints":"DEFAULT FALSE","default_dart":"const CustomExpression<bool>('FALSE')","default_client_dart":null,"dsl_features":[]},{"name":"owner","getter_name":"owner","moor_type":"ColumnType.integer","nullable":false,"customConstraints":"NOT NULL REFERENCES users (id)","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"constraints":["PRIMARY KEY (id)"],"explicit_pk":["id"]}},{"id":2,"references":[1,0],"type":"view","data":{"name":"group_count","sql":"CREATE VIEW group_count AS SELECT users.*, (SELECT COUNT(*) FROM \"groups\" WHERE owner = users.id) AS group_count FROM users","dart_data_name":"GroupCountData","dart_info_name":"GroupCount","columns":[{"name":"id","getter_name":"id","moor_type":"ColumnType.integer","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"name","getter_name":"name","moor_type":"ColumnType.text","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"birthday","getter_name":"birthday","moor_type":"ColumnType.datetime","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"next_user","getter_name":"nextUser","moor_type":"ColumnType.integer","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"group_count","getter_name":"groupCount","moor_type":"ColumnType.integer","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]}]}},{"id":3,"references":[],"type":"table","data":{"name":"notes","was_declared_in_moor":true,"columns":[{"name":"title","getter_name":"title","moor_type":"ColumnType.text","nullable":false,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"content","getter_name":"content","moor_type":"ColumnType.text","nullable":false,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"search_terms","getter_name":"searchTerms","moor_type":"ColumnType.text","nullable":false,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":true,"create_virtual_stmt":"CREATE VIRTUAL TABLE notes USING fts5(\n title,\n content,\n search_terms,\n tokenize = \"unicode61 tokenchars '.'\"\n);"}}]}
|
|
@ -9,7 +9,7 @@ part 'database.g.dart';
|
||||||
@DriftDatabase(include: {'tables.drift'})
|
@DriftDatabase(include: {'tables.drift'})
|
||||||
class Database extends _$Database {
|
class Database extends _$Database {
|
||||||
@override
|
@override
|
||||||
int get schemaVersion => 6;
|
int get schemaVersion => 7;
|
||||||
|
|
||||||
Database(DatabaseConnection connection) : super.connect(connection);
|
Database(DatabaseConnection connection) : super.connect(connection);
|
||||||
|
|
||||||
|
@ -18,37 +18,46 @@ class Database extends _$Database {
|
||||||
return MigrationStrategy(
|
return MigrationStrategy(
|
||||||
onUpgrade: (m, before, now) async {
|
onUpgrade: (m, before, now) async {
|
||||||
for (var target = before + 1; target <= now; target++) {
|
for (var target = before + 1; target <= now; target++) {
|
||||||
if (target == 2) {
|
switch (target) {
|
||||||
// Migration from 1 to 2: Add name column in users. Use "no name"
|
case 2:
|
||||||
// as a default value.
|
// Migration from 1 to 2: Add name column in users. Use "no name"
|
||||||
final usersAtV2 = v2.Users(this);
|
// as a default value.
|
||||||
|
final usersAtV2 = v2.Users(this);
|
||||||
|
|
||||||
await m.alterTable(
|
await m.alterTable(
|
||||||
TableMigration(
|
TableMigration(
|
||||||
usersAtV2,
|
usersAtV2,
|
||||||
columnTransformer: {
|
columnTransformer: {
|
||||||
users.name: const Constant<String>('no name'),
|
users.name: const Constant<String>('no name'),
|
||||||
},
|
},
|
||||||
newColumns: [usersAtV2.name],
|
newColumns: [usersAtV2.name],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (target == 3) {
|
break;
|
||||||
// Migration from 2 to 3: We added the groups table
|
case 3:
|
||||||
await m.createTable(groups);
|
// Migration from 2 to 3: We added the groups table
|
||||||
} else if (target == 4) {
|
await m.createTable(groups);
|
||||||
// Migration from 3 to 4: users.name now has a default value
|
break;
|
||||||
// No need to transform any data, just re-create the table
|
case 4:
|
||||||
final usersAtV4 = v4.Users(this);
|
// Migration from 3 to 4: users.name now has a default value
|
||||||
|
// No need to transform any data, just re-create the table
|
||||||
|
final usersAtV4 = v4.Users(this);
|
||||||
|
|
||||||
await m.alterTable(TableMigration(usersAtV4));
|
await m.alterTable(TableMigration(usersAtV4));
|
||||||
} else if (target == 5) {
|
break;
|
||||||
// Just add a new column that was added in version 5;
|
case 5:
|
||||||
await m.addColumn(users, users.nextUser);
|
// Just add a new column that was added in version 5;
|
||||||
|
await m.addColumn(users, users.nextUser);
|
||||||
|
|
||||||
// And create the view on users
|
// And create the view on users
|
||||||
await m.createView(groupCount);
|
await m.createView(groupCount);
|
||||||
} else if (target == 6) {
|
break;
|
||||||
await m.addColumn(users, users.birthday);
|
case 6:
|
||||||
|
await m.addColumn(users, users.birthday);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
await m.createTable(notes);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -507,6 +507,225 @@ class Groups extends Table with TableInfo<Groups, Group> {
|
||||||
bool get dontWriteConstraints => true;
|
bool get dontWriteConstraints => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Note extends DataClass implements Insertable<Note> {
|
||||||
|
final String title;
|
||||||
|
final String content;
|
||||||
|
final String searchTerms;
|
||||||
|
const Note(
|
||||||
|
{required this.title, required this.content, required this.searchTerms});
|
||||||
|
@override
|
||||||
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
|
final map = <String, Expression>{};
|
||||||
|
map['title'] = Variable<String>(title);
|
||||||
|
map['content'] = Variable<String>(content);
|
||||||
|
map['search_terms'] = Variable<String>(searchTerms);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
NotesCompanion toCompanion(bool nullToAbsent) {
|
||||||
|
return NotesCompanion(
|
||||||
|
title: Value(title),
|
||||||
|
content: Value(content),
|
||||||
|
searchTerms: Value(searchTerms),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory Note.fromJson(Map<String, dynamic> json,
|
||||||
|
{ValueSerializer? serializer}) {
|
||||||
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
|
return Note(
|
||||||
|
title: serializer.fromJson<String>(json['title']),
|
||||||
|
content: serializer.fromJson<String>(json['content']),
|
||||||
|
searchTerms: serializer.fromJson<String>(json['search_terms']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||||
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
|
return <String, dynamic>{
|
||||||
|
'title': serializer.toJson<String>(title),
|
||||||
|
'content': serializer.toJson<String>(content),
|
||||||
|
'search_terms': serializer.toJson<String>(searchTerms),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Note copyWith({String? title, String? content, String? searchTerms}) => Note(
|
||||||
|
title: title ?? this.title,
|
||||||
|
content: content ?? this.content,
|
||||||
|
searchTerms: searchTerms ?? this.searchTerms,
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return (StringBuffer('Note(')
|
||||||
|
..write('title: $title, ')
|
||||||
|
..write('content: $content, ')
|
||||||
|
..write('searchTerms: $searchTerms')
|
||||||
|
..write(')'))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(title, content, searchTerms);
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
(other is Note &&
|
||||||
|
other.title == this.title &&
|
||||||
|
other.content == this.content &&
|
||||||
|
other.searchTerms == this.searchTerms);
|
||||||
|
}
|
||||||
|
|
||||||
|
class NotesCompanion extends UpdateCompanion<Note> {
|
||||||
|
final Value<String> title;
|
||||||
|
final Value<String> content;
|
||||||
|
final Value<String> searchTerms;
|
||||||
|
const NotesCompanion({
|
||||||
|
this.title = const Value.absent(),
|
||||||
|
this.content = const Value.absent(),
|
||||||
|
this.searchTerms = const Value.absent(),
|
||||||
|
});
|
||||||
|
NotesCompanion.insert({
|
||||||
|
required String title,
|
||||||
|
required String content,
|
||||||
|
required String searchTerms,
|
||||||
|
}) : title = Value(title),
|
||||||
|
content = Value(content),
|
||||||
|
searchTerms = Value(searchTerms);
|
||||||
|
static Insertable<Note> custom({
|
||||||
|
Expression<String>? title,
|
||||||
|
Expression<String>? content,
|
||||||
|
Expression<String>? searchTerms,
|
||||||
|
}) {
|
||||||
|
return RawValuesInsertable({
|
||||||
|
if (title != null) 'title': title,
|
||||||
|
if (content != null) 'content': content,
|
||||||
|
if (searchTerms != null) 'search_terms': searchTerms,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
NotesCompanion copyWith(
|
||||||
|
{Value<String>? title,
|
||||||
|
Value<String>? content,
|
||||||
|
Value<String>? searchTerms}) {
|
||||||
|
return NotesCompanion(
|
||||||
|
title: title ?? this.title,
|
||||||
|
content: content ?? this.content,
|
||||||
|
searchTerms: searchTerms ?? this.searchTerms,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
|
final map = <String, Expression>{};
|
||||||
|
if (title.present) {
|
||||||
|
map['title'] = Variable<String>(title.value);
|
||||||
|
}
|
||||||
|
if (content.present) {
|
||||||
|
map['content'] = Variable<String>(content.value);
|
||||||
|
}
|
||||||
|
if (searchTerms.present) {
|
||||||
|
map['search_terms'] = Variable<String>(searchTerms.value);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return (StringBuffer('NotesCompanion(')
|
||||||
|
..write('title: $title, ')
|
||||||
|
..write('content: $content, ')
|
||||||
|
..write('searchTerms: $searchTerms')
|
||||||
|
..write(')'))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Notes extends Table
|
||||||
|
with TableInfo<Notes, Note>, VirtualTableInfo<Notes, Note> {
|
||||||
|
@override
|
||||||
|
final GeneratedDatabase attachedDatabase;
|
||||||
|
final String? _alias;
|
||||||
|
Notes(this.attachedDatabase, [this._alias]);
|
||||||
|
final VerificationMeta _titleMeta = const VerificationMeta('title');
|
||||||
|
late final GeneratedColumn<String> title = GeneratedColumn<String>(
|
||||||
|
'title', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: '');
|
||||||
|
final VerificationMeta _contentMeta = const VerificationMeta('content');
|
||||||
|
late final GeneratedColumn<String> content = GeneratedColumn<String>(
|
||||||
|
'content', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: '');
|
||||||
|
final VerificationMeta _searchTermsMeta =
|
||||||
|
const VerificationMeta('searchTerms');
|
||||||
|
late final GeneratedColumn<String> searchTerms = GeneratedColumn<String>(
|
||||||
|
'search_terms', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: '');
|
||||||
|
@override
|
||||||
|
List<GeneratedColumn> get $columns => [title, content, searchTerms];
|
||||||
|
@override
|
||||||
|
String get aliasedName => _alias ?? 'notes';
|
||||||
|
@override
|
||||||
|
String get actualTableName => 'notes';
|
||||||
|
@override
|
||||||
|
VerificationContext validateIntegrity(Insertable<Note> instance,
|
||||||
|
{bool isInserting = false}) {
|
||||||
|
final context = VerificationContext();
|
||||||
|
final data = instance.toColumns(true);
|
||||||
|
if (data.containsKey('title')) {
|
||||||
|
context.handle(
|
||||||
|
_titleMeta, title.isAcceptableOrUnknown(data['title']!, _titleMeta));
|
||||||
|
} else if (isInserting) {
|
||||||
|
context.missing(_titleMeta);
|
||||||
|
}
|
||||||
|
if (data.containsKey('content')) {
|
||||||
|
context.handle(_contentMeta,
|
||||||
|
content.isAcceptableOrUnknown(data['content']!, _contentMeta));
|
||||||
|
} else if (isInserting) {
|
||||||
|
context.missing(_contentMeta);
|
||||||
|
}
|
||||||
|
if (data.containsKey('search_terms')) {
|
||||||
|
context.handle(
|
||||||
|
_searchTermsMeta,
|
||||||
|
searchTerms.isAcceptableOrUnknown(
|
||||||
|
data['search_terms']!, _searchTermsMeta));
|
||||||
|
} else if (isInserting) {
|
||||||
|
context.missing(_searchTermsMeta);
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
|
||||||
|
@override
|
||||||
|
Note map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||||
|
return Note(
|
||||||
|
title: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
||||||
|
content: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.string, data['${effectivePrefix}content'])!,
|
||||||
|
searchTerms: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.string, data['${effectivePrefix}search_terms'])!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Notes createAlias(String alias) {
|
||||||
|
return Notes(attachedDatabase, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get dontWriteConstraints => true;
|
||||||
|
@override
|
||||||
|
String get moduleAndArgs =>
|
||||||
|
'fts5(title, content, search_terms, tokenize = "unicode61 tokenchars \'.\'")';
|
||||||
|
}
|
||||||
|
|
||||||
class GroupCountData extends DataClass {
|
class GroupCountData extends DataClass {
|
||||||
final int id;
|
final int id;
|
||||||
final String name;
|
final String name;
|
||||||
|
@ -646,12 +865,13 @@ abstract class _$Database extends GeneratedDatabase {
|
||||||
late final $UsersTable users = $UsersTable(this);
|
late final $UsersTable users = $UsersTable(this);
|
||||||
late final Groups groups = Groups(this);
|
late final Groups groups = Groups(this);
|
||||||
late final GroupCount groupCount = GroupCount(this);
|
late final GroupCount groupCount = GroupCount(this);
|
||||||
|
late final Notes notes = Notes(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
||||||
[users, groups, groupCount];
|
[users, groups, groupCount, notes];
|
||||||
@override
|
@override
|
||||||
DriftDatabaseOptions get options =>
|
DriftDatabaseOptions get options =>
|
||||||
const DriftDatabaseOptions(storeDateTimeAsText: true);
|
const DriftDatabaseOptions(storeDateTimeAsText: true);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:drift/drift.dart';
|
||||||
import 'package:drift_dev/api/migrations.dart';
|
import 'package:drift_dev/api/migrations.dart';
|
||||||
import 'schema_v6.dart' as v6;
|
import 'schema_v6.dart' as v6;
|
||||||
import 'schema_v2.dart' as v2;
|
import 'schema_v2.dart' as v2;
|
||||||
|
import 'schema_v7.dart' as v7;
|
||||||
import 'schema_v3.dart' as v3;
|
import 'schema_v3.dart' as v3;
|
||||||
import 'schema_v4.dart' as v4;
|
import 'schema_v4.dart' as v4;
|
||||||
import 'schema_v1.dart' as v1;
|
import 'schema_v1.dart' as v1;
|
||||||
|
@ -17,6 +18,8 @@ class GeneratedHelper implements SchemaInstantiationHelper {
|
||||||
return v6.DatabaseAtV6(db);
|
return v6.DatabaseAtV6(db);
|
||||||
case 2:
|
case 2:
|
||||||
return v2.DatabaseAtV2(db);
|
return v2.DatabaseAtV2(db);
|
||||||
|
case 7:
|
||||||
|
return v7.DatabaseAtV7(db);
|
||||||
case 3:
|
case 3:
|
||||||
return v3.DatabaseAtV3(db);
|
return v3.DatabaseAtV3(db);
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -26,7 +29,7 @@ class GeneratedHelper implements SchemaInstantiationHelper {
|
||||||
case 5:
|
case 5:
|
||||||
return v5.DatabaseAtV5(db);
|
return v5.DatabaseAtV5(db);
|
||||||
default:
|
default:
|
||||||
throw MissingSchemaException(version, const {6, 2, 3, 4, 1, 5});
|
throw MissingSchemaException(version, const {6, 2, 7, 3, 4, 1, 5});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ class DatabaseAtV1 extends GeneratedDatabase {
|
||||||
DatabaseAtV1.connect(DatabaseConnection c) : super.connect(c);
|
DatabaseAtV1.connect(DatabaseConnection c) : super.connect(c);
|
||||||
late final Users users = Users(this);
|
late final Users users = Users(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -42,7 +42,8 @@ class DatabaseAtV2 extends GeneratedDatabase {
|
||||||
DatabaseAtV2.connect(DatabaseConnection c) : super.connect(c);
|
DatabaseAtV2.connect(DatabaseConnection c) : super.connect(c);
|
||||||
late final Users users = Users(this);
|
late final Users users = Users(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -93,7 +93,8 @@ class DatabaseAtV3 extends GeneratedDatabase {
|
||||||
late final Users users = Users(this);
|
late final Users users = Users(this);
|
||||||
late final Groups groups = Groups(this);
|
late final Groups groups = Groups(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -95,7 +95,8 @@ class DatabaseAtV4 extends GeneratedDatabase {
|
||||||
late final Users users = Users(this);
|
late final Users users = Users(this);
|
||||||
late final Groups groups = Groups(this);
|
late final Groups groups = Groups(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -143,7 +143,8 @@ class DatabaseAtV5 extends GeneratedDatabase {
|
||||||
late final Groups groups = Groups(this);
|
late final Groups groups = Groups(this);
|
||||||
late final GroupCount groupCount = GroupCount(this);
|
late final GroupCount groupCount = GroupCount(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
||||||
[users, groups, groupCount];
|
[users, groups, groupCount];
|
||||||
|
|
|
@ -150,7 +150,8 @@ class DatabaseAtV6 extends GeneratedDatabase {
|
||||||
late final Groups groups = Groups(this);
|
late final Groups groups = Groups(this);
|
||||||
late final GroupCount groupCount = GroupCount(this);
|
late final GroupCount groupCount = GroupCount(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
||||||
[users, groups, groupCount];
|
[users, groups, groupCount];
|
||||||
|
|
|
@ -0,0 +1,209 @@
|
||||||
|
// GENERATED CODE, DO NOT EDIT BY HAND.
|
||||||
|
//@dart=2.12
|
||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
class Users extends Table with TableInfo {
|
||||||
|
@override
|
||||||
|
final GeneratedDatabase attachedDatabase;
|
||||||
|
final String? _alias;
|
||||||
|
Users(this.attachedDatabase, [this._alias]);
|
||||||
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
||||||
|
'id', aliasedName, false,
|
||||||
|
type: DriftSqlType.int,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
|
||||||
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
||||||
|
'name', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultValue: const Constant('name'));
|
||||||
|
late final GeneratedColumn<DateTime> birthday = GeneratedColumn<DateTime>(
|
||||||
|
'birthday', aliasedName, true,
|
||||||
|
type: DriftSqlType.dateTime, requiredDuringInsert: false);
|
||||||
|
late final GeneratedColumn<int> nextUser = GeneratedColumn<int>(
|
||||||
|
'next_user', aliasedName, true,
|
||||||
|
type: DriftSqlType.int,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultConstraints: 'REFERENCES users (id)');
|
||||||
|
@override
|
||||||
|
List<GeneratedColumn> get $columns => [id, name, birthday, nextUser];
|
||||||
|
@override
|
||||||
|
String get aliasedName => _alias ?? 'users';
|
||||||
|
@override
|
||||||
|
String get actualTableName => 'users';
|
||||||
|
@override
|
||||||
|
Set<GeneratedColumn> get $primaryKey => {id};
|
||||||
|
@override
|
||||||
|
Never map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
throw UnsupportedError('TableInfo.map in schema verification code');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Users createAlias(String alias) {
|
||||||
|
return Users(attachedDatabase, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get dontWriteConstraints => false;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Groups extends Table with TableInfo {
|
||||||
|
@override
|
||||||
|
final GeneratedDatabase attachedDatabase;
|
||||||
|
final String? _alias;
|
||||||
|
Groups(this.attachedDatabase, [this._alias]);
|
||||||
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
||||||
|
'id', aliasedName, false,
|
||||||
|
type: DriftSqlType.int,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
$customConstraints: 'NOT NULL');
|
||||||
|
late final GeneratedColumn<String> title = GeneratedColumn<String>(
|
||||||
|
'title', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: 'NOT NULL');
|
||||||
|
late final GeneratedColumn<bool> deleted = GeneratedColumn<bool>(
|
||||||
|
'deleted', aliasedName, true,
|
||||||
|
type: DriftSqlType.bool,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
$customConstraints: 'DEFAULT FALSE',
|
||||||
|
defaultValue: const CustomExpression<bool>('FALSE'));
|
||||||
|
late final GeneratedColumn<int> owner = GeneratedColumn<int>(
|
||||||
|
'owner', aliasedName, false,
|
||||||
|
type: DriftSqlType.int,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: 'NOT NULL REFERENCES users (id)');
|
||||||
|
@override
|
||||||
|
List<GeneratedColumn> get $columns => [id, title, deleted, owner];
|
||||||
|
@override
|
||||||
|
String get aliasedName => _alias ?? 'groups';
|
||||||
|
@override
|
||||||
|
String get actualTableName => 'groups';
|
||||||
|
@override
|
||||||
|
Set<GeneratedColumn> get $primaryKey => {id};
|
||||||
|
@override
|
||||||
|
Never map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
throw UnsupportedError('TableInfo.map in schema verification code');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Groups createAlias(String alias) {
|
||||||
|
return Groups(attachedDatabase, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<String> get customConstraints => const ['PRIMARY KEY (id)'];
|
||||||
|
@override
|
||||||
|
bool get dontWriteConstraints => true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Notes extends Table with TableInfo, VirtualTableInfo {
|
||||||
|
@override
|
||||||
|
final GeneratedDatabase attachedDatabase;
|
||||||
|
final String? _alias;
|
||||||
|
Notes(this.attachedDatabase, [this._alias]);
|
||||||
|
late final GeneratedColumn<String> title = GeneratedColumn<String>(
|
||||||
|
'title', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: '');
|
||||||
|
late final GeneratedColumn<String> content = GeneratedColumn<String>(
|
||||||
|
'content', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: '');
|
||||||
|
late final GeneratedColumn<String> searchTerms = GeneratedColumn<String>(
|
||||||
|
'search_terms', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: '');
|
||||||
|
@override
|
||||||
|
List<GeneratedColumn> get $columns => [title, content, searchTerms];
|
||||||
|
@override
|
||||||
|
String get aliasedName => _alias ?? 'notes';
|
||||||
|
@override
|
||||||
|
String get actualTableName => 'notes';
|
||||||
|
@override
|
||||||
|
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
|
||||||
|
@override
|
||||||
|
Never map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
throw UnsupportedError('TableInfo.map in schema verification code');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Notes createAlias(String alias) {
|
||||||
|
return Notes(attachedDatabase, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get dontWriteConstraints => true;
|
||||||
|
@override
|
||||||
|
String get moduleAndArgs =>
|
||||||
|
'fts5(title, content, search_terms, tokenize = "unicode61 tokenchars \'.\'")';
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupCount extends ViewInfo<GroupCount, Never> implements HasResultSet {
|
||||||
|
final String? _alias;
|
||||||
|
@override
|
||||||
|
final DatabaseAtV7 attachedDatabase;
|
||||||
|
GroupCount(this.attachedDatabase, [this._alias]);
|
||||||
|
@override
|
||||||
|
List<GeneratedColumn> get $columns =>
|
||||||
|
[id, name, birthday, nextUser, groupCount];
|
||||||
|
@override
|
||||||
|
String get aliasedName => _alias ?? entityName;
|
||||||
|
@override
|
||||||
|
String get entityName => 'group_count';
|
||||||
|
@override
|
||||||
|
String? get createViewStmt => null;
|
||||||
|
@override
|
||||||
|
GroupCount get asDslTable => this;
|
||||||
|
@override
|
||||||
|
Never map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
throw UnsupportedError('TableInfo.map in schema verification code');
|
||||||
|
}
|
||||||
|
|
||||||
|
late final GeneratedColumn<int> id =
|
||||||
|
GeneratedColumn<int>('id', aliasedName, false, type: DriftSqlType.int);
|
||||||
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
||||||
|
'name', aliasedName, false,
|
||||||
|
type: DriftSqlType.string);
|
||||||
|
late final GeneratedColumn<DateTime> birthday = GeneratedColumn<DateTime>(
|
||||||
|
'birthday', aliasedName, true,
|
||||||
|
type: DriftSqlType.dateTime);
|
||||||
|
late final GeneratedColumn<int> nextUser = GeneratedColumn<int>(
|
||||||
|
'next_user', aliasedName, true,
|
||||||
|
type: DriftSqlType.int);
|
||||||
|
late final GeneratedColumn<int> groupCount = GeneratedColumn<int>(
|
||||||
|
'group_count', aliasedName, false,
|
||||||
|
type: DriftSqlType.int);
|
||||||
|
@override
|
||||||
|
GroupCount createAlias(String alias) {
|
||||||
|
return GroupCount(attachedDatabase, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Query? get query => null;
|
||||||
|
@override
|
||||||
|
Set<String> get readTables => const {};
|
||||||
|
}
|
||||||
|
|
||||||
|
class DatabaseAtV7 extends GeneratedDatabase {
|
||||||
|
DatabaseAtV7(QueryExecutor e) : super(e);
|
||||||
|
DatabaseAtV7.connect(DatabaseConnection c) : super.connect(c);
|
||||||
|
late final Users users = Users(this);
|
||||||
|
late final Groups groups = Groups(this);
|
||||||
|
late final GroupCount groupCount = GroupCount(this);
|
||||||
|
late final Notes notes = Notes(this);
|
||||||
|
@override
|
||||||
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
|
@override
|
||||||
|
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
||||||
|
[users, groups, groupCount, notes];
|
||||||
|
@override
|
||||||
|
int get schemaVersion => 7;
|
||||||
|
@override
|
||||||
|
DriftDatabaseOptions get options =>
|
||||||
|
const DriftDatabaseOptions(storeDateTimeAsText: true);
|
||||||
|
}
|
|
@ -10,6 +10,14 @@ CREATE TABLE "groups" (
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- This table was added in schema version 7
|
||||||
|
CREATE VIRTUAL TABLE notes USING fts5(
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
search_terms,
|
||||||
|
tokenize = "unicode61 tokenchars '.'"
|
||||||
|
);
|
||||||
|
|
||||||
-- This view was added in schema version 5
|
-- This view was added in schema version 5
|
||||||
CREATE VIEW group_count AS SELECT
|
CREATE VIEW group_count AS SELECT
|
||||||
users.*,
|
users.*,
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:drift/drift.dart';
|
||||||
import 'package:drift_dev/api/migrations.dart';
|
import 'package:drift_dev/api/migrations.dart';
|
||||||
import 'schema_v6.dart' as v6;
|
import 'schema_v6.dart' as v6;
|
||||||
import 'schema_v2.dart' as v2;
|
import 'schema_v2.dart' as v2;
|
||||||
|
import 'schema_v7.dart' as v7;
|
||||||
import 'schema_v3.dart' as v3;
|
import 'schema_v3.dart' as v3;
|
||||||
import 'schema_v4.dart' as v4;
|
import 'schema_v4.dart' as v4;
|
||||||
import 'schema_v1.dart' as v1;
|
import 'schema_v1.dart' as v1;
|
||||||
|
@ -17,6 +18,8 @@ class GeneratedHelper implements SchemaInstantiationHelper {
|
||||||
return v6.DatabaseAtV6(db);
|
return v6.DatabaseAtV6(db);
|
||||||
case 2:
|
case 2:
|
||||||
return v2.DatabaseAtV2(db);
|
return v2.DatabaseAtV2(db);
|
||||||
|
case 7:
|
||||||
|
return v7.DatabaseAtV7(db);
|
||||||
case 3:
|
case 3:
|
||||||
return v3.DatabaseAtV3(db);
|
return v3.DatabaseAtV3(db);
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -26,7 +29,7 @@ class GeneratedHelper implements SchemaInstantiationHelper {
|
||||||
case 5:
|
case 5:
|
||||||
return v5.DatabaseAtV5(db);
|
return v5.DatabaseAtV5(db);
|
||||||
default:
|
default:
|
||||||
throw MissingSchemaException(version, const {6, 2, 3, 4, 1, 5});
|
throw MissingSchemaException(version, const {6, 2, 7, 3, 4, 1, 5});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,8 @@ class DatabaseAtV1 extends GeneratedDatabase {
|
||||||
DatabaseAtV1.connect(DatabaseConnection c) : super.connect(c);
|
DatabaseAtV1.connect(DatabaseConnection c) : super.connect(c);
|
||||||
late final Users users = Users(this);
|
late final Users users = Users(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -155,7 +155,8 @@ class DatabaseAtV2 extends GeneratedDatabase {
|
||||||
DatabaseAtV2.connect(DatabaseConnection c) : super.connect(c);
|
DatabaseAtV2.connect(DatabaseConnection c) : super.connect(c);
|
||||||
late final Users users = Users(this);
|
late final Users users = Users(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -204,11 +204,15 @@ class GroupsData extends DataClass implements Insertable<GroupsData> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupsData copyWith({int? id, String? title, bool? deleted, int? owner}) =>
|
GroupsData copyWith(
|
||||||
|
{int? id,
|
||||||
|
String? title,
|
||||||
|
Value<bool?> deleted = const Value.absent(),
|
||||||
|
int? owner}) =>
|
||||||
GroupsData(
|
GroupsData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
title: title ?? this.title,
|
title: title ?? this.title,
|
||||||
deleted: deleted ?? this.deleted,
|
deleted: deleted.present ? deleted.value : this.deleted,
|
||||||
owner: owner ?? this.owner,
|
owner: owner ?? this.owner,
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
|
@ -375,7 +379,8 @@ class DatabaseAtV3 extends GeneratedDatabase {
|
||||||
late final Users users = Users(this);
|
late final Users users = Users(this);
|
||||||
late final Groups groups = Groups(this);
|
late final Groups groups = Groups(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -206,11 +206,15 @@ class GroupsData extends DataClass implements Insertable<GroupsData> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupsData copyWith({int? id, String? title, bool? deleted, int? owner}) =>
|
GroupsData copyWith(
|
||||||
|
{int? id,
|
||||||
|
String? title,
|
||||||
|
Value<bool?> deleted = const Value.absent(),
|
||||||
|
int? owner}) =>
|
||||||
GroupsData(
|
GroupsData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
title: title ?? this.title,
|
title: title ?? this.title,
|
||||||
deleted: deleted ?? this.deleted,
|
deleted: deleted.present ? deleted.value : this.deleted,
|
||||||
owner: owner ?? this.owner,
|
owner: owner ?? this.owner,
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
|
@ -377,7 +381,8 @@ class DatabaseAtV4 extends GeneratedDatabase {
|
||||||
late final Users users = Users(this);
|
late final Users users = Users(this);
|
||||||
late final Groups groups = Groups(this);
|
late final Groups groups = Groups(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -47,10 +47,14 @@ class UsersData extends DataClass implements Insertable<UsersData> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
UsersData copyWith({int? id, String? name, int? nextUser}) => UsersData(
|
UsersData copyWith(
|
||||||
|
{int? id,
|
||||||
|
String? name,
|
||||||
|
Value<int?> nextUser = const Value.absent()}) =>
|
||||||
|
UsersData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
nextUser: nextUser ?? this.nextUser,
|
nextUser: nextUser.present ? nextUser.value : this.nextUser,
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
@ -238,11 +242,15 @@ class GroupsData extends DataClass implements Insertable<GroupsData> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupsData copyWith({int? id, String? title, bool? deleted, int? owner}) =>
|
GroupsData copyWith(
|
||||||
|
{int? id,
|
||||||
|
String? title,
|
||||||
|
Value<bool?> deleted = const Value.absent(),
|
||||||
|
int? owner}) =>
|
||||||
GroupsData(
|
GroupsData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
title: title ?? this.title,
|
title: title ?? this.title,
|
||||||
deleted: deleted ?? this.deleted,
|
deleted: deleted.present ? deleted.value : this.deleted,
|
||||||
owner: owner ?? this.owner,
|
owner: owner ?? this.owner,
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
|
@ -435,11 +443,14 @@ class GroupCountData extends DataClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupCountData copyWith(
|
GroupCountData copyWith(
|
||||||
{int? id, String? name, int? nextUser, int? groupCount}) =>
|
{int? id,
|
||||||
|
String? name,
|
||||||
|
Value<int?> nextUser = const Value.absent(),
|
||||||
|
int? groupCount}) =>
|
||||||
GroupCountData(
|
GroupCountData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
nextUser: nextUser ?? this.nextUser,
|
nextUser: nextUser.present ? nextUser.value : this.nextUser,
|
||||||
groupCount: groupCount ?? this.groupCount,
|
groupCount: groupCount ?? this.groupCount,
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
|
@ -525,7 +536,8 @@ class DatabaseAtV5 extends GeneratedDatabase {
|
||||||
late final Groups groups = Groups(this);
|
late final Groups groups = Groups(this);
|
||||||
late final GroupCount groupCount = GroupCount(this);
|
late final GroupCount groupCount = GroupCount(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
||||||
[users, groups, groupCount];
|
[users, groups, groupCount];
|
||||||
|
|
|
@ -58,12 +58,15 @@ class UsersData extends DataClass implements Insertable<UsersData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
UsersData copyWith(
|
UsersData copyWith(
|
||||||
{int? id, String? name, DateTime? birthday, int? nextUser}) =>
|
{int? id,
|
||||||
|
String? name,
|
||||||
|
Value<DateTime?> birthday = const Value.absent(),
|
||||||
|
Value<int?> nextUser = const Value.absent()}) =>
|
||||||
UsersData(
|
UsersData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
birthday: birthday ?? this.birthday,
|
birthday: birthday.present ? birthday.value : this.birthday,
|
||||||
nextUser: nextUser ?? this.nextUser,
|
nextUser: nextUser.present ? nextUser.value : this.nextUser,
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
@ -271,11 +274,15 @@ class GroupsData extends DataClass implements Insertable<GroupsData> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupsData copyWith({int? id, String? title, bool? deleted, int? owner}) =>
|
GroupsData copyWith(
|
||||||
|
{int? id,
|
||||||
|
String? title,
|
||||||
|
Value<bool?> deleted = const Value.absent(),
|
||||||
|
int? owner}) =>
|
||||||
GroupsData(
|
GroupsData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
title: title ?? this.title,
|
title: title ?? this.title,
|
||||||
deleted: deleted ?? this.deleted,
|
deleted: deleted.present ? deleted.value : this.deleted,
|
||||||
owner: owner ?? this.owner,
|
owner: owner ?? this.owner,
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
|
@ -474,14 +481,14 @@ class GroupCountData extends DataClass {
|
||||||
GroupCountData copyWith(
|
GroupCountData copyWith(
|
||||||
{int? id,
|
{int? id,
|
||||||
String? name,
|
String? name,
|
||||||
DateTime? birthday,
|
Value<DateTime?> birthday = const Value.absent(),
|
||||||
int? nextUser,
|
Value<int?> nextUser = const Value.absent(),
|
||||||
int? groupCount}) =>
|
int? groupCount}) =>
|
||||||
GroupCountData(
|
GroupCountData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
birthday: birthday ?? this.birthday,
|
birthday: birthday.present ? birthday.value : this.birthday,
|
||||||
nextUser: nextUser ?? this.nextUser,
|
nextUser: nextUser.present ? nextUser.value : this.nextUser,
|
||||||
groupCount: groupCount ?? this.groupCount,
|
groupCount: groupCount ?? this.groupCount,
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
|
@ -575,7 +582,8 @@ class DatabaseAtV6 extends GeneratedDatabase {
|
||||||
late final Groups groups = Groups(this);
|
late final Groups groups = Groups(this);
|
||||||
late final GroupCount groupCount = GroupCount(this);
|
late final GroupCount groupCount = GroupCount(this);
|
||||||
@override
|
@override
|
||||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
@override
|
@override
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
||||||
[users, groups, groupCount];
|
[users, groups, groupCount];
|
||||||
|
|
|
@ -0,0 +1,784 @@
|
||||||
|
// GENERATED CODE, DO NOT EDIT BY HAND.
|
||||||
|
//@dart=2.12
|
||||||
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
|
class UsersData extends DataClass implements Insertable<UsersData> {
|
||||||
|
final int id;
|
||||||
|
final String name;
|
||||||
|
final DateTime? birthday;
|
||||||
|
final int? nextUser;
|
||||||
|
const UsersData(
|
||||||
|
{required this.id, required this.name, this.birthday, this.nextUser});
|
||||||
|
@override
|
||||||
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
|
final map = <String, Expression>{};
|
||||||
|
map['id'] = Variable<int>(id);
|
||||||
|
map['name'] = Variable<String>(name);
|
||||||
|
if (!nullToAbsent || birthday != null) {
|
||||||
|
map['birthday'] = Variable<DateTime>(birthday);
|
||||||
|
}
|
||||||
|
if (!nullToAbsent || nextUser != null) {
|
||||||
|
map['next_user'] = Variable<int>(nextUser);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
UsersCompanion toCompanion(bool nullToAbsent) {
|
||||||
|
return UsersCompanion(
|
||||||
|
id: Value(id),
|
||||||
|
name: Value(name),
|
||||||
|
birthday: birthday == null && nullToAbsent
|
||||||
|
? const Value.absent()
|
||||||
|
: Value(birthday),
|
||||||
|
nextUser: nextUser == null && nullToAbsent
|
||||||
|
? const Value.absent()
|
||||||
|
: Value(nextUser),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory UsersData.fromJson(Map<String, dynamic> json,
|
||||||
|
{ValueSerializer? serializer}) {
|
||||||
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
|
return UsersData(
|
||||||
|
id: serializer.fromJson<int>(json['id']),
|
||||||
|
name: serializer.fromJson<String>(json['name']),
|
||||||
|
birthday: serializer.fromJson<DateTime?>(json['birthday']),
|
||||||
|
nextUser: serializer.fromJson<int?>(json['nextUser']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||||
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
|
return <String, dynamic>{
|
||||||
|
'id': serializer.toJson<int>(id),
|
||||||
|
'name': serializer.toJson<String>(name),
|
||||||
|
'birthday': serializer.toJson<DateTime?>(birthday),
|
||||||
|
'nextUser': serializer.toJson<int?>(nextUser),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
UsersData copyWith(
|
||||||
|
{int? id,
|
||||||
|
String? name,
|
||||||
|
Value<DateTime?> birthday = const Value.absent(),
|
||||||
|
Value<int?> nextUser = const Value.absent()}) =>
|
||||||
|
UsersData(
|
||||||
|
id: id ?? this.id,
|
||||||
|
name: name ?? this.name,
|
||||||
|
birthday: birthday.present ? birthday.value : this.birthday,
|
||||||
|
nextUser: nextUser.present ? nextUser.value : this.nextUser,
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return (StringBuffer('UsersData(')
|
||||||
|
..write('id: $id, ')
|
||||||
|
..write('name: $name, ')
|
||||||
|
..write('birthday: $birthday, ')
|
||||||
|
..write('nextUser: $nextUser')
|
||||||
|
..write(')'))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(id, name, birthday, nextUser);
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
(other is UsersData &&
|
||||||
|
other.id == this.id &&
|
||||||
|
other.name == this.name &&
|
||||||
|
other.birthday == this.birthday &&
|
||||||
|
other.nextUser == this.nextUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
class UsersCompanion extends UpdateCompanion<UsersData> {
|
||||||
|
final Value<int> id;
|
||||||
|
final Value<String> name;
|
||||||
|
final Value<DateTime?> birthday;
|
||||||
|
final Value<int?> nextUser;
|
||||||
|
const UsersCompanion({
|
||||||
|
this.id = const Value.absent(),
|
||||||
|
this.name = const Value.absent(),
|
||||||
|
this.birthday = const Value.absent(),
|
||||||
|
this.nextUser = const Value.absent(),
|
||||||
|
});
|
||||||
|
UsersCompanion.insert({
|
||||||
|
this.id = const Value.absent(),
|
||||||
|
this.name = const Value.absent(),
|
||||||
|
this.birthday = const Value.absent(),
|
||||||
|
this.nextUser = const Value.absent(),
|
||||||
|
});
|
||||||
|
static Insertable<UsersData> custom({
|
||||||
|
Expression<int>? id,
|
||||||
|
Expression<String>? name,
|
||||||
|
Expression<DateTime>? birthday,
|
||||||
|
Expression<int>? nextUser,
|
||||||
|
}) {
|
||||||
|
return RawValuesInsertable({
|
||||||
|
if (id != null) 'id': id,
|
||||||
|
if (name != null) 'name': name,
|
||||||
|
if (birthday != null) 'birthday': birthday,
|
||||||
|
if (nextUser != null) 'next_user': nextUser,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
UsersCompanion copyWith(
|
||||||
|
{Value<int>? id,
|
||||||
|
Value<String>? name,
|
||||||
|
Value<DateTime?>? birthday,
|
||||||
|
Value<int?>? nextUser}) {
|
||||||
|
return UsersCompanion(
|
||||||
|
id: id ?? this.id,
|
||||||
|
name: name ?? this.name,
|
||||||
|
birthday: birthday ?? this.birthday,
|
||||||
|
nextUser: nextUser ?? this.nextUser,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
|
final map = <String, Expression>{};
|
||||||
|
if (id.present) {
|
||||||
|
map['id'] = Variable<int>(id.value);
|
||||||
|
}
|
||||||
|
if (name.present) {
|
||||||
|
map['name'] = Variable<String>(name.value);
|
||||||
|
}
|
||||||
|
if (birthday.present) {
|
||||||
|
map['birthday'] = Variable<DateTime>(birthday.value);
|
||||||
|
}
|
||||||
|
if (nextUser.present) {
|
||||||
|
map['next_user'] = Variable<int>(nextUser.value);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return (StringBuffer('UsersCompanion(')
|
||||||
|
..write('id: $id, ')
|
||||||
|
..write('name: $name, ')
|
||||||
|
..write('birthday: $birthday, ')
|
||||||
|
..write('nextUser: $nextUser')
|
||||||
|
..write(')'))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Users extends Table with TableInfo<Users, UsersData> {
|
||||||
|
@override
|
||||||
|
final GeneratedDatabase attachedDatabase;
|
||||||
|
final String? _alias;
|
||||||
|
Users(this.attachedDatabase, [this._alias]);
|
||||||
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
||||||
|
'id', aliasedName, false,
|
||||||
|
type: DriftSqlType.int,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
|
||||||
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
||||||
|
'name', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultValue: const Constant('name'));
|
||||||
|
late final GeneratedColumn<DateTime> birthday = GeneratedColumn<DateTime>(
|
||||||
|
'birthday', aliasedName, true,
|
||||||
|
type: DriftSqlType.dateTime, requiredDuringInsert: false);
|
||||||
|
late final GeneratedColumn<int> nextUser = GeneratedColumn<int>(
|
||||||
|
'next_user', aliasedName, true,
|
||||||
|
type: DriftSqlType.int,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultConstraints: 'REFERENCES users (id)');
|
||||||
|
@override
|
||||||
|
List<GeneratedColumn> get $columns => [id, name, birthday, nextUser];
|
||||||
|
@override
|
||||||
|
String get aliasedName => _alias ?? 'users';
|
||||||
|
@override
|
||||||
|
String get actualTableName => 'users';
|
||||||
|
@override
|
||||||
|
Set<GeneratedColumn> get $primaryKey => {id};
|
||||||
|
@override
|
||||||
|
UsersData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||||
|
return UsersData(
|
||||||
|
id: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||||
|
name: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
||||||
|
birthday: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}birthday']),
|
||||||
|
nextUser: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Users createAlias(String alias) {
|
||||||
|
return Users(attachedDatabase, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get dontWriteConstraints => false;
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupsData extends DataClass implements Insertable<GroupsData> {
|
||||||
|
final int id;
|
||||||
|
final String title;
|
||||||
|
final bool? deleted;
|
||||||
|
final int owner;
|
||||||
|
const GroupsData(
|
||||||
|
{required this.id,
|
||||||
|
required this.title,
|
||||||
|
this.deleted,
|
||||||
|
required this.owner});
|
||||||
|
@override
|
||||||
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
|
final map = <String, Expression>{};
|
||||||
|
map['id'] = Variable<int>(id);
|
||||||
|
map['title'] = Variable<String>(title);
|
||||||
|
if (!nullToAbsent || deleted != null) {
|
||||||
|
map['deleted'] = Variable<bool>(deleted);
|
||||||
|
}
|
||||||
|
map['owner'] = Variable<int>(owner);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupsCompanion toCompanion(bool nullToAbsent) {
|
||||||
|
return GroupsCompanion(
|
||||||
|
id: Value(id),
|
||||||
|
title: Value(title),
|
||||||
|
deleted: deleted == null && nullToAbsent
|
||||||
|
? const Value.absent()
|
||||||
|
: Value(deleted),
|
||||||
|
owner: Value(owner),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory GroupsData.fromJson(Map<String, dynamic> json,
|
||||||
|
{ValueSerializer? serializer}) {
|
||||||
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
|
return GroupsData(
|
||||||
|
id: serializer.fromJson<int>(json['id']),
|
||||||
|
title: serializer.fromJson<String>(json['title']),
|
||||||
|
deleted: serializer.fromJson<bool?>(json['deleted']),
|
||||||
|
owner: serializer.fromJson<int>(json['owner']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||||
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
|
return <String, dynamic>{
|
||||||
|
'id': serializer.toJson<int>(id),
|
||||||
|
'title': serializer.toJson<String>(title),
|
||||||
|
'deleted': serializer.toJson<bool?>(deleted),
|
||||||
|
'owner': serializer.toJson<int>(owner),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupsData copyWith(
|
||||||
|
{int? id,
|
||||||
|
String? title,
|
||||||
|
Value<bool?> deleted = const Value.absent(),
|
||||||
|
int? owner}) =>
|
||||||
|
GroupsData(
|
||||||
|
id: id ?? this.id,
|
||||||
|
title: title ?? this.title,
|
||||||
|
deleted: deleted.present ? deleted.value : this.deleted,
|
||||||
|
owner: owner ?? this.owner,
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return (StringBuffer('GroupsData(')
|
||||||
|
..write('id: $id, ')
|
||||||
|
..write('title: $title, ')
|
||||||
|
..write('deleted: $deleted, ')
|
||||||
|
..write('owner: $owner')
|
||||||
|
..write(')'))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(id, title, deleted, owner);
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
(other is GroupsData &&
|
||||||
|
other.id == this.id &&
|
||||||
|
other.title == this.title &&
|
||||||
|
other.deleted == this.deleted &&
|
||||||
|
other.owner == this.owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupsCompanion extends UpdateCompanion<GroupsData> {
|
||||||
|
final Value<int> id;
|
||||||
|
final Value<String> title;
|
||||||
|
final Value<bool?> deleted;
|
||||||
|
final Value<int> owner;
|
||||||
|
const GroupsCompanion({
|
||||||
|
this.id = const Value.absent(),
|
||||||
|
this.title = const Value.absent(),
|
||||||
|
this.deleted = const Value.absent(),
|
||||||
|
this.owner = const Value.absent(),
|
||||||
|
});
|
||||||
|
GroupsCompanion.insert({
|
||||||
|
this.id = const Value.absent(),
|
||||||
|
required String title,
|
||||||
|
this.deleted = const Value.absent(),
|
||||||
|
required int owner,
|
||||||
|
}) : title = Value(title),
|
||||||
|
owner = Value(owner);
|
||||||
|
static Insertable<GroupsData> custom({
|
||||||
|
Expression<int>? id,
|
||||||
|
Expression<String>? title,
|
||||||
|
Expression<bool>? deleted,
|
||||||
|
Expression<int>? owner,
|
||||||
|
}) {
|
||||||
|
return RawValuesInsertable({
|
||||||
|
if (id != null) 'id': id,
|
||||||
|
if (title != null) 'title': title,
|
||||||
|
if (deleted != null) 'deleted': deleted,
|
||||||
|
if (owner != null) 'owner': owner,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupsCompanion copyWith(
|
||||||
|
{Value<int>? id,
|
||||||
|
Value<String>? title,
|
||||||
|
Value<bool?>? deleted,
|
||||||
|
Value<int>? owner}) {
|
||||||
|
return GroupsCompanion(
|
||||||
|
id: id ?? this.id,
|
||||||
|
title: title ?? this.title,
|
||||||
|
deleted: deleted ?? this.deleted,
|
||||||
|
owner: owner ?? this.owner,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
|
final map = <String, Expression>{};
|
||||||
|
if (id.present) {
|
||||||
|
map['id'] = Variable<int>(id.value);
|
||||||
|
}
|
||||||
|
if (title.present) {
|
||||||
|
map['title'] = Variable<String>(title.value);
|
||||||
|
}
|
||||||
|
if (deleted.present) {
|
||||||
|
map['deleted'] = Variable<bool>(deleted.value);
|
||||||
|
}
|
||||||
|
if (owner.present) {
|
||||||
|
map['owner'] = Variable<int>(owner.value);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return (StringBuffer('GroupsCompanion(')
|
||||||
|
..write('id: $id, ')
|
||||||
|
..write('title: $title, ')
|
||||||
|
..write('deleted: $deleted, ')
|
||||||
|
..write('owner: $owner')
|
||||||
|
..write(')'))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Groups extends Table with TableInfo<Groups, GroupsData> {
|
||||||
|
@override
|
||||||
|
final GeneratedDatabase attachedDatabase;
|
||||||
|
final String? _alias;
|
||||||
|
Groups(this.attachedDatabase, [this._alias]);
|
||||||
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
||||||
|
'id', aliasedName, false,
|
||||||
|
type: DriftSqlType.int,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
$customConstraints: 'NOT NULL');
|
||||||
|
late final GeneratedColumn<String> title = GeneratedColumn<String>(
|
||||||
|
'title', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: 'NOT NULL');
|
||||||
|
late final GeneratedColumn<bool> deleted = GeneratedColumn<bool>(
|
||||||
|
'deleted', aliasedName, true,
|
||||||
|
type: DriftSqlType.bool,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
$customConstraints: 'DEFAULT FALSE',
|
||||||
|
defaultValue: const CustomExpression<bool>('FALSE'));
|
||||||
|
late final GeneratedColumn<int> owner = GeneratedColumn<int>(
|
||||||
|
'owner', aliasedName, false,
|
||||||
|
type: DriftSqlType.int,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: 'NOT NULL REFERENCES users (id)');
|
||||||
|
@override
|
||||||
|
List<GeneratedColumn> get $columns => [id, title, deleted, owner];
|
||||||
|
@override
|
||||||
|
String get aliasedName => _alias ?? 'groups';
|
||||||
|
@override
|
||||||
|
String get actualTableName => 'groups';
|
||||||
|
@override
|
||||||
|
Set<GeneratedColumn> get $primaryKey => {id};
|
||||||
|
@override
|
||||||
|
GroupsData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||||
|
return GroupsData(
|
||||||
|
id: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||||
|
title: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
||||||
|
deleted: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.bool, data['${effectivePrefix}deleted']),
|
||||||
|
owner: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.int, data['${effectivePrefix}owner'])!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Groups createAlias(String alias) {
|
||||||
|
return Groups(attachedDatabase, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<String> get customConstraints => const ['PRIMARY KEY (id)'];
|
||||||
|
@override
|
||||||
|
bool get dontWriteConstraints => true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class NotesData extends DataClass implements Insertable<NotesData> {
|
||||||
|
final String title;
|
||||||
|
final String content;
|
||||||
|
final String searchTerms;
|
||||||
|
const NotesData(
|
||||||
|
{required this.title, required this.content, required this.searchTerms});
|
||||||
|
@override
|
||||||
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
|
final map = <String, Expression>{};
|
||||||
|
map['title'] = Variable<String>(title);
|
||||||
|
map['content'] = Variable<String>(content);
|
||||||
|
map['search_terms'] = Variable<String>(searchTerms);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
NotesCompanion toCompanion(bool nullToAbsent) {
|
||||||
|
return NotesCompanion(
|
||||||
|
title: Value(title),
|
||||||
|
content: Value(content),
|
||||||
|
searchTerms: Value(searchTerms),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory NotesData.fromJson(Map<String, dynamic> json,
|
||||||
|
{ValueSerializer? serializer}) {
|
||||||
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
|
return NotesData(
|
||||||
|
title: serializer.fromJson<String>(json['title']),
|
||||||
|
content: serializer.fromJson<String>(json['content']),
|
||||||
|
searchTerms: serializer.fromJson<String>(json['searchTerms']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||||
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
|
return <String, dynamic>{
|
||||||
|
'title': serializer.toJson<String>(title),
|
||||||
|
'content': serializer.toJson<String>(content),
|
||||||
|
'searchTerms': serializer.toJson<String>(searchTerms),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
NotesData copyWith({String? title, String? content, String? searchTerms}) =>
|
||||||
|
NotesData(
|
||||||
|
title: title ?? this.title,
|
||||||
|
content: content ?? this.content,
|
||||||
|
searchTerms: searchTerms ?? this.searchTerms,
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return (StringBuffer('NotesData(')
|
||||||
|
..write('title: $title, ')
|
||||||
|
..write('content: $content, ')
|
||||||
|
..write('searchTerms: $searchTerms')
|
||||||
|
..write(')'))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(title, content, searchTerms);
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
(other is NotesData &&
|
||||||
|
other.title == this.title &&
|
||||||
|
other.content == this.content &&
|
||||||
|
other.searchTerms == this.searchTerms);
|
||||||
|
}
|
||||||
|
|
||||||
|
class NotesCompanion extends UpdateCompanion<NotesData> {
|
||||||
|
final Value<String> title;
|
||||||
|
final Value<String> content;
|
||||||
|
final Value<String> searchTerms;
|
||||||
|
const NotesCompanion({
|
||||||
|
this.title = const Value.absent(),
|
||||||
|
this.content = const Value.absent(),
|
||||||
|
this.searchTerms = const Value.absent(),
|
||||||
|
});
|
||||||
|
NotesCompanion.insert({
|
||||||
|
required String title,
|
||||||
|
required String content,
|
||||||
|
required String searchTerms,
|
||||||
|
}) : title = Value(title),
|
||||||
|
content = Value(content),
|
||||||
|
searchTerms = Value(searchTerms);
|
||||||
|
static Insertable<NotesData> custom({
|
||||||
|
Expression<String>? title,
|
||||||
|
Expression<String>? content,
|
||||||
|
Expression<String>? searchTerms,
|
||||||
|
}) {
|
||||||
|
return RawValuesInsertable({
|
||||||
|
if (title != null) 'title': title,
|
||||||
|
if (content != null) 'content': content,
|
||||||
|
if (searchTerms != null) 'search_terms': searchTerms,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
NotesCompanion copyWith(
|
||||||
|
{Value<String>? title,
|
||||||
|
Value<String>? content,
|
||||||
|
Value<String>? searchTerms}) {
|
||||||
|
return NotesCompanion(
|
||||||
|
title: title ?? this.title,
|
||||||
|
content: content ?? this.content,
|
||||||
|
searchTerms: searchTerms ?? this.searchTerms,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
|
final map = <String, Expression>{};
|
||||||
|
if (title.present) {
|
||||||
|
map['title'] = Variable<String>(title.value);
|
||||||
|
}
|
||||||
|
if (content.present) {
|
||||||
|
map['content'] = Variable<String>(content.value);
|
||||||
|
}
|
||||||
|
if (searchTerms.present) {
|
||||||
|
map['search_terms'] = Variable<String>(searchTerms.value);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return (StringBuffer('NotesCompanion(')
|
||||||
|
..write('title: $title, ')
|
||||||
|
..write('content: $content, ')
|
||||||
|
..write('searchTerms: $searchTerms')
|
||||||
|
..write(')'))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Notes extends Table
|
||||||
|
with TableInfo<Notes, NotesData>, VirtualTableInfo<Notes, NotesData> {
|
||||||
|
@override
|
||||||
|
final GeneratedDatabase attachedDatabase;
|
||||||
|
final String? _alias;
|
||||||
|
Notes(this.attachedDatabase, [this._alias]);
|
||||||
|
late final GeneratedColumn<String> title = GeneratedColumn<String>(
|
||||||
|
'title', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: '');
|
||||||
|
late final GeneratedColumn<String> content = GeneratedColumn<String>(
|
||||||
|
'content', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: '');
|
||||||
|
late final GeneratedColumn<String> searchTerms = GeneratedColumn<String>(
|
||||||
|
'search_terms', aliasedName, false,
|
||||||
|
type: DriftSqlType.string,
|
||||||
|
requiredDuringInsert: true,
|
||||||
|
$customConstraints: '');
|
||||||
|
@override
|
||||||
|
List<GeneratedColumn> get $columns => [title, content, searchTerms];
|
||||||
|
@override
|
||||||
|
String get aliasedName => _alias ?? 'notes';
|
||||||
|
@override
|
||||||
|
String get actualTableName => 'notes';
|
||||||
|
@override
|
||||||
|
Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
|
||||||
|
@override
|
||||||
|
NotesData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||||
|
return NotesData(
|
||||||
|
title: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
||||||
|
content: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.string, data['${effectivePrefix}content'])!,
|
||||||
|
searchTerms: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.string, data['${effectivePrefix}search_terms'])!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Notes createAlias(String alias) {
|
||||||
|
return Notes(attachedDatabase, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get dontWriteConstraints => true;
|
||||||
|
@override
|
||||||
|
String get moduleAndArgs =>
|
||||||
|
'fts5(title, content, search_terms, tokenize = "unicode61 tokenchars \'.\'")';
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupCountData extends DataClass {
|
||||||
|
final int id;
|
||||||
|
final String name;
|
||||||
|
final DateTime? birthday;
|
||||||
|
final int? nextUser;
|
||||||
|
final int groupCount;
|
||||||
|
const GroupCountData(
|
||||||
|
{required this.id,
|
||||||
|
required this.name,
|
||||||
|
this.birthday,
|
||||||
|
this.nextUser,
|
||||||
|
required this.groupCount});
|
||||||
|
factory GroupCountData.fromJson(Map<String, dynamic> json,
|
||||||
|
{ValueSerializer? serializer}) {
|
||||||
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
|
return GroupCountData(
|
||||||
|
id: serializer.fromJson<int>(json['id']),
|
||||||
|
name: serializer.fromJson<String>(json['name']),
|
||||||
|
birthday: serializer.fromJson<DateTime?>(json['birthday']),
|
||||||
|
nextUser: serializer.fromJson<int?>(json['nextUser']),
|
||||||
|
groupCount: serializer.fromJson<int>(json['groupCount']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||||
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
|
return <String, dynamic>{
|
||||||
|
'id': serializer.toJson<int>(id),
|
||||||
|
'name': serializer.toJson<String>(name),
|
||||||
|
'birthday': serializer.toJson<DateTime?>(birthday),
|
||||||
|
'nextUser': serializer.toJson<int?>(nextUser),
|
||||||
|
'groupCount': serializer.toJson<int>(groupCount),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupCountData copyWith(
|
||||||
|
{int? id,
|
||||||
|
String? name,
|
||||||
|
Value<DateTime?> birthday = const Value.absent(),
|
||||||
|
Value<int?> nextUser = const Value.absent(),
|
||||||
|
int? groupCount}) =>
|
||||||
|
GroupCountData(
|
||||||
|
id: id ?? this.id,
|
||||||
|
name: name ?? this.name,
|
||||||
|
birthday: birthday.present ? birthday.value : this.birthday,
|
||||||
|
nextUser: nextUser.present ? nextUser.value : this.nextUser,
|
||||||
|
groupCount: groupCount ?? this.groupCount,
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return (StringBuffer('GroupCountData(')
|
||||||
|
..write('id: $id, ')
|
||||||
|
..write('name: $name, ')
|
||||||
|
..write('birthday: $birthday, ')
|
||||||
|
..write('nextUser: $nextUser, ')
|
||||||
|
..write('groupCount: $groupCount')
|
||||||
|
..write(')'))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(id, name, birthday, nextUser, groupCount);
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
(other is GroupCountData &&
|
||||||
|
other.id == this.id &&
|
||||||
|
other.name == this.name &&
|
||||||
|
other.birthday == this.birthday &&
|
||||||
|
other.nextUser == this.nextUser &&
|
||||||
|
other.groupCount == this.groupCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupCount extends ViewInfo<GroupCount, GroupCountData>
|
||||||
|
implements HasResultSet {
|
||||||
|
final String? _alias;
|
||||||
|
@override
|
||||||
|
final DatabaseAtV7 attachedDatabase;
|
||||||
|
GroupCount(this.attachedDatabase, [this._alias]);
|
||||||
|
@override
|
||||||
|
List<GeneratedColumn> get $columns =>
|
||||||
|
[id, name, birthday, nextUser, groupCount];
|
||||||
|
@override
|
||||||
|
String get aliasedName => _alias ?? entityName;
|
||||||
|
@override
|
||||||
|
String get entityName => 'group_count';
|
||||||
|
@override
|
||||||
|
String? get createViewStmt => null;
|
||||||
|
@override
|
||||||
|
GroupCount get asDslTable => this;
|
||||||
|
@override
|
||||||
|
GroupCountData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||||
|
return GroupCountData(
|
||||||
|
id: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||||
|
name: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
||||||
|
birthday: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}birthday']),
|
||||||
|
nextUser: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
|
||||||
|
groupCount: attachedDatabase.options.types
|
||||||
|
.read(DriftSqlType.int, data['${effectivePrefix}group_count'])!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
late final GeneratedColumn<int> id =
|
||||||
|
GeneratedColumn<int>('id', aliasedName, false, type: DriftSqlType.int);
|
||||||
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
||||||
|
'name', aliasedName, false,
|
||||||
|
type: DriftSqlType.string);
|
||||||
|
late final GeneratedColumn<DateTime> birthday = GeneratedColumn<DateTime>(
|
||||||
|
'birthday', aliasedName, true,
|
||||||
|
type: DriftSqlType.dateTime);
|
||||||
|
late final GeneratedColumn<int> nextUser = GeneratedColumn<int>(
|
||||||
|
'next_user', aliasedName, true,
|
||||||
|
type: DriftSqlType.int);
|
||||||
|
late final GeneratedColumn<int> groupCount = GeneratedColumn<int>(
|
||||||
|
'group_count', aliasedName, false,
|
||||||
|
type: DriftSqlType.int);
|
||||||
|
@override
|
||||||
|
GroupCount createAlias(String alias) {
|
||||||
|
return GroupCount(attachedDatabase, alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Query? get query => null;
|
||||||
|
@override
|
||||||
|
Set<String> get readTables => const {};
|
||||||
|
}
|
||||||
|
|
||||||
|
class DatabaseAtV7 extends GeneratedDatabase {
|
||||||
|
DatabaseAtV7(QueryExecutor e) : super(e);
|
||||||
|
DatabaseAtV7.connect(DatabaseConnection c) : super.connect(c);
|
||||||
|
late final Users users = Users(this);
|
||||||
|
late final Groups groups = Groups(this);
|
||||||
|
late final GroupCount groupCount = GroupCount(this);
|
||||||
|
late final Notes notes = Notes(this);
|
||||||
|
@override
|
||||||
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
||||||
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
||||||
|
@override
|
||||||
|
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
||||||
|
[users, groups, groupCount, notes];
|
||||||
|
@override
|
||||||
|
int get schemaVersion => 7;
|
||||||
|
@override
|
||||||
|
DriftDatabaseOptions get options =>
|
||||||
|
const DriftDatabaseOptions(storeDateTimeAsText: true);
|
||||||
|
}
|
|
@ -20,7 +20,30 @@ void main() {
|
||||||
verifier = SchemaVerifier(GeneratedHelper());
|
verifier = SchemaVerifier(GeneratedHelper());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('upgrade from v1 to v2', () async {
|
// Test all possible schema migrations with a simple test that just ensures
|
||||||
|
// the schema is correct after the migration.
|
||||||
|
// More complex tests ensuring data integrity are written below.
|
||||||
|
group('general migration', () {
|
||||||
|
const currentSchema = 7;
|
||||||
|
|
||||||
|
for (var oldVersion = 1; oldVersion < currentSchema; oldVersion++) {
|
||||||
|
group('from v$oldVersion', () {
|
||||||
|
for (var targetVersion = oldVersion + 1;
|
||||||
|
targetVersion <= currentSchema;
|
||||||
|
targetVersion++) {
|
||||||
|
test('to v$targetVersion', () async {
|
||||||
|
final connection = await verifier.startAt(1);
|
||||||
|
final db = Database(connection);
|
||||||
|
addTearDown(db.close);
|
||||||
|
|
||||||
|
await verifier.migrateAndValidate(db, targetVersion);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('preserves existing data in migration from v1 to v2', () async {
|
||||||
final schema = await verifier.schemaAt(1);
|
final schema = await verifier.schemaAt(1);
|
||||||
|
|
||||||
// Add some data to the users table, which only has an id column at v1
|
// Add some data to the users table, which only has an id column at v1
|
||||||
|
@ -41,23 +64,7 @@ void main() {
|
||||||
await migratedDb.close();
|
await migratedDb.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('upgrade from v2 to v3', () async {
|
test('foreign key constraints work after upgrade from v4 to v5', () async {
|
||||||
final connection = await verifier.startAt(2);
|
|
||||||
final db = Database(connection);
|
|
||||||
|
|
||||||
await verifier.migrateAndValidate(db, 3);
|
|
||||||
await db.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('upgrade from v3 to v4', () async {
|
|
||||||
final connection = await verifier.startAt(3);
|
|
||||||
final db = Database(connection);
|
|
||||||
|
|
||||||
await verifier.migrateAndValidate(db, 4);
|
|
||||||
await db.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('upgrade from v4 to v5', () async {
|
|
||||||
final schema = await verifier.schemaAt(4);
|
final schema = await verifier.schemaAt(4);
|
||||||
final db = Database(schema.newConnection());
|
final db = Database(schema.newConnection());
|
||||||
await verifier.migrateAndValidate(db, 5);
|
await verifier.migrateAndValidate(db, 5);
|
||||||
|
@ -112,12 +119,4 @@ void main() {
|
||||||
.having((e) => e.groupCount, 'groupCount', 0)));
|
.having((e) => e.groupCount, 'groupCount', 0)));
|
||||||
await migratedDb.close();
|
await migratedDb.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('upgrade from v5 to v6', () async {
|
|
||||||
final connection = await verifier.startAt(5);
|
|
||||||
final db = Database(connection);
|
|
||||||
addTearDown(db.close);
|
|
||||||
|
|
||||||
await verifier.migrateAndValidate(db, 6);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue