mirror of https://github.com/AMT-Cheif/drift.git
Add step-by-step migration API
This commit is contained in:
parent
8b7872fc67
commit
ed9aeb866a
|
@ -2,15 +2,15 @@ import 'package:drift/drift.dart';
|
||||||
|
|
||||||
abstract base class VersionedSchema {
|
abstract base class VersionedSchema {
|
||||||
final DatabaseConnectionUser database;
|
final DatabaseConnectionUser database;
|
||||||
|
final int version;
|
||||||
|
|
||||||
VersionedSchema(this.database);
|
VersionedSchema({required this.database, required this.version});
|
||||||
|
|
||||||
DatabaseSchemaEntity lookup(String name, int version) {
|
Iterable<DatabaseSchemaEntity> get entities;
|
||||||
return allEntitiesAt(version)
|
|
||||||
.singleWhere((element) => element.entityName == name);
|
DatabaseSchemaEntity lookup(String name) {
|
||||||
|
return entities.singleWhere((element) => element.entityName == name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<DatabaseSchemaEntity> allEntitiesAt(int version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class VersionedTable extends Table with TableInfo<Table, QueryRow> {
|
class VersionedTable extends Table with TableInfo<Table, QueryRow> {
|
||||||
|
@ -29,6 +29,10 @@ class VersionedTable extends Table with TableInfo<Table, QueryRow> {
|
||||||
@override
|
@override
|
||||||
final List<GeneratedColumn> $columns;
|
final List<GeneratedColumn> $columns;
|
||||||
|
|
||||||
|
/// List of columns, represented as a function that returns the generated
|
||||||
|
/// column when given the resolved table name.
|
||||||
|
final List<GeneratedColumn Function(String)> _columnFactories;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final List<String> customConstraints;
|
final List<String> customConstraints;
|
||||||
|
|
||||||
|
@ -40,10 +44,26 @@ class VersionedTable extends Table with TableInfo<Table, QueryRow> {
|
||||||
required List<GeneratedColumn Function(String)> columns,
|
required List<GeneratedColumn Function(String)> columns,
|
||||||
required List<String> tableConstraints,
|
required List<String> tableConstraints,
|
||||||
String? alias,
|
String? alias,
|
||||||
}) : customConstraints = tableConstraints,
|
}) : _columnFactories = columns,
|
||||||
|
customConstraints = tableConstraints,
|
||||||
$columns = [for (final column in columns) column(alias ?? entityName)],
|
$columns = [for (final column in columns) column(alias ?? entityName)],
|
||||||
_alias = alias;
|
_alias = alias;
|
||||||
|
|
||||||
|
VersionedTable.aliased({
|
||||||
|
required VersionedTable source,
|
||||||
|
required String? alias,
|
||||||
|
}) : entityName = source.entityName,
|
||||||
|
isStrict = source.isStrict,
|
||||||
|
withoutRowId = source.withoutRowId,
|
||||||
|
attachedDatabase = source.attachedDatabase,
|
||||||
|
customConstraints = source.customConstraints,
|
||||||
|
_columnFactories = source._columnFactories,
|
||||||
|
$columns = [
|
||||||
|
for (final column in source._columnFactories)
|
||||||
|
column(alias ?? source.entityName)
|
||||||
|
],
|
||||||
|
_alias = alias;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get actualTableName => entityName;
|
String get actualTableName => entityName;
|
||||||
|
|
||||||
|
@ -53,21 +73,111 @@ class VersionedTable extends Table with TableInfo<Table, QueryRow> {
|
||||||
@override
|
@override
|
||||||
bool get dontWriteConstraints => true;
|
bool get dontWriteConstraints => true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
QueryRow map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
|
return QueryRow(data, attachedDatabase);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
VersionedTable createAlias(String alias) {
|
VersionedTable createAlias(String alias) {
|
||||||
return VersionedTable(
|
return VersionedTable.aliased(source: this, alias: alias);
|
||||||
entityName: entityName,
|
}
|
||||||
isStrict: isStrict,
|
}
|
||||||
withoutRowId: withoutRowId,
|
|
||||||
attachedDatabase: attachedDatabase,
|
class VersionedVirtualTable extends VersionedTable
|
||||||
columns: $columns,
|
with VirtualTableInfo<Table, QueryRow> {
|
||||||
tableConstraints: customConstraints,
|
@override
|
||||||
|
final String moduleAndArgs;
|
||||||
|
|
||||||
|
VersionedVirtualTable({
|
||||||
|
required super.entityName,
|
||||||
|
required super.attachedDatabase,
|
||||||
|
required super.columns,
|
||||||
|
required this.moduleAndArgs,
|
||||||
|
super.alias,
|
||||||
|
}) : super(
|
||||||
|
isStrict: false,
|
||||||
|
withoutRowId: false,
|
||||||
|
tableConstraints: [],
|
||||||
|
);
|
||||||
|
|
||||||
|
VersionedVirtualTable.aliased(
|
||||||
|
{required VersionedVirtualTable source, required String? alias})
|
||||||
|
: moduleAndArgs = source.moduleAndArgs,
|
||||||
|
super.aliased(source: source, alias: alias);
|
||||||
|
|
||||||
|
@override
|
||||||
|
VersionedVirtualTable createAlias(String alias) {
|
||||||
|
return VersionedVirtualTable.aliased(
|
||||||
|
source: this,
|
||||||
alias: alias,
|
alias: alias,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class VersionedView implements ViewInfo<HasResultSet, QueryRow>, HasResultSet {
|
||||||
|
@override
|
||||||
|
final String entityName;
|
||||||
|
final String? _alias;
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String createViewStmt;
|
||||||
|
|
||||||
|
@override
|
||||||
|
final List<GeneratedColumn> $columns;
|
||||||
|
|
||||||
|
@override
|
||||||
|
late final Map<String, GeneratedColumn> columnsByName = {
|
||||||
|
for (final column in $columns) column.name: column,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// List of columns, represented as a function that returns the generated
|
||||||
|
/// column when given the resolved table name.
|
||||||
|
final List<GeneratedColumn Function(String)> _columnFactories;
|
||||||
|
|
||||||
|
@override
|
||||||
|
final DatabaseConnectionUser attachedDatabase;
|
||||||
|
|
||||||
|
VersionedView({
|
||||||
|
required this.entityName,
|
||||||
|
required this.attachedDatabase,
|
||||||
|
required this.createViewStmt,
|
||||||
|
required List<GeneratedColumn Function(String)> columns,
|
||||||
|
String? alias,
|
||||||
|
}) : _columnFactories = columns,
|
||||||
|
$columns = [for (final column in columns) column(alias ?? entityName)],
|
||||||
|
_alias = alias;
|
||||||
|
|
||||||
|
VersionedView.aliased({required VersionedView source, required String? alias})
|
||||||
|
: entityName = source.entityName,
|
||||||
|
attachedDatabase = source.attachedDatabase,
|
||||||
|
createViewStmt = source.createViewStmt,
|
||||||
|
_columnFactories = source._columnFactories,
|
||||||
|
$columns = [
|
||||||
|
for (final column in source._columnFactories)
|
||||||
|
column(alias ?? source.entityName)
|
||||||
|
],
|
||||||
|
_alias = alias;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get aliasedName => _alias ?? entityName;
|
||||||
|
|
||||||
|
@override
|
||||||
|
HasResultSet get asDslTable => this;
|
||||||
|
|
||||||
|
@override
|
||||||
|
VersionedView createAlias(String alias) {
|
||||||
|
return VersionedView.aliased(source: this, alias: alias);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
QueryRow map(Map<String, dynamic> data, {String? tablePrefix}) {
|
QueryRow map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
return QueryRow(data, attachedDatabase);
|
return QueryRow(data, attachedDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Query<HasResultSet, dynamic>? get query => null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Set<String> get readTables => const {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,14 +49,22 @@ class MigrationStrategy {
|
||||||
/// Runs migrations declared by a [MigrationStrategy].
|
/// Runs migrations declared by a [MigrationStrategy].
|
||||||
class Migrator {
|
class Migrator {
|
||||||
final GeneratedDatabase _db;
|
final GeneratedDatabase _db;
|
||||||
|
final VersionedSchema? _fixedVersion;
|
||||||
|
|
||||||
/// Used internally by drift when opening the database.
|
/// Used internally by drift when opening the database.
|
||||||
Migrator(this._db);
|
Migrator(this._db, [this._fixedVersion]);
|
||||||
|
|
||||||
|
Iterable<DatabaseSchemaEntity> get _allSchemaEntities {
|
||||||
|
return switch (_fixedVersion) {
|
||||||
|
null => _db.allSchemaEntities,
|
||||||
|
var fixed => fixed.entities,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates all tables specified for the database, if they don't exist
|
/// Creates all tables specified for the database, if they don't exist
|
||||||
@Deprecated('Use createAll() instead')
|
@Deprecated('Use createAll() instead')
|
||||||
Future<void> createAllTables() async {
|
Future<void> createAllTables() async {
|
||||||
for (final table in _db.allTables) {
|
for (final table in _allSchemaEntities.whereType<TableInfo>()) {
|
||||||
await createTable(table);
|
await createTable(table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +72,7 @@ class Migrator {
|
||||||
/// Creates all tables, triggers, views, indexes and everything else defined
|
/// Creates all tables, triggers, views, indexes and everything else defined
|
||||||
/// in the database, if they don't exist.
|
/// in the database, if they don't exist.
|
||||||
Future<void> createAll() async {
|
Future<void> createAll() async {
|
||||||
for (final entity in _db.allSchemaEntities) {
|
for (final entity in _allSchemaEntities) {
|
||||||
await create(entity);
|
await create(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +102,7 @@ class Migrator {
|
||||||
/// a view reads from may also warrant re-creating the view to make sure it's
|
/// a view reads from may also warrant re-creating the view to make sure it's
|
||||||
/// still valid.
|
/// still valid.
|
||||||
Future<void> recreateAllViews() async {
|
Future<void> recreateAllViews() async {
|
||||||
for (final entity in _db.allSchemaEntities) {
|
for (final entity in _allSchemaEntities) {
|
||||||
if (entity is ViewInfo) {
|
if (entity is ViewInfo) {
|
||||||
await drop(entity);
|
await drop(entity);
|
||||||
await createView(entity);
|
await createView(entity);
|
||||||
|
@ -119,7 +127,7 @@ class Migrator {
|
||||||
return _issueCustomQuery(context.sql, context.boundVariables);
|
return _issueCustomQuery(context.sql, context.boundVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Experimental utility method to alter columns of an existing table.
|
/// Alter columns of an existing tabe.
|
||||||
///
|
///
|
||||||
/// Since sqlite does not provide a way to alter the type or constraint of an
|
/// Since sqlite does not provide a way to alter the type or constraint of an
|
||||||
/// individual column, one needs to write a fairly complex migration procedure
|
/// individual column, one needs to write a fairly complex migration procedure
|
||||||
|
@ -141,7 +149,6 @@ class Migrator {
|
||||||
///
|
///
|
||||||
/// [other alter]: https://www.sqlite.org/lang_altertable.html#otheralter
|
/// [other alter]: https://www.sqlite.org/lang_altertable.html#otheralter
|
||||||
/// [drift docs]: https://drift.simonbinder.eu/docs/advanced-features/migrations/#complex-migrations
|
/// [drift docs]: https://drift.simonbinder.eu/docs/advanced-features/migrations/#complex-migrations
|
||||||
@experimental
|
|
||||||
Future<void> alterTable(TableMigration migration) async {
|
Future<void> alterTable(TableMigration migration) async {
|
||||||
final foreignKeysEnabled =
|
final foreignKeysEnabled =
|
||||||
(await _db.customSelect('PRAGMA foreign_keys').getSingle())
|
(await _db.customSelect('PRAGMA foreign_keys').getSingle())
|
||||||
|
@ -474,6 +481,22 @@ class Migrator {
|
||||||
Future<void> _issueCustomQuery(String sql, [List<dynamic>? args]) {
|
Future<void> _issueCustomQuery(String sql, [List<dynamic>? args]) {
|
||||||
return _db.customStatement(sql, args);
|
return _db.customStatement(sql, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@experimental
|
||||||
|
static OnUpgrade stepByStepHelper({
|
||||||
|
required Future<int> Function(
|
||||||
|
int currentVersion,
|
||||||
|
GeneratedDatabase database,
|
||||||
|
) step,
|
||||||
|
}) {
|
||||||
|
return (m, from, to) async {
|
||||||
|
final database = m._db;
|
||||||
|
|
||||||
|
for (var target = from; target < to;) {
|
||||||
|
target = await step(target, database);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Provides information about whether migrations ran before opening the
|
/// Provides information about whether migrations ran before opening the
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'dart:collection';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:drift/internal/versioned_schema.dart';
|
||||||
import 'package:drift/src/dsl/dsl.dart';
|
import 'package:drift/src/dsl/dsl.dart';
|
||||||
import 'package:drift/src/runtime/api/options.dart';
|
import 'package:drift/src/runtime/api/options.dart';
|
||||||
import 'package:drift/src/runtime/api/runtime_api.dart';
|
import 'package:drift/src/runtime/api/runtime_api.dart';
|
||||||
|
|
|
@ -49,7 +49,7 @@ class DriftTable extends DriftElementWithResultSet {
|
||||||
/// when creating the `CREATE TABLE` statement at runtime.
|
/// when creating the `CREATE TABLE` statement at runtime.
|
||||||
final bool writeDefaultConstraints;
|
final bool writeDefaultConstraints;
|
||||||
|
|
||||||
/// When non-null, the generated table class will override the
|
/// When non-empty, the generated table class will override the
|
||||||
/// `customConstraints` getter in the table class with this value.
|
/// `customConstraints` getter in the table class with this value.
|
||||||
final List<String> overrideTableConstraints;
|
final List<String> overrideTableConstraints;
|
||||||
|
|
||||||
|
@ -169,21 +169,21 @@ class DriftTable extends DriftElementWithResultSet {
|
||||||
'\$${className}Table';
|
'\$${className}Table';
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class DriftTableConstraint {}
|
sealed class DriftTableConstraint {}
|
||||||
|
|
||||||
class UniqueColumns extends DriftTableConstraint {
|
final class UniqueColumns extends DriftTableConstraint {
|
||||||
final Set<DriftColumn> uniqueSet;
|
final Set<DriftColumn> uniqueSet;
|
||||||
|
|
||||||
UniqueColumns(this.uniqueSet);
|
UniqueColumns(this.uniqueSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PrimaryKeyColumns extends DriftTableConstraint {
|
final class PrimaryKeyColumns extends DriftTableConstraint {
|
||||||
final Set<DriftColumn> primaryKey;
|
final Set<DriftColumn> primaryKey;
|
||||||
|
|
||||||
PrimaryKeyColumns(this.primaryKey);
|
PrimaryKeyColumns(this.primaryKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ForeignKeyTable extends DriftTableConstraint {
|
final class ForeignKeyTable extends DriftTableConstraint {
|
||||||
final List<DriftColumn> localColumns;
|
final List<DriftColumn> localColumns;
|
||||||
final DriftTable otherTable;
|
final DriftTable otherTable;
|
||||||
|
|
||||||
|
@ -214,6 +214,12 @@ class VirtualTableData {
|
||||||
|
|
||||||
final RecognizedVirtualTableModule? recognized;
|
final RecognizedVirtualTableModule? recognized;
|
||||||
|
|
||||||
|
/// The module and the arguments in a single string, suitable for `CREATE
|
||||||
|
/// VIRTUAL TABLE` statements.
|
||||||
|
String get moduleAndArgs {
|
||||||
|
return '$module(${moduleArguments.join(', ')})';
|
||||||
|
}
|
||||||
|
|
||||||
VirtualTableData(this.module, this.moduleArguments, this.recognized);
|
VirtualTableData(this.module, this.moduleArguments, this.recognized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import 'schema/dump.dart';
|
||||||
import 'schema/generate_utils.dart';
|
import 'schema/generate_utils.dart';
|
||||||
|
|
||||||
import '../cli.dart';
|
import '../cli.dart';
|
||||||
import 'schema/versions.dart';
|
import 'schema/steps.dart';
|
||||||
|
|
||||||
class SchemaCommand extends Command {
|
class SchemaCommand extends Command {
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -18,7 +18,7 @@ class WriteVersions extends Command {
|
||||||
WriteVersions(this.cli);
|
WriteVersions(this.cli);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get name => 'versions';
|
String get name => 'steps';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get description =>
|
String get description =>
|
||||||
|
@ -26,7 +26,7 @@ class WriteVersions extends Command {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get invocation {
|
String get invocation {
|
||||||
return '${runner!.executableName} schema versions <schema directory> <output file>';
|
return '${runner!.executableName} schema steps <schema directory> <output file>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
|
@ -1,4 +1,7 @@
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:drift/drift.dart' show DriftSqlType;
|
||||||
|
import 'package:sqlparser/sqlparser.dart' as sql;
|
||||||
|
import 'package:sqlparser/utils/node_to_text.dart';
|
||||||
|
|
||||||
import '../analysis/results/results.dart';
|
import '../analysis/results/results.dart';
|
||||||
import '../utils/string_escaper.dart';
|
import '../utils/string_escaper.dart';
|
||||||
|
@ -13,60 +16,231 @@ class SchemaVersion {
|
||||||
SchemaVersion(this.version, this.schema, this.options);
|
SchemaVersion(this.version, this.schema, this.options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum _ResultSetKind {
|
||||||
|
table,
|
||||||
|
virtualTable,
|
||||||
|
view,
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _TableShape {
|
||||||
|
final _ResultSetKind kind;
|
||||||
|
// Map from Dart getter names to column names in SQL and the SQL type.
|
||||||
|
final Map<String, (String, DriftSqlType)> columnTypes;
|
||||||
|
|
||||||
|
_TableShape(this.kind, this.columnTypes);
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(kind, _equality.hash(columnTypes));
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is _TableShape &&
|
||||||
|
other.kind == kind &&
|
||||||
|
_equality.equals(other.columnTypes, columnTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const _equality = MapEquality<String, (String, DriftSqlType)>();
|
||||||
|
|
||||||
|
static Map<String, (String, DriftSqlType)> columnsFrom(
|
||||||
|
DriftElementWithResultSet e) {
|
||||||
|
return {
|
||||||
|
for (final column in e.columns)
|
||||||
|
column.nameInDart: (column.nameInSql, column.sqlType),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class SchemaVersionWriter {
|
class SchemaVersionWriter {
|
||||||
static final Uri _schemaLibrary =
|
static final Uri _schemaLibrary =
|
||||||
Uri.parse('package:drift/internal/versioned_schema.dart');
|
Uri.parse('package:drift/internal/versioned_schema.dart');
|
||||||
|
|
||||||
/// All schema versions, sorted by [SchemaVersion.version].
|
/// All schema versions, sorted by [SchemaVersion.version].
|
||||||
final List<SchemaVersion> versions;
|
final List<SchemaVersion> versions;
|
||||||
final Scope scope;
|
final Scope libraryScope;
|
||||||
|
|
||||||
final Map<String, String> _columnCodeToFactory = {};
|
final Map<String, String> _columnCodeToFactory = {};
|
||||||
|
final Map<_TableShape, String> _shapes = {};
|
||||||
|
|
||||||
/// All schema entities across all versions are put in a single list, sorted
|
SchemaVersionWriter(this.versions, this.libraryScope);
|
||||||
/// by their schema version.
|
|
||||||
///
|
|
||||||
/// By keeping a start and end-index pair for each schema, we can efficiently
|
|
||||||
/// find all schema entities for a given version at runtime.
|
|
||||||
final rangesForVersion = <(int, int)>[];
|
|
||||||
|
|
||||||
SchemaVersionWriter(this.versions, this.scope);
|
|
||||||
|
|
||||||
String _referenceColumn(DriftColumn column) {
|
String _referenceColumn(DriftColumn column) {
|
||||||
final text = scope.leaf();
|
final text = libraryScope.leaf();
|
||||||
final (type, code) = TableOrViewWriter.instantiateColumn(column, text);
|
final (type, code) = TableOrViewWriter.instantiateColumn(column, text);
|
||||||
|
|
||||||
return _columnCodeToFactory.putIfAbsent(code, () {
|
return _columnCodeToFactory.putIfAbsent(code, () {
|
||||||
final methodName = 'column_${_columnCodeToFactory.length}';
|
final methodName = '_column_${_columnCodeToFactory.length}';
|
||||||
text.write('$type $methodName(String aliasedName) => $code;');
|
text.writeln('$type $methodName(String aliasedName) => $code;');
|
||||||
return methodName;
|
return methodName;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _writeTable(DriftTable table, TextEmitter writer) {
|
void _writeColumnsArgument(List<DriftColumn> columns, TextEmitter writer) {
|
||||||
writer
|
writer.write('columns: [');
|
||||||
..writeUriRef(_schemaLibrary, 'VersionedTable(')
|
|
||||||
..write('entityName: ${asDartLiteral(table.schemaName)},')
|
|
||||||
..write('withoutRowId: ${table.withoutRowId},')
|
|
||||||
..write('isStrict: ${table.strict},')
|
|
||||||
..write('attachedDatabase: database,')
|
|
||||||
..write('columns: [');
|
|
||||||
|
|
||||||
for (final column in table.columns) {
|
for (final column in columns) {
|
||||||
writer
|
writer
|
||||||
..write(_referenceColumn(column))
|
..write(_referenceColumn(column))
|
||||||
..write(',');
|
..write(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
writer
|
writer.write('],');
|
||||||
..write('],')
|
|
||||||
..write('tableConstraints: [],')
|
|
||||||
..write(')');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _writeEntity(DriftSchemaElement element, TextEmitter writer) {
|
String _shapeClass(DriftElementWithResultSet resultSet) {
|
||||||
if (element is DriftTable) {
|
final (kind, superclass) = switch (resultSet) {
|
||||||
_writeTable(element, writer);
|
DriftTable(virtualTableData: null) => (
|
||||||
|
_ResultSetKind.table,
|
||||||
|
'VersionedTable'
|
||||||
|
),
|
||||||
|
DriftTable() => (_ResultSetKind.virtualTable, 'VersionedVirtualTable'),
|
||||||
|
DriftView() => (_ResultSetKind.view, 'VersionedView'),
|
||||||
|
_ => throw ArgumentError.value(resultSet, 'resultSet', 'Unknown type'),
|
||||||
|
};
|
||||||
|
|
||||||
|
final shape = _TableShape(kind, _TableShape.columnsFrom(resultSet));
|
||||||
|
return _shapes.putIfAbsent(shape, () {
|
||||||
|
final className = 'Shape${_shapes.length}';
|
||||||
|
final classWriter = libraryScope.leaf();
|
||||||
|
|
||||||
|
classWriter
|
||||||
|
..write('class $className extends ')
|
||||||
|
..writeUriRef(_schemaLibrary, superclass)
|
||||||
|
..writeln('{')
|
||||||
|
..writeln(
|
||||||
|
'$className({required super.source, required super.alias}) : super.aliased();');
|
||||||
|
|
||||||
|
for (final MapEntry(key: getterName, value: (sqlName, type))
|
||||||
|
in shape.columnTypes.entries) {
|
||||||
|
final columnType = AnnotatedDartCode([dartTypeNames[type]!]);
|
||||||
|
|
||||||
|
classWriter
|
||||||
|
..writeDriftRef('GeneratedColumn<')
|
||||||
|
..writeDart(columnType)
|
||||||
|
..write('> get ')
|
||||||
|
..write(getterName)
|
||||||
|
..write(' => columnsByName[${asDartLiteral(sqlName)}]! as ')
|
||||||
|
..writeDriftRef('GeneratedColumn<')
|
||||||
|
..writeDart(columnType)
|
||||||
|
..writeln('>;');
|
||||||
|
}
|
||||||
|
|
||||||
|
classWriter.writeln('}');
|
||||||
|
|
||||||
|
return className;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _writeWithResultSet(DriftElementWithResultSet entity, Scope classScope,
|
||||||
|
TextEmitter intoListWriter) {
|
||||||
|
final getterName = entity.dbGetterName;
|
||||||
|
final shape = _shapeClass(entity);
|
||||||
|
final writer = classScope.leaf()
|
||||||
|
..write('late final $shape $getterName = ')
|
||||||
|
..write('$shape(source: ');
|
||||||
|
|
||||||
|
switch (entity) {
|
||||||
|
case DriftTable():
|
||||||
|
if (entity.isVirtual) {
|
||||||
|
final info = entity.virtualTableData!;
|
||||||
|
|
||||||
|
writer
|
||||||
|
..writeUriRef(_schemaLibrary, 'VersionedVirtualTable(')
|
||||||
|
..write('entityName: ${asDartLiteral(entity.schemaName)},')
|
||||||
|
..write('moduleAndArgs: ${asDartLiteral(info.moduleAndArgs)},');
|
||||||
|
} else {
|
||||||
|
final tableConstraints = <String>[];
|
||||||
|
|
||||||
|
if (entity.writeDefaultConstraints) {
|
||||||
|
// We don't override primaryKey and uniqueKey in generated table
|
||||||
|
// classes to keep the code shorter. The migrator would use those
|
||||||
|
// getters to generate SQL at runtime, which means that this burden
|
||||||
|
// now falls onto the generator.
|
||||||
|
for (final constraint in entity.tableConstraints) {
|
||||||
|
final astNode = switch (constraint) {
|
||||||
|
PrimaryKeyColumns(primaryKey: var columns) => sql.KeyClause(
|
||||||
|
null,
|
||||||
|
isPrimaryKey: true,
|
||||||
|
columns: [
|
||||||
|
for (final column in columns)
|
||||||
|
sql.IndexedColumn(
|
||||||
|
sql.Reference(columnName: column.nameInSql))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
UniqueColumns(uniqueSet: var columns) => sql.KeyClause(
|
||||||
|
null,
|
||||||
|
isPrimaryKey: false,
|
||||||
|
columns: [
|
||||||
|
for (final column in columns)
|
||||||
|
sql.IndexedColumn(
|
||||||
|
sql.Reference(columnName: column.nameInSql))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
ForeignKeyTable() => sql.ForeignKeyTableConstraint(
|
||||||
|
null,
|
||||||
|
columns: [
|
||||||
|
for (final column in constraint.localColumns)
|
||||||
|
sql.Reference(columnName: column.nameInSql)
|
||||||
|
],
|
||||||
|
clause: sql.ForeignKeyClause(
|
||||||
|
foreignTable:
|
||||||
|
sql.TableReference(constraint.otherTable.schemaName),
|
||||||
|
columnNames: [
|
||||||
|
for (final column in constraint.otherColumns)
|
||||||
|
sql.Reference(columnName: column.nameInSql)
|
||||||
|
],
|
||||||
|
onUpdate: constraint.onUpdate,
|
||||||
|
onDelete: constraint.onDelete,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
tableConstraints.add(astNode.toSql());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tableConstraints.addAll(entity.overrideTableConstraints.toList());
|
||||||
|
|
||||||
|
writer
|
||||||
|
..writeUriRef(_schemaLibrary, 'VersionedTable(')
|
||||||
|
..write('entityName: ${asDartLiteral(entity.schemaName)},')
|
||||||
|
..write('withoutRowId: ${entity.withoutRowId},')
|
||||||
|
..write('isStrict: ${entity.strict},')
|
||||||
|
..write('tableConstraints: [');
|
||||||
|
|
||||||
|
for (final constraint in tableConstraints) {
|
||||||
|
writer
|
||||||
|
..write(asDartLiteral(constraint))
|
||||||
|
..write(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.write('],');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DriftView():
|
||||||
|
final source = entity.source as SqlViewSource;
|
||||||
|
|
||||||
|
writer
|
||||||
|
..writeUriRef(_schemaLibrary, 'VersionedView(')
|
||||||
|
..write('entityName: ${asDartLiteral(entity.schemaName)},')
|
||||||
|
..write(
|
||||||
|
'createViewStmt: ${asDartLiteral(source.sqlCreateViewStmt)},');
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_writeColumnsArgument(entity.columns, writer);
|
||||||
|
writer.write('attachedDatabase: database,');
|
||||||
|
writer.write('), alias: null);');
|
||||||
|
|
||||||
|
intoListWriter.write(getterName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _writeEntity({
|
||||||
|
required DriftSchemaElement element,
|
||||||
|
required Scope classScope,
|
||||||
|
required TextEmitter writer,
|
||||||
|
}) {
|
||||||
|
if (element is DriftElementWithResultSet) {
|
||||||
|
_writeWithResultSet(element, classScope, writer);
|
||||||
} else if (element is DriftIndex) {
|
} else if (element is DriftIndex) {
|
||||||
writer
|
writer
|
||||||
..writeDriftRef('Index(')
|
..writeDriftRef('Index(')
|
||||||
|
@ -86,68 +260,92 @@ class SchemaVersionWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _implementAllEntitiesAt(TextEmitter writer) {
|
|
||||||
writer
|
|
||||||
..writeln('@override')
|
|
||||||
..write('Iterable<')
|
|
||||||
..writeDriftRef('DatabaseSchemaEntity')
|
|
||||||
..writeln('> allEntitiesAt(int version) {')
|
|
||||||
..writeln('int start, count;')
|
|
||||||
..writeln('switch (version) {');
|
|
||||||
|
|
||||||
versions.forEachIndexed((index, schema) {
|
|
||||||
final (start, end) = rangesForVersion[index];
|
|
||||||
|
|
||||||
writer
|
|
||||||
..writeln('case ${schema.version}:')
|
|
||||||
..writeln('start = $start;')
|
|
||||||
..writeln('count = ${end - start};');
|
|
||||||
});
|
|
||||||
|
|
||||||
writer
|
|
||||||
..writeln('default:')
|
|
||||||
..writeln(r"throw ArgumentError('Unknown schema version $version');");
|
|
||||||
|
|
||||||
writer
|
|
||||||
..writeln('}')
|
|
||||||
..writeln('return entities.skip(start).take(count);')
|
|
||||||
..writeln('}');
|
|
||||||
}
|
|
||||||
|
|
||||||
void write() {
|
void write() {
|
||||||
final classWriter = scope.leaf();
|
|
||||||
|
|
||||||
classWriter
|
|
||||||
..write('final class VersionedSchema extends ')
|
|
||||||
..writeUriRef(_schemaLibrary, 'VersionedSchema')
|
|
||||||
..writeln('{')
|
|
||||||
..writeln('VersionedSchema(super.database);');
|
|
||||||
|
|
||||||
var currentIndex = 0;
|
|
||||||
classWriter
|
|
||||||
..write('late final ')
|
|
||||||
..writeUriRef(AnnotatedDartCode.dartCore, 'List')
|
|
||||||
..write('<')
|
|
||||||
..writeDriftRef('DatabaseSchemaEntity')
|
|
||||||
..write('> entities = [');
|
|
||||||
|
|
||||||
for (final version in versions) {
|
for (final version in versions) {
|
||||||
classWriter.writeln(' // VERSION ${version.version}');
|
final versionNo = version.version;
|
||||||
final startIndex = currentIndex;
|
final versionClass = '_S$versionNo';
|
||||||
|
final versionScope = libraryScope.child();
|
||||||
|
|
||||||
|
versionScope.leaf()
|
||||||
|
..write('final class $versionClass extends ')
|
||||||
|
..writeUriRef(_schemaLibrary, 'VersionedSchema')
|
||||||
|
..writeln('{')
|
||||||
|
..writeln('$versionClass({required super.database}): '
|
||||||
|
'super(version: $versionNo);');
|
||||||
|
|
||||||
|
final allEntitiesWriter = versionScope.leaf()
|
||||||
|
..write('@override')
|
||||||
|
..write(' late final ')
|
||||||
|
..writeUriRef(AnnotatedDartCode.dartCore, 'List')
|
||||||
|
..write('<')
|
||||||
|
..writeDriftRef('DatabaseSchemaEntity')
|
||||||
|
..write('> entities = [');
|
||||||
|
|
||||||
for (final entity in version.schema) {
|
for (final entity in version.schema) {
|
||||||
_writeEntity(entity, classWriter);
|
_writeEntity(
|
||||||
classWriter.writeln(',');
|
element: entity,
|
||||||
currentIndex++;
|
classScope: versionScope,
|
||||||
|
writer: allEntitiesWriter,
|
||||||
|
);
|
||||||
|
allEntitiesWriter.write(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
final endIndex = currentIndex;
|
allEntitiesWriter.write('];');
|
||||||
rangesForVersion.add((startIndex, endIndex));
|
versionScope.leaf().writeln('}');
|
||||||
}
|
}
|
||||||
classWriter.write('];');
|
|
||||||
|
|
||||||
_implementAllEntitiesAt(classWriter);
|
final stepByStep = libraryScope.leaf()
|
||||||
|
..writeDriftRef('OnUpgrade')
|
||||||
|
..write(' stepByStep({');
|
||||||
|
|
||||||
classWriter.writeln('}');
|
for (final (current, next) in versions.withNext) {
|
||||||
|
stepByStep
|
||||||
|
..write('required Future<void> Function(')
|
||||||
|
..writeDriftRef('Migrator')
|
||||||
|
..write(' m, _S${next.version} schema)')
|
||||||
|
..writeln('from${current.version}To${next.version},');
|
||||||
|
}
|
||||||
|
|
||||||
|
stepByStep
|
||||||
|
..writeln('}) {')
|
||||||
|
..write('return ')
|
||||||
|
..writeDriftRef('Migrator')
|
||||||
|
..writeln('.stepByStepHelper(step: (currentVersion, database) async {')
|
||||||
|
..writeln('switch (currentVersion) {');
|
||||||
|
|
||||||
|
for (final (current, next) in versions.withNext) {
|
||||||
|
stepByStep
|
||||||
|
..writeln('case ${current.version}:')
|
||||||
|
..write('final schema = _S${next.version}(database: database);')
|
||||||
|
..write('final migrator = ')
|
||||||
|
..writeDriftRef('Migrator')
|
||||||
|
..writeln('(database, schema);')
|
||||||
|
..writeln(
|
||||||
|
'await from${current.version}To${next.version}(migrator, schema);')
|
||||||
|
..writeln('return ${next.version};');
|
||||||
|
}
|
||||||
|
|
||||||
|
stepByStep
|
||||||
|
..writeln(
|
||||||
|
r"default: throw ArgumentError.value('Unknown migration from $currentVersion');")
|
||||||
|
..writeln('}') // End of switch
|
||||||
|
..writeln('}') // End of stepByStepHelper function
|
||||||
|
..writeln(');') // End of stepByStepHelper call
|
||||||
|
..writeln('}'); // End of method
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension<T> on Iterable<T> {
|
||||||
|
Iterable<(T, T)> get withNext sync* {
|
||||||
|
final iterator = this.iterator;
|
||||||
|
if (!iterator.moveNext()) return;
|
||||||
|
|
||||||
|
var a = iterator.current;
|
||||||
|
while (iterator.moveNext()) {
|
||||||
|
var b = iterator.current;
|
||||||
|
yield (a, b);
|
||||||
|
|
||||||
|
a = b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -598,8 +598,7 @@ class TableWriter extends TableOrViewWriter {
|
||||||
|
|
||||||
if (table.isVirtual) {
|
if (table.isVirtual) {
|
||||||
final stmt = table.virtualTableData!;
|
final stmt = table.virtualTableData!;
|
||||||
final moduleAndArgs =
|
final moduleAndArgs = asDartLiteral(stmt.moduleAndArgs);
|
||||||
asDartLiteral('${stmt.module}(${stmt.moduleArguments.join(', ')})');
|
|
||||||
buffer
|
buffer
|
||||||
..write('@override\n')
|
..write('@override\n')
|
||||||
..write('String get moduleAndArgs => $moduleAndArgs;\n');
|
..write('String get moduleAndArgs => $moduleAndArgs;\n');
|
||||||
|
|
|
@ -20,9 +20,9 @@ Run
|
||||||
dart run drift_dev schema generate drift_migrations/ test/generated/ --data-classes --companions
|
dart run drift_dev schema generate drift_migrations/ test/generated/ --data-classes --companions
|
||||||
```
|
```
|
||||||
|
|
||||||
We're also using test code inside `lib/` to run migrations with older definitions of tables.
|
Since we're using the step-by-step generator to make writing migrations easier, this command
|
||||||
This isn't required for all migrations, but can be useful in some cases.
|
is used to generate a helper file in `lib/`:
|
||||||
|
|
||||||
```
|
```
|
||||||
dart run drift_dev schema generate drift_migrations/ lib/src/generated
|
dart run drift_dev schema steps drift_migrations/ lib/src/versions.dart
|
||||||
```
|
```
|
||||||
|
|
|
@ -2,9 +2,7 @@ import 'package:drift/drift.dart';
|
||||||
import 'package:drift_dev/api/migrations.dart';
|
import 'package:drift_dev/api/migrations.dart';
|
||||||
|
|
||||||
import 'tables.dart';
|
import 'tables.dart';
|
||||||
import 'src/generated/schema_v2.dart' as v2;
|
import 'src/versions.dart';
|
||||||
import 'src/generated/schema_v4.dart' as v4;
|
|
||||||
import 'src/generated/schema_v8.dart' as v8;
|
|
||||||
|
|
||||||
part 'database.g.dart';
|
part 'database.g.dart';
|
||||||
|
|
||||||
|
@ -20,59 +18,7 @@ class Database extends _$Database {
|
||||||
@override
|
@override
|
||||||
MigrationStrategy get migration {
|
MigrationStrategy get migration {
|
||||||
return MigrationStrategy(
|
return MigrationStrategy(
|
||||||
onUpgrade: (m, before, now) async {
|
onUpgrade: _upgrade,
|
||||||
for (var target = before + 1; target <= now; target++) {
|
|
||||||
switch (target) {
|
|
||||||
case 2:
|
|
||||||
// Migration from 1 to 2: Add name column in users. Use "no name"
|
|
||||||
// as a default value.
|
|
||||||
final usersAtV2 = v2.Users(this);
|
|
||||||
|
|
||||||
await m.alterTable(
|
|
||||||
TableMigration(
|
|
||||||
usersAtV2,
|
|
||||||
columnTransformer: {
|
|
||||||
users.name: const Constant<String>('no name'),
|
|
||||||
},
|
|
||||||
newColumns: [usersAtV2.name],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
// Migration from 2 to 3: We added the groups table
|
|
||||||
await m.createTable(groups);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
// 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));
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
// Just add a new column that was added in version 5;
|
|
||||||
await m.addColumn(users, users.nextUser);
|
|
||||||
|
|
||||||
// And create the view on users
|
|
||||||
await m.createView(groupCount);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
await m.addColumn(users, users.birthday);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
await m.createTable(notes);
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
// Added a unique key to the users table
|
|
||||||
await m.alterTable(TableMigration(v8.Users(this)));
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
// Added a check to the users table
|
|
||||||
await m.alterTable(TableMigration(users));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
beforeOpen: (details) async {
|
beforeOpen: (details) async {
|
||||||
// For Flutter apps, this should be wrapped in an if (kDebugMode) as
|
// For Flutter apps, this should be wrapped in an if (kDebugMode) as
|
||||||
// suggested here: https://drift.simonbinder.eu/docs/advanced-features/migrations/#verifying-a-database-schema-at-runtime
|
// suggested here: https://drift.simonbinder.eu/docs/advanced-features/migrations/#verifying-a-database-schema-at-runtime
|
||||||
|
@ -80,4 +26,50 @@ class Database extends _$Database {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final _upgrade = stepByStep(
|
||||||
|
from1To2: (m, schema) async {
|
||||||
|
// Migration from 1 to 2: Add name column in users. Use "no name"
|
||||||
|
// as a default value.
|
||||||
|
|
||||||
|
await m.alterTable(
|
||||||
|
TableMigration(
|
||||||
|
schema.users,
|
||||||
|
columnTransformer: {
|
||||||
|
schema.users.name: const Constant<String>('no name'),
|
||||||
|
},
|
||||||
|
newColumns: [schema.users.name],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
from2To3: (m, schema) async => m.createTable(schema.groups),
|
||||||
|
from3To4: (m, schema) async {
|
||||||
|
// 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 = schema.users;
|
||||||
|
|
||||||
|
await m.alterTable(TableMigration(usersAtV4));
|
||||||
|
},
|
||||||
|
from4To5: (m, schema) async {
|
||||||
|
// Just add a new column that was added in version 5;
|
||||||
|
await m.addColumn(schema.users, schema.users.nextUser);
|
||||||
|
|
||||||
|
// And create the view on users
|
||||||
|
await m.createView(schema.groupCount);
|
||||||
|
},
|
||||||
|
from5To6: (m, schema) async {
|
||||||
|
await m.addColumn(schema.users, schema.users.birthday);
|
||||||
|
},
|
||||||
|
from6To7: (m, schema) async {
|
||||||
|
await m.createTable(schema.notes);
|
||||||
|
},
|
||||||
|
from7To8: (m, schema) async {
|
||||||
|
// Added a unique key to the users table
|
||||||
|
await m.alterTable(TableMigration(schema.users));
|
||||||
|
},
|
||||||
|
from8To9: (m, schema) async {
|
||||||
|
// Added a check to the users table
|
||||||
|
await m.alterTable(TableMigration(schema.users));
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -874,7 +874,7 @@ class GroupCount extends ViewInfo<GroupCount, GroupCountData>
|
||||||
@override
|
@override
|
||||||
Query? get query => null;
|
Query? get query => null;
|
||||||
@override
|
@override
|
||||||
Set<String> get readTables => const {'groups', 'users'};
|
Set<String> get readTables => const {'users', 'groups'};
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _$Database extends GeneratedDatabase {
|
abstract class _$Database extends GeneratedDatabase {
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
//@dart=2.12
|
|
||||||
import 'package:drift/drift.dart';
|
|
||||||
import 'package:drift/internal/migrations.dart';
|
|
||||||
import 'schema_v1.dart' as v1;
|
|
||||||
import 'schema_v2.dart' as v2;
|
|
||||||
import 'schema_v3.dart' as v3;
|
|
||||||
import 'schema_v4.dart' as v4;
|
|
||||||
import 'schema_v5.dart' as v5;
|
|
||||||
import 'schema_v6.dart' as v6;
|
|
||||||
import 'schema_v7.dart' as v7;
|
|
||||||
import 'schema_v8.dart' as v8;
|
|
||||||
import 'schema_v9.dart' as v9;
|
|
||||||
|
|
||||||
class GeneratedHelper implements SchemaInstantiationHelper {
|
|
||||||
@override
|
|
||||||
GeneratedDatabase databaseForVersion(QueryExecutor db, int version) {
|
|
||||||
switch (version) {
|
|
||||||
case 1:
|
|
||||||
return v1.DatabaseAtV1(db);
|
|
||||||
case 2:
|
|
||||||
return v2.DatabaseAtV2(db);
|
|
||||||
case 3:
|
|
||||||
return v3.DatabaseAtV3(db);
|
|
||||||
case 4:
|
|
||||||
return v4.DatabaseAtV4(db);
|
|
||||||
case 5:
|
|
||||||
return v5.DatabaseAtV5(db);
|
|
||||||
case 6:
|
|
||||||
return v6.DatabaseAtV6(db);
|
|
||||||
case 7:
|
|
||||||
return v7.DatabaseAtV7(db);
|
|
||||||
case 8:
|
|
||||||
return v8.DatabaseAtV8(db);
|
|
||||||
case 9:
|
|
||||||
return v9.DatabaseAtV9(db);
|
|
||||||
default:
|
|
||||||
throw MissingSchemaException(
|
|
||||||
version, const {1, 2, 3, 4, 5, 6, 7, 8, 9});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
//@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,
|
|
||||||
hasAutoIncrement: true,
|
|
||||||
type: DriftSqlType.int,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints:
|
|
||||||
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
||||||
@override
|
|
||||||
List<GeneratedColumn> get $columns => [id];
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DatabaseAtV1 extends GeneratedDatabase {
|
|
||||||
DatabaseAtV1(QueryExecutor e) : super(e);
|
|
||||||
late final Users users = Users(this);
|
|
||||||
@override
|
|
||||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
||||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
||||||
@override
|
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
|
||||||
@override
|
|
||||||
int get schemaVersion => 1;
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
//@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,
|
|
||||||
hasAutoIncrement: true,
|
|
||||||
type: DriftSqlType.int,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints:
|
|
||||||
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
||||||
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
|
||||||
'name', aliasedName, false,
|
|
||||||
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
||||||
@override
|
|
||||||
List<GeneratedColumn> get $columns => [id, name];
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DatabaseAtV2 extends GeneratedDatabase {
|
|
||||||
DatabaseAtV2(QueryExecutor e) : super(e);
|
|
||||||
late final Users users = Users(this);
|
|
||||||
@override
|
|
||||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
||||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
||||||
@override
|
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
|
||||||
@override
|
|
||||||
int get schemaVersion => 2;
|
|
||||||
}
|
|
|
@ -1,101 +0,0 @@
|
||||||
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
//@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,
|
|
||||||
hasAutoIncrement: true,
|
|
||||||
type: DriftSqlType.int,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints:
|
|
||||||
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
||||||
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
|
||||||
'name', aliasedName, false,
|
|
||||||
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
||||||
@override
|
|
||||||
List<GeneratedColumn> get $columns => [id, name];
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 DatabaseAtV3 extends GeneratedDatabase {
|
|
||||||
DatabaseAtV3(QueryExecutor e) : super(e);
|
|
||||||
late final Users users = Users(this);
|
|
||||||
late final Groups groups = Groups(this);
|
|
||||||
@override
|
|
||||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
||||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
||||||
@override
|
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
|
||||||
@override
|
|
||||||
int get schemaVersion => 3;
|
|
||||||
}
|
|
|
@ -1,103 +0,0 @@
|
||||||
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
//@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,
|
|
||||||
hasAutoIncrement: true,
|
|
||||||
type: DriftSqlType.int,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints:
|
|
||||||
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
||||||
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
|
||||||
'name', aliasedName, false,
|
|
||||||
type: DriftSqlType.string,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultValue: const Constant('name'));
|
|
||||||
@override
|
|
||||||
List<GeneratedColumn> get $columns => [id, name];
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 DatabaseAtV4 extends GeneratedDatabase {
|
|
||||||
DatabaseAtV4(QueryExecutor e) : super(e);
|
|
||||||
late final Users users = Users(this);
|
|
||||||
late final Groups groups = Groups(this);
|
|
||||||
@override
|
|
||||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
||||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
||||||
@override
|
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
|
||||||
@override
|
|
||||||
int get schemaVersion => 4;
|
|
||||||
}
|
|
|
@ -1,154 +0,0 @@
|
||||||
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
//@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,
|
|
||||||
hasAutoIncrement: true,
|
|
||||||
type: DriftSqlType.int,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints:
|
|
||||||
GeneratedColumn.constraintIsAlways('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<int> nextUser = GeneratedColumn<int>(
|
|
||||||
'next_user', aliasedName, true,
|
|
||||||
type: DriftSqlType.int,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints:
|
|
||||||
GeneratedColumn.constraintIsAlways('REFERENCES users (id)'));
|
|
||||||
@override
|
|
||||||
List<GeneratedColumn> get $columns => [id, name, 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 GroupCount extends ViewInfo<GroupCount, Never> implements HasResultSet {
|
|
||||||
final String? _alias;
|
|
||||||
@override
|
|
||||||
final DatabaseAtV5 attachedDatabase;
|
|
||||||
GroupCount(this.attachedDatabase, [this._alias]);
|
|
||||||
@override
|
|
||||||
List<GeneratedColumn> get $columns => [id, name, nextUser, groupCount];
|
|
||||||
@override
|
|
||||||
String get aliasedName => _alias ?? entityName;
|
|
||||||
@override
|
|
||||||
String get entityName => 'group_count';
|
|
||||||
@override
|
|
||||||
String get createViewStmt =>
|
|
||||||
'CREATE VIEW group_count AS SELECT users.*, (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count FROM users';
|
|
||||||
@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<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 DatabaseAtV5 extends GeneratedDatabase {
|
|
||||||
DatabaseAtV5(QueryExecutor e) : super(e);
|
|
||||||
late final Users users = Users(this);
|
|
||||||
late final Groups groups = Groups(this);
|
|
||||||
late final GroupCount groupCount = GroupCount(this);
|
|
||||||
@override
|
|
||||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
||||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
||||||
@override
|
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
|
||||||
[users, groups, groupCount];
|
|
||||||
@override
|
|
||||||
int get schemaVersion => 5;
|
|
||||||
}
|
|
|
@ -1,164 +0,0 @@
|
||||||
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
//@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,
|
|
||||||
hasAutoIncrement: true,
|
|
||||||
type: DriftSqlType.int,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints:
|
|
||||||
GeneratedColumn.constraintIsAlways('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:
|
|
||||||
GeneratedColumn.constraintIsAlways('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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 GroupCount extends ViewInfo<GroupCount, Never> implements HasResultSet {
|
|
||||||
final String? _alias;
|
|
||||||
@override
|
|
||||||
final DatabaseAtV6 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 =>
|
|
||||||
'CREATE VIEW group_count AS SELECT users.*, (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count FROM users';
|
|
||||||
@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 DatabaseAtV6 extends GeneratedDatabase {
|
|
||||||
DatabaseAtV6(QueryExecutor e) : super(e);
|
|
||||||
late final Users users = Users(this);
|
|
||||||
late final Groups groups = Groups(this);
|
|
||||||
late final GroupCount groupCount = GroupCount(this);
|
|
||||||
@override
|
|
||||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
||||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
||||||
@override
|
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
|
||||||
[users, groups, groupCount];
|
|
||||||
@override
|
|
||||||
int get schemaVersion => 6;
|
|
||||||
@override
|
|
||||||
DriftDatabaseOptions get options =>
|
|
||||||
const DriftDatabaseOptions(storeDateTimeAsText: true);
|
|
||||||
}
|
|
|
@ -1,208 +0,0 @@
|
||||||
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
//@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,
|
|
||||||
hasAutoIncrement: true,
|
|
||||||
type: DriftSqlType.int,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints:
|
|
||||||
GeneratedColumn.constraintIsAlways('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:
|
|
||||||
GeneratedColumn.constraintIsAlways('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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 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 =>
|
|
||||||
'CREATE VIEW group_count AS SELECT users.*, (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count FROM users';
|
|
||||||
@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 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 => const {};
|
|
||||||
@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
|
|
||||||
String get moduleAndArgs =>
|
|
||||||
'fts5(title, content, search_terms, tokenize = "unicode61 tokenchars \'.\'")';
|
|
||||||
}
|
|
||||||
|
|
||||||
class DatabaseAtV7 extends GeneratedDatabase {
|
|
||||||
DatabaseAtV7(QueryExecutor e) : super(e);
|
|
||||||
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, Object?>> 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);
|
|
||||||
}
|
|
|
@ -1,212 +0,0 @@
|
||||||
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
//@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,
|
|
||||||
hasAutoIncrement: true,
|
|
||||||
type: DriftSqlType.int,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints:
|
|
||||||
GeneratedColumn.constraintIsAlways('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:
|
|
||||||
GeneratedColumn.constraintIsAlways('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
|
|
||||||
List<Set<GeneratedColumn>> get uniqueKeys => [
|
|
||||||
{name, birthday},
|
|
||||||
];
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 GroupCount extends ViewInfo<GroupCount, Never> implements HasResultSet {
|
|
||||||
final String? _alias;
|
|
||||||
@override
|
|
||||||
final DatabaseAtV8 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 =>
|
|
||||||
'CREATE VIEW group_count AS SELECT users.*, (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count FROM users';
|
|
||||||
@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 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 => const {};
|
|
||||||
@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
|
|
||||||
String get moduleAndArgs =>
|
|
||||||
'fts5(title, content, search_terms, tokenize = "unicode61 tokenchars \'.\'")';
|
|
||||||
}
|
|
||||||
|
|
||||||
class DatabaseAtV8 extends GeneratedDatabase {
|
|
||||||
DatabaseAtV8(QueryExecutor e) : super(e);
|
|
||||||
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, Object?>> get allTables =>
|
|
||||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
||||||
@override
|
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
|
||||||
[users, groups, groupCount, notes];
|
|
||||||
@override
|
|
||||||
int get schemaVersion => 8;
|
|
||||||
@override
|
|
||||||
DriftDatabaseOptions get options =>
|
|
||||||
const DriftDatabaseOptions(storeDateTimeAsText: true);
|
|
||||||
}
|
|
|
@ -1,215 +0,0 @@
|
||||||
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
//@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,
|
|
||||||
hasAutoIncrement: true,
|
|
||||||
type: DriftSqlType.int,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints:
|
|
||||||
GeneratedColumn.constraintIsAlways('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:
|
|
||||||
GeneratedColumn.constraintIsAlways('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
|
|
||||||
List<Set<GeneratedColumn>> get uniqueKeys => [
|
|
||||||
{name, birthday},
|
|
||||||
];
|
|
||||||
@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
|
|
||||||
List<String> get customConstraints => const ['CHECK (LENGTH(name) < 10)'];
|
|
||||||
}
|
|
||||||
|
|
||||||
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('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 => const {};
|
|
||||||
@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
|
|
||||||
String get moduleAndArgs =>
|
|
||||||
'fts5(title, content, search_terms, tokenize = "unicode61 tokenchars \'.\'")';
|
|
||||||
}
|
|
||||||
|
|
||||||
class GroupCount extends ViewInfo<GroupCount, Never> implements HasResultSet {
|
|
||||||
final String? _alias;
|
|
||||||
@override
|
|
||||||
final DatabaseAtV9 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 =>
|
|
||||||
'CREATE VIEW group_count AS SELECT\n users.*,\n (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count\n FROM users;';
|
|
||||||
@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 DatabaseAtV9 extends GeneratedDatabase {
|
|
||||||
DatabaseAtV9(QueryExecutor e) : super(e);
|
|
||||||
late final Users users = Users(this);
|
|
||||||
late final Groups groups = Groups(this);
|
|
||||||
late final Notes notes = Notes(this);
|
|
||||||
late final GroupCount groupCount = GroupCount(this);
|
|
||||||
@override
|
|
||||||
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
||||||
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
||||||
@override
|
|
||||||
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
|
||||||
[users, groups, notes, groupCount];
|
|
||||||
@override
|
|
||||||
int get schemaVersion => 9;
|
|
||||||
@override
|
|
||||||
DriftDatabaseOptions get options =>
|
|
||||||
const DriftDatabaseOptions(storeDateTimeAsText: true);
|
|
||||||
}
|
|
|
@ -2,351 +2,669 @@ import 'package:drift/internal/versioned_schema.dart' as i0;
|
||||||
import 'package:drift/drift.dart' as i1;
|
import 'package:drift/drift.dart' as i1;
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
|
|
||||||
final class VersionedSchema extends i0.VersionedSchema {
|
final class _S1 extends i0.VersionedSchema {
|
||||||
VersionedSchema(super.database);
|
_S1({required super.database}) : super(version: 1);
|
||||||
late final List<i1.DatabaseSchemaEntity> entities = [
|
|
||||||
// VERSION 1
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'users',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_0,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
// VERSION 2
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'users',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_0,
|
|
||||||
column_1,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
// VERSION 3
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'users',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_0,
|
|
||||||
column_1,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'groups',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_2,
|
|
||||||
column_3,
|
|
||||||
column_4,
|
|
||||||
column_5,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
// VERSION 4
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'users',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_0,
|
|
||||||
column_6,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'groups',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_2,
|
|
||||||
column_3,
|
|
||||||
column_4,
|
|
||||||
column_5,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
// VERSION 5
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'users',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_0,
|
|
||||||
column_6,
|
|
||||||
column_7,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'groups',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_2,
|
|
||||||
column_3,
|
|
||||||
column_4,
|
|
||||||
column_5,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
null,
|
|
||||||
// VERSION 6
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'users',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_0,
|
|
||||||
column_6,
|
|
||||||
column_8,
|
|
||||||
column_7,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'groups',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_2,
|
|
||||||
column_3,
|
|
||||||
column_4,
|
|
||||||
column_5,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
null,
|
|
||||||
// VERSION 7
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'users',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_0,
|
|
||||||
column_6,
|
|
||||||
column_8,
|
|
||||||
column_7,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'groups',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_2,
|
|
||||||
column_3,
|
|
||||||
column_4,
|
|
||||||
column_5,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
null,
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'notes',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_9,
|
|
||||||
column_10,
|
|
||||||
column_11,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
// VERSION 8
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'users',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_0,
|
|
||||||
column_6,
|
|
||||||
column_8,
|
|
||||||
column_12,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'groups',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_2,
|
|
||||||
column_3,
|
|
||||||
column_4,
|
|
||||||
column_5,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
null,
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'notes',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_9,
|
|
||||||
column_10,
|
|
||||||
column_11,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
// VERSION 9
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'users',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_0,
|
|
||||||
column_6,
|
|
||||||
column_8,
|
|
||||||
column_7,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'groups',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_2,
|
|
||||||
column_3,
|
|
||||||
column_13,
|
|
||||||
column_14,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
i0.VersionedTable(
|
|
||||||
entityName: 'notes',
|
|
||||||
withoutRowId: false,
|
|
||||||
isStrict: false,
|
|
||||||
attachedDatabase: database,
|
|
||||||
columns: [
|
|
||||||
column_9,
|
|
||||||
column_10,
|
|
||||||
column_11,
|
|
||||||
],
|
|
||||||
tableConstraints: [],
|
|
||||||
),
|
|
||||||
null,
|
|
||||||
];
|
|
||||||
@override
|
@override
|
||||||
Iterable<i1.DatabaseSchemaEntity> allEntitiesAt(int version) {
|
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||||
int start, count;
|
users,
|
||||||
switch (version) {
|
];
|
||||||
case 1:
|
late final Shape0 users = Shape0(
|
||||||
start = 0;
|
source: i0.VersionedTable(
|
||||||
count = 1;
|
entityName: 'users',
|
||||||
case 2:
|
withoutRowId: false,
|
||||||
start = 1;
|
isStrict: false,
|
||||||
count = 1;
|
tableConstraints: [],
|
||||||
case 3:
|
columns: [
|
||||||
start = 2;
|
_column_0,
|
||||||
count = 2;
|
],
|
||||||
case 4:
|
attachedDatabase: database,
|
||||||
start = 4;
|
),
|
||||||
count = 2;
|
alias: null);
|
||||||
case 5:
|
|
||||||
start = 6;
|
|
||||||
count = 3;
|
|
||||||
case 6:
|
|
||||||
start = 9;
|
|
||||||
count = 3;
|
|
||||||
case 7:
|
|
||||||
start = 12;
|
|
||||||
count = 4;
|
|
||||||
case 8:
|
|
||||||
start = 16;
|
|
||||||
count = 4;
|
|
||||||
case 9:
|
|
||||||
start = 20;
|
|
||||||
count = 4;
|
|
||||||
default:
|
|
||||||
throw ArgumentError('Unknown schema version $version');
|
|
||||||
}
|
|
||||||
return entities.skip(start).take(count);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i1.GeneratedColumn<int> column_0(String aliasedName) =>
|
class Shape0 extends i0.VersionedTable {
|
||||||
|
Shape0({required super.source, required super.alias}) : super.aliased();
|
||||||
|
i1.GeneratedColumn<int> get id =>
|
||||||
|
columnsByName['id']! as i1.GeneratedColumn<int>;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<int> _column_0(String aliasedName) =>
|
||||||
i1.GeneratedColumn<int>('id', aliasedName, false,
|
i1.GeneratedColumn<int>('id', aliasedName, false,
|
||||||
hasAutoIncrement: true,
|
hasAutoIncrement: true,
|
||||||
type: i1.DriftSqlType.int,
|
type: i1.DriftSqlType.int,
|
||||||
defaultConstraints:
|
defaultConstraints:
|
||||||
i1.GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
i1.GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
||||||
i1.GeneratedColumn<String> column_1(String aliasedName) =>
|
|
||||||
|
final class _S2 extends i0.VersionedSchema {
|
||||||
|
_S2({required super.database}) : super(version: 2);
|
||||||
|
@override
|
||||||
|
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||||
|
users,
|
||||||
|
];
|
||||||
|
late final Shape1 users = Shape1(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'users',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_1,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Shape1 extends i0.VersionedTable {
|
||||||
|
Shape1({required super.source, required super.alias}) : super.aliased();
|
||||||
|
i1.GeneratedColumn<int> get id =>
|
||||||
|
columnsByName['id']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<String> get name =>
|
||||||
|
columnsByName['name']! as i1.GeneratedColumn<String>;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<String> _column_1(String aliasedName) =>
|
||||||
i1.GeneratedColumn<String>('name', aliasedName, false,
|
i1.GeneratedColumn<String>('name', aliasedName, false,
|
||||||
type: i1.DriftSqlType.string);
|
type: i1.DriftSqlType.string);
|
||||||
i1.GeneratedColumn<int> column_2(String aliasedName) =>
|
|
||||||
|
final class _S3 extends i0.VersionedSchema {
|
||||||
|
_S3({required super.database}) : super(version: 3);
|
||||||
|
@override
|
||||||
|
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||||
|
users,
|
||||||
|
groups,
|
||||||
|
];
|
||||||
|
late final Shape1 users = Shape1(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'users',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_1,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape2 groups = Shape2(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'groups',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY (id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_2,
|
||||||
|
_column_3,
|
||||||
|
_column_4,
|
||||||
|
_column_5,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Shape2 extends i0.VersionedTable {
|
||||||
|
Shape2({required super.source, required super.alias}) : super.aliased();
|
||||||
|
i1.GeneratedColumn<int> get id =>
|
||||||
|
columnsByName['id']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<String> get title =>
|
||||||
|
columnsByName['title']! as i1.GeneratedColumn<String>;
|
||||||
|
i1.GeneratedColumn<bool> get deleted =>
|
||||||
|
columnsByName['deleted']! as i1.GeneratedColumn<bool>;
|
||||||
|
i1.GeneratedColumn<int> get owner =>
|
||||||
|
columnsByName['owner']! as i1.GeneratedColumn<int>;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<int> _column_2(String aliasedName) =>
|
||||||
i1.GeneratedColumn<int>('id', aliasedName, false,
|
i1.GeneratedColumn<int>('id', aliasedName, false,
|
||||||
type: i1.DriftSqlType.int, $customConstraints: 'NOT NULL');
|
type: i1.DriftSqlType.int, $customConstraints: 'NOT NULL');
|
||||||
i1.GeneratedColumn<String> column_3(String aliasedName) =>
|
i1.GeneratedColumn<String> _column_3(String aliasedName) =>
|
||||||
i1.GeneratedColumn<String>('title', aliasedName, false,
|
i1.GeneratedColumn<String>('title', aliasedName, false,
|
||||||
type: i1.DriftSqlType.string, $customConstraints: 'NOT NULL');
|
type: i1.DriftSqlType.string, $customConstraints: 'NOT NULL');
|
||||||
i1.GeneratedColumn<bool> column_4(String aliasedName) =>
|
i1.GeneratedColumn<bool> _column_4(String aliasedName) =>
|
||||||
i1.GeneratedColumn<bool>('deleted', aliasedName, true,
|
i1.GeneratedColumn<bool>('deleted', aliasedName, true,
|
||||||
type: i1.DriftSqlType.bool,
|
type: i1.DriftSqlType.bool,
|
||||||
$customConstraints: 'DEFAULT FALSE',
|
$customConstraints: 'DEFAULT FALSE',
|
||||||
defaultValue: const CustomExpression<bool>('FALSE'));
|
defaultValue: const CustomExpression<bool>('FALSE'));
|
||||||
i1.GeneratedColumn<int> column_5(String aliasedName) =>
|
i1.GeneratedColumn<int> _column_5(String aliasedName) =>
|
||||||
i1.GeneratedColumn<int>('owner', aliasedName, false,
|
i1.GeneratedColumn<int>('owner', aliasedName, false,
|
||||||
type: i1.DriftSqlType.int,
|
type: i1.DriftSqlType.int,
|
||||||
$customConstraints: 'NOT NULL REFERENCES users (id)');
|
$customConstraints: 'NOT NULL REFERENCES users (id)');
|
||||||
i1.GeneratedColumn<String> column_6(String aliasedName) =>
|
|
||||||
|
final class _S4 extends i0.VersionedSchema {
|
||||||
|
_S4({required super.database}) : super(version: 4);
|
||||||
|
@override
|
||||||
|
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||||
|
users,
|
||||||
|
groups,
|
||||||
|
];
|
||||||
|
late final Shape1 users = Shape1(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'users',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_6,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape2 groups = Shape2(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'groups',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY (id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_2,
|
||||||
|
_column_3,
|
||||||
|
_column_4,
|
||||||
|
_column_5,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<String> _column_6(String aliasedName) =>
|
||||||
i1.GeneratedColumn<String>('name', aliasedName, false,
|
i1.GeneratedColumn<String>('name', aliasedName, false,
|
||||||
type: i1.DriftSqlType.string, defaultValue: const Constant('name'));
|
type: i1.DriftSqlType.string, defaultValue: const Constant('name'));
|
||||||
i1.GeneratedColumn<int> column_7(String aliasedName) =>
|
|
||||||
|
final class _S5 extends i0.VersionedSchema {
|
||||||
|
_S5({required super.database}) : super(version: 5);
|
||||||
|
@override
|
||||||
|
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||||
|
users,
|
||||||
|
groups,
|
||||||
|
groupCount,
|
||||||
|
];
|
||||||
|
late final Shape3 users = Shape3(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'users',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_6,
|
||||||
|
_column_7,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape2 groups = Shape2(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'groups',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY (id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_2,
|
||||||
|
_column_3,
|
||||||
|
_column_4,
|
||||||
|
_column_5,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape4 groupCount = Shape4(
|
||||||
|
source: i0.VersionedView(
|
||||||
|
entityName: 'group_count',
|
||||||
|
createViewStmt:
|
||||||
|
'CREATE VIEW group_count AS SELECT users.*, (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count FROM users',
|
||||||
|
columns: [
|
||||||
|
_column_8,
|
||||||
|
_column_1,
|
||||||
|
_column_9,
|
||||||
|
_column_10,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Shape3 extends i0.VersionedTable {
|
||||||
|
Shape3({required super.source, required super.alias}) : super.aliased();
|
||||||
|
i1.GeneratedColumn<int> get id =>
|
||||||
|
columnsByName['id']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<String> get name =>
|
||||||
|
columnsByName['name']! as i1.GeneratedColumn<String>;
|
||||||
|
i1.GeneratedColumn<int> get nextUser =>
|
||||||
|
columnsByName['next_user']! as i1.GeneratedColumn<int>;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<int> _column_7(String aliasedName) =>
|
||||||
i1.GeneratedColumn<int>('next_user', aliasedName, true,
|
i1.GeneratedColumn<int>('next_user', aliasedName, true,
|
||||||
type: i1.DriftSqlType.int,
|
type: i1.DriftSqlType.int,
|
||||||
defaultConstraints:
|
defaultConstraints:
|
||||||
i1.GeneratedColumn.constraintIsAlways('REFERENCES users (id)'));
|
i1.GeneratedColumn.constraintIsAlways('REFERENCES users (id)'));
|
||||||
i1.GeneratedColumn<DateTime> column_8(String aliasedName) =>
|
|
||||||
|
class Shape4 extends i0.VersionedView {
|
||||||
|
Shape4({required super.source, required super.alias}) : super.aliased();
|
||||||
|
i1.GeneratedColumn<int> get id =>
|
||||||
|
columnsByName['id']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<String> get name =>
|
||||||
|
columnsByName['name']! as i1.GeneratedColumn<String>;
|
||||||
|
i1.GeneratedColumn<int> get nextUser =>
|
||||||
|
columnsByName['next_user']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<int> get groupCount =>
|
||||||
|
columnsByName['group_count']! as i1.GeneratedColumn<int>;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<int> _column_8(String aliasedName) =>
|
||||||
|
i1.GeneratedColumn<int>('id', aliasedName, false,
|
||||||
|
type: i1.DriftSqlType.int);
|
||||||
|
i1.GeneratedColumn<int> _column_9(String aliasedName) =>
|
||||||
|
i1.GeneratedColumn<int>('next_user', aliasedName, true,
|
||||||
|
type: i1.DriftSqlType.int);
|
||||||
|
i1.GeneratedColumn<int> _column_10(String aliasedName) =>
|
||||||
|
i1.GeneratedColumn<int>('group_count', aliasedName, false,
|
||||||
|
type: i1.DriftSqlType.int);
|
||||||
|
|
||||||
|
final class _S6 extends i0.VersionedSchema {
|
||||||
|
_S6({required super.database}) : super(version: 6);
|
||||||
|
@override
|
||||||
|
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||||
|
users,
|
||||||
|
groups,
|
||||||
|
groupCount,
|
||||||
|
];
|
||||||
|
late final Shape5 users = Shape5(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'users',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_6,
|
||||||
|
_column_11,
|
||||||
|
_column_7,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape2 groups = Shape2(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'groups',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY (id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_2,
|
||||||
|
_column_3,
|
||||||
|
_column_4,
|
||||||
|
_column_5,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape6 groupCount = Shape6(
|
||||||
|
source: i0.VersionedView(
|
||||||
|
entityName: 'group_count',
|
||||||
|
createViewStmt:
|
||||||
|
'CREATE VIEW group_count AS SELECT users.*, (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count FROM users',
|
||||||
|
columns: [
|
||||||
|
_column_8,
|
||||||
|
_column_1,
|
||||||
|
_column_11,
|
||||||
|
_column_9,
|
||||||
|
_column_10,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Shape5 extends i0.VersionedTable {
|
||||||
|
Shape5({required super.source, required super.alias}) : super.aliased();
|
||||||
|
i1.GeneratedColumn<int> get id =>
|
||||||
|
columnsByName['id']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<String> get name =>
|
||||||
|
columnsByName['name']! as i1.GeneratedColumn<String>;
|
||||||
|
i1.GeneratedColumn<DateTime> get birthday =>
|
||||||
|
columnsByName['birthday']! as i1.GeneratedColumn<DateTime>;
|
||||||
|
i1.GeneratedColumn<int> get nextUser =>
|
||||||
|
columnsByName['next_user']! as i1.GeneratedColumn<int>;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<DateTime> _column_11(String aliasedName) =>
|
||||||
i1.GeneratedColumn<DateTime>('birthday', aliasedName, true,
|
i1.GeneratedColumn<DateTime>('birthday', aliasedName, true,
|
||||||
type: i1.DriftSqlType.dateTime);
|
type: i1.DriftSqlType.dateTime);
|
||||||
i1.GeneratedColumn<String> column_9(String aliasedName) =>
|
|
||||||
|
class Shape6 extends i0.VersionedView {
|
||||||
|
Shape6({required super.source, required super.alias}) : super.aliased();
|
||||||
|
i1.GeneratedColumn<int> get id =>
|
||||||
|
columnsByName['id']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<String> get name =>
|
||||||
|
columnsByName['name']! as i1.GeneratedColumn<String>;
|
||||||
|
i1.GeneratedColumn<DateTime> get birthday =>
|
||||||
|
columnsByName['birthday']! as i1.GeneratedColumn<DateTime>;
|
||||||
|
i1.GeneratedColumn<int> get nextUser =>
|
||||||
|
columnsByName['next_user']! as i1.GeneratedColumn<int>;
|
||||||
|
i1.GeneratedColumn<int> get groupCount =>
|
||||||
|
columnsByName['group_count']! as i1.GeneratedColumn<int>;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _S7 extends i0.VersionedSchema {
|
||||||
|
_S7({required super.database}) : super(version: 7);
|
||||||
|
@override
|
||||||
|
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||||
|
users,
|
||||||
|
groups,
|
||||||
|
groupCount,
|
||||||
|
notes,
|
||||||
|
];
|
||||||
|
late final Shape5 users = Shape5(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'users',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_6,
|
||||||
|
_column_11,
|
||||||
|
_column_7,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape2 groups = Shape2(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'groups',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY (id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_2,
|
||||||
|
_column_3,
|
||||||
|
_column_4,
|
||||||
|
_column_5,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape6 groupCount = Shape6(
|
||||||
|
source: i0.VersionedView(
|
||||||
|
entityName: 'group_count',
|
||||||
|
createViewStmt:
|
||||||
|
'CREATE VIEW group_count AS SELECT users.*, (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count FROM users',
|
||||||
|
columns: [
|
||||||
|
_column_8,
|
||||||
|
_column_1,
|
||||||
|
_column_11,
|
||||||
|
_column_9,
|
||||||
|
_column_10,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape7 notes = Shape7(
|
||||||
|
source: i0.VersionedVirtualTable(
|
||||||
|
entityName: 'notes',
|
||||||
|
moduleAndArgs:
|
||||||
|
'fts5(title, content, search_terms, tokenize = "unicode61 tokenchars \'.\'")',
|
||||||
|
columns: [
|
||||||
|
_column_12,
|
||||||
|
_column_13,
|
||||||
|
_column_14,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Shape7 extends i0.VersionedVirtualTable {
|
||||||
|
Shape7({required super.source, required super.alias}) : super.aliased();
|
||||||
|
i1.GeneratedColumn<String> get title =>
|
||||||
|
columnsByName['title']! as i1.GeneratedColumn<String>;
|
||||||
|
i1.GeneratedColumn<String> get content =>
|
||||||
|
columnsByName['content']! as i1.GeneratedColumn<String>;
|
||||||
|
i1.GeneratedColumn<String> get searchTerms =>
|
||||||
|
columnsByName['search_terms']! as i1.GeneratedColumn<String>;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<String> _column_12(String aliasedName) =>
|
||||||
i1.GeneratedColumn<String>('title', aliasedName, false,
|
i1.GeneratedColumn<String>('title', aliasedName, false,
|
||||||
type: i1.DriftSqlType.string, $customConstraints: '');
|
type: i1.DriftSqlType.string, $customConstraints: '');
|
||||||
i1.GeneratedColumn<String> column_10(String aliasedName) =>
|
i1.GeneratedColumn<String> _column_13(String aliasedName) =>
|
||||||
i1.GeneratedColumn<String>('content', aliasedName, false,
|
i1.GeneratedColumn<String>('content', aliasedName, false,
|
||||||
type: i1.DriftSqlType.string, $customConstraints: '');
|
type: i1.DriftSqlType.string, $customConstraints: '');
|
||||||
i1.GeneratedColumn<String> column_11(String aliasedName) =>
|
i1.GeneratedColumn<String> _column_14(String aliasedName) =>
|
||||||
i1.GeneratedColumn<String>('search_terms', aliasedName, false,
|
i1.GeneratedColumn<String>('search_terms', aliasedName, false,
|
||||||
type: i1.DriftSqlType.string, $customConstraints: '');
|
type: i1.DriftSqlType.string, $customConstraints: '');
|
||||||
i1.GeneratedColumn<int> column_12(String aliasedName) =>
|
|
||||||
|
final class _S8 extends i0.VersionedSchema {
|
||||||
|
_S8({required super.database}) : super(version: 8);
|
||||||
|
@override
|
||||||
|
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||||
|
users,
|
||||||
|
groups,
|
||||||
|
groupCount,
|
||||||
|
notes,
|
||||||
|
];
|
||||||
|
late final Shape5 users = Shape5(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'users',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [
|
||||||
|
'UNIQUE(name, birthday)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_6,
|
||||||
|
_column_11,
|
||||||
|
_column_15,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape2 groups = Shape2(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'groups',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY (id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_2,
|
||||||
|
_column_3,
|
||||||
|
_column_4,
|
||||||
|
_column_5,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape6 groupCount = Shape6(
|
||||||
|
source: i0.VersionedView(
|
||||||
|
entityName: 'group_count',
|
||||||
|
createViewStmt:
|
||||||
|
'CREATE VIEW group_count AS SELECT users.*, (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count FROM users',
|
||||||
|
columns: [
|
||||||
|
_column_8,
|
||||||
|
_column_1,
|
||||||
|
_column_11,
|
||||||
|
_column_9,
|
||||||
|
_column_10,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape7 notes = Shape7(
|
||||||
|
source: i0.VersionedVirtualTable(
|
||||||
|
entityName: 'notes',
|
||||||
|
moduleAndArgs:
|
||||||
|
'fts5(title, content, search_terms, tokenize = "unicode61 tokenchars \'.\'")',
|
||||||
|
columns: [
|
||||||
|
_column_12,
|
||||||
|
_column_13,
|
||||||
|
_column_14,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<int> _column_15(String aliasedName) =>
|
||||||
i1.GeneratedColumn<int>('next_user', aliasedName, true,
|
i1.GeneratedColumn<int>('next_user', aliasedName, true,
|
||||||
type: i1.DriftSqlType.int,
|
type: i1.DriftSqlType.int,
|
||||||
defaultConstraints:
|
defaultConstraints:
|
||||||
i1.GeneratedColumn.constraintIsAlways('REFERENCES "users" ("id")'));
|
i1.GeneratedColumn.constraintIsAlways('REFERENCES "users" ("id")'));
|
||||||
i1.GeneratedColumn<bool> column_13(String aliasedName) =>
|
|
||||||
|
final class _S9 extends i0.VersionedSchema {
|
||||||
|
_S9({required super.database}) : super(version: 9);
|
||||||
|
@override
|
||||||
|
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||||
|
users,
|
||||||
|
groups,
|
||||||
|
notes,
|
||||||
|
groupCount,
|
||||||
|
];
|
||||||
|
late final Shape5 users = Shape5(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'users',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [
|
||||||
|
'UNIQUE(name, birthday)',
|
||||||
|
'CHECK (LENGTH(name) < 10)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_0,
|
||||||
|
_column_6,
|
||||||
|
_column_11,
|
||||||
|
_column_7,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape2 groups = Shape2(
|
||||||
|
source: i0.VersionedTable(
|
||||||
|
entityName: 'groups',
|
||||||
|
withoutRowId: false,
|
||||||
|
isStrict: false,
|
||||||
|
tableConstraints: [
|
||||||
|
'PRIMARY KEY(id)',
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
_column_2,
|
||||||
|
_column_3,
|
||||||
|
_column_16,
|
||||||
|
_column_17,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape7 notes = Shape7(
|
||||||
|
source: i0.VersionedVirtualTable(
|
||||||
|
entityName: 'notes',
|
||||||
|
moduleAndArgs:
|
||||||
|
'fts5(title, content, search_terms, tokenize = "unicode61 tokenchars \'.\'")',
|
||||||
|
columns: [
|
||||||
|
_column_12,
|
||||||
|
_column_13,
|
||||||
|
_column_14,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
late final Shape6 groupCount = Shape6(
|
||||||
|
source: i0.VersionedView(
|
||||||
|
entityName: 'group_count',
|
||||||
|
createViewStmt:
|
||||||
|
'CREATE VIEW group_count AS SELECT\n users.*,\n (SELECT COUNT(*) FROM "groups" WHERE owner = users.id) AS group_count\n FROM users;',
|
||||||
|
columns: [
|
||||||
|
_column_8,
|
||||||
|
_column_1,
|
||||||
|
_column_11,
|
||||||
|
_column_9,
|
||||||
|
_column_10,
|
||||||
|
],
|
||||||
|
attachedDatabase: database,
|
||||||
|
),
|
||||||
|
alias: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
i1.GeneratedColumn<bool> _column_16(String aliasedName) =>
|
||||||
i1.GeneratedColumn<bool>('deleted', aliasedName, true,
|
i1.GeneratedColumn<bool>('deleted', aliasedName, true,
|
||||||
type: i1.DriftSqlType.bool,
|
type: i1.DriftSqlType.bool,
|
||||||
$customConstraints: 'DEFAULT FALSE',
|
$customConstraints: 'DEFAULT FALSE',
|
||||||
defaultValue: const CustomExpression('FALSE'));
|
defaultValue: const CustomExpression('FALSE'));
|
||||||
i1.GeneratedColumn<int> column_14(String aliasedName) =>
|
i1.GeneratedColumn<int> _column_17(String aliasedName) =>
|
||||||
i1.GeneratedColumn<int>('owner', aliasedName, false,
|
i1.GeneratedColumn<int>('owner', aliasedName, false,
|
||||||
type: i1.DriftSqlType.int,
|
type: i1.DriftSqlType.int,
|
||||||
$customConstraints: 'NOT NULL REFERENCES users(id)');
|
$customConstraints: 'NOT NULL REFERENCES users(id)');
|
||||||
|
i1.OnUpgrade stepByStep({
|
||||||
|
required Future<void> Function(i1.Migrator m, _S2 schema) from1To2,
|
||||||
|
required Future<void> Function(i1.Migrator m, _S3 schema) from2To3,
|
||||||
|
required Future<void> Function(i1.Migrator m, _S4 schema) from3To4,
|
||||||
|
required Future<void> Function(i1.Migrator m, _S5 schema) from4To5,
|
||||||
|
required Future<void> Function(i1.Migrator m, _S6 schema) from5To6,
|
||||||
|
required Future<void> Function(i1.Migrator m, _S7 schema) from6To7,
|
||||||
|
required Future<void> Function(i1.Migrator m, _S8 schema) from7To8,
|
||||||
|
required Future<void> Function(i1.Migrator m, _S9 schema) from8To9,
|
||||||
|
}) {
|
||||||
|
return i1.Migrator.stepByStepHelper(step: (currentVersion, database) async {
|
||||||
|
switch (currentVersion) {
|
||||||
|
case 1:
|
||||||
|
final schema = _S2(database: database);
|
||||||
|
final migrator = i1.Migrator(database, schema);
|
||||||
|
await from1To2(migrator, schema);
|
||||||
|
return 2;
|
||||||
|
case 2:
|
||||||
|
final schema = _S3(database: database);
|
||||||
|
final migrator = i1.Migrator(database, schema);
|
||||||
|
await from2To3(migrator, schema);
|
||||||
|
return 3;
|
||||||
|
case 3:
|
||||||
|
final schema = _S4(database: database);
|
||||||
|
final migrator = i1.Migrator(database, schema);
|
||||||
|
await from3To4(migrator, schema);
|
||||||
|
return 4;
|
||||||
|
case 4:
|
||||||
|
final schema = _S5(database: database);
|
||||||
|
final migrator = i1.Migrator(database, schema);
|
||||||
|
await from4To5(migrator, schema);
|
||||||
|
return 5;
|
||||||
|
case 5:
|
||||||
|
final schema = _S6(database: database);
|
||||||
|
final migrator = i1.Migrator(database, schema);
|
||||||
|
await from5To6(migrator, schema);
|
||||||
|
return 6;
|
||||||
|
case 6:
|
||||||
|
final schema = _S7(database: database);
|
||||||
|
final migrator = i1.Migrator(database, schema);
|
||||||
|
await from6To7(migrator, schema);
|
||||||
|
return 7;
|
||||||
|
case 7:
|
||||||
|
final schema = _S8(database: database);
|
||||||
|
final migrator = i1.Migrator(database, schema);
|
||||||
|
await from7To8(migrator, schema);
|
||||||
|
return 8;
|
||||||
|
case 8:
|
||||||
|
final schema = _S9(database: database);
|
||||||
|
final migrator = i1.Migrator(database, schema);
|
||||||
|
await from8To9(migrator, schema);
|
||||||
|
return 9;
|
||||||
|
default:
|
||||||
|
throw ArgumentError.value('Unknown migration from $currentVersion');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
32
pubspec.lock
32
pubspec.lock
|
@ -13,10 +13,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: args
|
name: args
|
||||||
sha256: c372bb384f273f0c2a8aaaa226dad84dc27c8519a691b888725dec59518ad53a
|
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.1"
|
version: "2.4.2"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -53,10 +53,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: cli_util
|
name: cli_util
|
||||||
sha256: "66f86e916d285c1a93d3b79587d94bd71984a66aac4ff74e524cfa7877f1395c"
|
sha256: b8db3080e59b2503ca9e7922c3df2072cf13992354d5e944074ffa836fba43b7
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.5"
|
version: "0.4.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -85,18 +85,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: glob
|
name: glob
|
||||||
sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c"
|
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
graphs:
|
graphs:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: graphs
|
name: graphs
|
||||||
sha256: "772db3d53d23361d4ffcf5a9bb091cf3ee9b22f2be52cd107cd7a2683a89ba0e"
|
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.0"
|
version: "2.3.1"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -133,18 +133,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
|
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.15"
|
version: "0.12.16"
|
||||||
melos:
|
melos:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: melos
|
name: melos
|
||||||
sha256: "993ac467e7a36bd832a6cdabbe18a0487c30bc52b5cca14e476a824679ebdce0"
|
sha256: ccbb6ecd8bb3f08ae8f9ce22920d816bff325a98940c845eda0257cd395503ac
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "3.1.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -253,10 +253,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -277,10 +277,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: daadc9baabec998b062c9091525aa95786508b1c48e9c30f1f891b8bf6ff2e64
|
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.2"
|
version: "0.6.0"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in New Issue