Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
226 lines
6.2 KiB
Dart
226 lines
6.2 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:drift/drift.dart';
|
|
import 'package:drift/native.dart';
|
|
import 'package:path/path.dart' as p;
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
part 'app_database.g.dart';
|
|
|
|
class RecentProjectRecords extends Table {
|
|
TextColumn get id => text()();
|
|
TextColumn get name => text()();
|
|
TextColumn get path => text()();
|
|
IntColumn get position => integer()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {id};
|
|
}
|
|
|
|
class LastOpenedTimelines extends Table {
|
|
TextColumn get projectId => text()();
|
|
TextColumn get timelineId => text()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {projectId};
|
|
}
|
|
|
|
class McpConfigurations extends Table {
|
|
IntColumn get id => integer()();
|
|
BoolColumn get enabled => boolean()();
|
|
IntColumn get port => integer()();
|
|
TextColumn get token => text()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {id};
|
|
}
|
|
|
|
class AppearanceConfigurations extends Table {
|
|
IntColumn get id => integer()();
|
|
TextColumn get themeMode => text()();
|
|
TextColumn get palette => text().withDefault(const Constant('graphite'))();
|
|
TextColumn get timelineRulerLayout =>
|
|
text().withDefault(const Constant('inline'))();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {id};
|
|
}
|
|
|
|
class LanguageConfigurations extends Table {
|
|
IntColumn get id => integer()();
|
|
TextColumn get language => text()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {id};
|
|
}
|
|
|
|
class ConversationLocationConfigurations extends Table {
|
|
IntColumn get id => integer()();
|
|
TextColumn get directory => text()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {id};
|
|
}
|
|
|
|
class ProjectLocationConfigurations extends Table {
|
|
IntColumn get id => integer()();
|
|
TextColumn get directory => text()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {id};
|
|
}
|
|
|
|
class ResourceLocationConfigurations extends Table {
|
|
IntColumn get id => integer()();
|
|
TextColumn get directory => text()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {id};
|
|
}
|
|
|
|
class AgentConfigurations extends Table {
|
|
IntColumn get id => integer()();
|
|
BoolColumn get enabled => boolean()();
|
|
TextColumn get selectedProviderId => text().nullable()();
|
|
TextColumn get selectedModelId => text().nullable()();
|
|
IntColumn get revision => integer()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {id};
|
|
}
|
|
|
|
class AgentProviders extends Table {
|
|
BoolColumn get enabled => boolean().withDefault(const Constant(true))();
|
|
TextColumn get id => text()();
|
|
TextColumn get name => text()();
|
|
TextColumn get apiType => text()();
|
|
TextColumn get baseUrl => text()();
|
|
TextColumn get credentialId => text().nullable()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {id};
|
|
}
|
|
|
|
class AgentModels extends Table {
|
|
TextColumn get providerId => text()();
|
|
TextColumn get modelId => text()();
|
|
IntColumn get contextWindow => integer().nullable()();
|
|
IntColumn get maxOutputTokens => integer().nullable()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {providerId, modelId};
|
|
}
|
|
|
|
class WorkspaceViewConfigurations extends Table {
|
|
TextColumn get mode => text().withDefault(const Constant('agent'))();
|
|
IntColumn get id => integer()();
|
|
TextColumn get activeProjectId => text().nullable()();
|
|
BoolColumn get sidebarCollapsed => boolean()();
|
|
RealColumn get sidebarWidth => real().nullable()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {id};
|
|
}
|
|
|
|
class ProjectViewConfigurations extends Table {
|
|
TextColumn get projectId => text()();
|
|
BoolColumn get propertiesOpen => boolean()();
|
|
RealColumn get timelineHeight => real().nullable()();
|
|
RealColumn get mediaWidth => real().nullable()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {projectId};
|
|
}
|
|
|
|
class TimelineViewConfigurations extends Table {
|
|
TextColumn get projectId => text()();
|
|
TextColumn get timelineId => text()();
|
|
TextColumn get sequenceId => text()();
|
|
BoolColumn get active => boolean()();
|
|
IntColumn get playheadTick => integer()();
|
|
IntColumn get baseTick => integer()();
|
|
RealColumn get fractionalTick => real()();
|
|
RealColumn get pixelsPerTick => real()();
|
|
RealColumn get verticalOffset => real()();
|
|
|
|
@override
|
|
Set<Column<Object>> get primaryKey => {projectId, timelineId, sequenceId};
|
|
}
|
|
|
|
@DriftDatabase(
|
|
tables: [
|
|
RecentProjectRecords,
|
|
LastOpenedTimelines,
|
|
McpConfigurations,
|
|
AppearanceConfigurations,
|
|
LanguageConfigurations,
|
|
ConversationLocationConfigurations,
|
|
ProjectLocationConfigurations,
|
|
ResourceLocationConfigurations,
|
|
AgentConfigurations,
|
|
AgentProviders,
|
|
AgentModels,
|
|
WorkspaceViewConfigurations,
|
|
ProjectViewConfigurations,
|
|
TimelineViewConfigurations,
|
|
],
|
|
)
|
|
class AppDatabase extends _$AppDatabase {
|
|
AppDatabase(super.executor);
|
|
|
|
@override
|
|
int get schemaVersion => 5;
|
|
|
|
@override
|
|
MigrationStrategy get migration => MigrationStrategy(
|
|
onCreate: (migrator) => migrator.createAll(),
|
|
onUpgrade: (migrator, from, _) async {
|
|
if (from < 2 || from > 4) {
|
|
throw StateError('Unsupported app database schema version: $from');
|
|
}
|
|
if (from == 2) {
|
|
await migrator.addColumn(
|
|
appearanceConfigurations,
|
|
appearanceConfigurations.palette,
|
|
);
|
|
}
|
|
if (from < 4) {
|
|
await migrator.addColumn(
|
|
appearanceConfigurations,
|
|
appearanceConfigurations.timelineRulerLayout,
|
|
);
|
|
}
|
|
await migrator.addColumn(
|
|
projectViewConfigurations,
|
|
projectViewConfigurations.mediaWidth,
|
|
);
|
|
},
|
|
beforeOpen: (_) async {
|
|
await customStatement('PRAGMA journal_mode = WAL');
|
|
await customStatement('PRAGMA synchronous = FULL');
|
|
await customStatement('PRAGMA busy_timeout = 5000');
|
|
},
|
|
);
|
|
}
|
|
|
|
@Riverpod(keepAlive: true)
|
|
AppDatabase appDatabase(Ref ref) {
|
|
final database = AppDatabase(LazyDatabase(_openAppDatabase));
|
|
ref.onDispose(database.close);
|
|
return database;
|
|
}
|
|
|
|
Future<QueryExecutor> _openAppDatabase() async {
|
|
if (Platform.environment.containsKey('FLUTTER_TEST')) {
|
|
return NativeDatabase.memory();
|
|
}
|
|
final support = Directory(
|
|
p.join((await getApplicationSupportDirectory()).path, 'Cutdex'),
|
|
);
|
|
await support.create(recursive: true);
|
|
return NativeDatabase.createInBackground(
|
|
File(p.join(support.path, 'app.sqlite')),
|
|
);
|
|
}
|